From 0fa3fc88279bfc1acaa1fc6d13837fe48e36ba01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=20Gramn=C3=A6s=20Tjernshaugen?= Date: Mon, 22 Jul 2024 11:41:16 +0200 Subject: [PATCH 1/6] Randomized committee ordering every hour and removed outdated link --- src/pages/applications/index.tsx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/pages/applications/index.tsx b/src/pages/applications/index.tsx index 63d08e01..ecc3bbd0 100644 --- a/src/pages/applications/index.tsx +++ b/src/pages/applications/index.tsx @@ -4,6 +4,7 @@ import { IOnlineGroup } from 'groups/models/onlinegroup'; import React, { useEffect, useState } from 'react'; import style from '../../applications/committee.less'; +import crypto from 'crypto'; const Committees: React.FC = () => { const [committees, setCommittees] = useState([]); @@ -22,6 +23,17 @@ const Committees: React.FC = () => { CommitteeList.push(groups[i]); } } + + const getKey = (key: string) => { + const hash = crypto.createHash('sha256'); + const hour = Math.floor((+new Date()) / 3600000); + hash.update(key + hour.toString()); + return hash.digest('hex'); + } + + CommitteeList.sort((a, b) => { + return getKey(a.name_short) > getKey(b.name_short) ? 1 : -1; + }); setCommittees(CommitteeList); }); }, []); @@ -31,7 +43,7 @@ const Committees: React.FC = () => {
Komitémedlemmene våre får Online til å gå rundt, og arbeider for at alle informatikkstudenter skal ha en flott studiehverdag. -
Her kan du søke om å bli en av oss! + {/*
Her kan du søke om å bli en av oss! */ }
{committees.map((com) => { return ( @@ -42,11 +54,13 @@ const Committees: React.FC = () => { ); })} + {/*
Trykk her for å sende inn en søknad!
+ */} ); }; From e6dd5a231e47755ff935dd669e7968cec22b5258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=20Gramn=C3=A6s=20Tjernshaugen?= Date: Mon, 22 Jul 2024 11:46:43 +0200 Subject: [PATCH 2/6] Minor refactor --- src/pages/applications/index.tsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/pages/applications/index.tsx b/src/pages/applications/index.tsx index ecc3bbd0..67a490b4 100644 --- a/src/pages/applications/index.tsx +++ b/src/pages/applications/index.tsx @@ -6,6 +6,13 @@ import React, { useEffect, useState } from 'react'; import style from '../../applications/committee.less'; import crypto from 'crypto'; +const getHourlyUpdatedSortKey = (key: string) => { + const hash = crypto.createHash('sha256'); + const hour = Math.floor((+new Date()) / 3600000); + hash.update(key + hour.toString()); + return hash.digest('hex'); +} + const Committees: React.FC = () => { const [committees, setCommittees] = useState([]); const applicationFormUrl = 'https://forms.gle/BpQfh42FXfC85tNd6'; // updated for August 2023 @@ -22,17 +29,10 @@ const Committees: React.FC = () => { ) { CommitteeList.push(groups[i]); } - } - - const getKey = (key: string) => { - const hash = crypto.createHash('sha256'); - const hour = Math.floor((+new Date()) / 3600000); - hash.update(key + hour.toString()); - return hash.digest('hex'); - } + } CommitteeList.sort((a, b) => { - return getKey(a.name_short) > getKey(b.name_short) ? 1 : -1; + return getHourlyUpdatedSortKey(a.name_short) > getHourlyUpdatedSortKey(b.name_short) ? 1 : -1; }); setCommittees(CommitteeList); }); From 02752a2d0c03bebdfa02563594c96f51623d3b81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=20Gramn=C3=A6s=20Tjernshaugen?= Date: Tue, 23 Jul 2024 09:01:59 +0200 Subject: [PATCH 3/6] Commented out unused variable --- src/pages/applications/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/applications/index.tsx b/src/pages/applications/index.tsx index 67a490b4..10aadff6 100644 --- a/src/pages/applications/index.tsx +++ b/src/pages/applications/index.tsx @@ -15,7 +15,7 @@ const getHourlyUpdatedSortKey = (key: string) => { const Committees: React.FC = () => { const [committees, setCommittees] = useState([]); - const applicationFormUrl = 'https://forms.gle/BpQfh42FXfC85tNd6'; // updated for August 2023 + // const applicationFormUrl = 'https://forms.gle/BpQfh42FXfC85tNd6'; // updated for August 2023 useEffect(() => { console.log('Running'); From d1fa6d2b79ece221e0c8dd1bf15c27c7fd5dc3ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=20Gramn=C3=A6s=20Tjernshaugen?= Date: Tue, 23 Jul 2024 09:04:49 +0200 Subject: [PATCH 4/6] test 1 --- src/pages/applications/index.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pages/applications/index.tsx b/src/pages/applications/index.tsx index 10aadff6..445df528 100644 --- a/src/pages/applications/index.tsx +++ b/src/pages/applications/index.tsx @@ -13,6 +13,8 @@ const getHourlyUpdatedSortKey = (key: string) => { return hash.digest('hex'); } +// test + const Committees: React.FC = () => { const [committees, setCommittees] = useState([]); // const applicationFormUrl = 'https://forms.gle/BpQfh42FXfC85tNd6'; // updated for August 2023 From e1bf273f9e566a749893803f427ff4eb27979fba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=20Gramn=C3=A6s=20Tjernshaugen?= Date: Tue, 23 Jul 2024 09:04:56 +0200 Subject: [PATCH 5/6] Revert "Commented out unused variable" This reverts commit 02752a2d0c03bebdfa02563594c96f51623d3b81. --- src/pages/applications/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/applications/index.tsx b/src/pages/applications/index.tsx index 445df528..ec866f5a 100644 --- a/src/pages/applications/index.tsx +++ b/src/pages/applications/index.tsx @@ -17,7 +17,7 @@ const getHourlyUpdatedSortKey = (key: string) => { const Committees: React.FC = () => { const [committees, setCommittees] = useState([]); - // const applicationFormUrl = 'https://forms.gle/BpQfh42FXfC85tNd6'; // updated for August 2023 + const applicationFormUrl = 'https://forms.gle/BpQfh42FXfC85tNd6'; // updated for August 2023 useEffect(() => { console.log('Running'); From 26940976b2695435e347eadeff978237ca111c8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=20Gramn=C3=A6s=20Tjernshaugen?= Date: Tue, 23 Jul 2024 09:10:06 +0200 Subject: [PATCH 6/6] test 2 --- src/pages/applications/index.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/pages/applications/index.tsx b/src/pages/applications/index.tsx index ec866f5a..67a490b4 100644 --- a/src/pages/applications/index.tsx +++ b/src/pages/applications/index.tsx @@ -13,8 +13,6 @@ const getHourlyUpdatedSortKey = (key: string) => { return hash.digest('hex'); } -// test - const Committees: React.FC = () => { const [committees, setCommittees] = useState([]); const applicationFormUrl = 'https://forms.gle/BpQfh42FXfC85tNd6'; // updated for August 2023