From 97a72700038f0e1dd51848edd4c7034677507974 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Wed, 10 Apr 2024 21:39:01 +0200 Subject: [PATCH] Local changes for HKS 2024. --- bin/sync.pl | 43 +++++++++++++++++++++++++++++++++++++++++++ include/config.pm | 3 +++ 2 files changed, 46 insertions(+) diff --git a/bin/sync.pl b/bin/sync.pl index 23c5627..bfa694a 100644 --- a/bin/sync.pl +++ b/bin/sync.pl @@ -709,6 +709,33 @@ sub run { } } } + # LOCAL CHANGE FOR HKS 2024 + # Piece together HKS users. + $q = $dbh->prepare('SELECT userid FROM current_reactions WHERE channel=? and ts=? and reaction=?;'); + $q->execute('C06C34L2R6G', '1712686401.430939', 'heart'); # #hks-2024-05-04 + my @hks_runners = (); + while (my $ref = $q->fetchrow_hashref) { + my $userid = $ref->{'userid'}; + if (!exists($slack_userid_to_real_name{$userid}) && !exists($slack_userid_to_slack_name{$userid})) { + my $slack_name = get_slack_name($ua, $userid); + my $write_row = $cur_row++; + push @slack_mapping_updates, { + range => "Slack-mapping!A$write_row:A$write_row", + values => [ [ $userid ]] + }; + push @slack_mapping_updates, { + range => "Slack-mapping!B$write_row:B$write_row", + values => [ [ $slack_name ]] + }; + $slack_userid_to_slack_name{$userid} = $slack_name; + } + my $name = $slack_userid_to_real_name{$userid} // $slack_userid_to_slack_name{$userid} // $userid; + push @hks_runners, { values => [{ userEnteredValue => { stringValue => $name } }] }; + } + push @hks_runners, { values => [{ userEnteredValue => { stringValue => '' } }] }; + push @hks_runners, { values => [{ userEnteredValue => { stringValue => '' } }] }; + push @hks_runners, { values => [{ userEnteredValue => { stringValue => '' } }] }; + # END LOCAL CHANGE FOR HKS 2024 if (scalar @slack_mapping_updates > 0) { my $update = { valueInputOption => 'USER_ENTERED', @@ -838,6 +865,22 @@ sub run { } }; + # LOCAL CHANGE FOR HKS 2024 + push @yellow_updates, { + updateCells => { + rows => \@hks_runners, + fields => 'userEnteredValue.stringValue', + range => { + sheetId => $config::hks_tab_id, + startRowIndex => 1, + endRowIndex => 1 + scalar @hks_runners, + startColumnIndex => 0, + endColumnIndex => 1 + } + } + }; + # END LOCAL CHANGE FOR HKS 2024 + # Push the final set of updates (including the log). skv_log("Ferdig."); push @yellow_updates, serialize_skv_log_to_sheet(); diff --git a/include/config.pm b/include/config.pm index 2d95d41..675aca1 100644 --- a/include/config.pm +++ b/include/config.pm @@ -18,6 +18,9 @@ our $jwt_key = { }; our $sheet_id = '1-alcvuB3184rw3pWLcvYjc2d6CnVGpMuvZYMYxn7Cgw'; our $log_tab_id = '253633356'; +# LOCAL CHANGE FOR HKS 2024 +our $hks_tab_id = '240735494'; +# END LOCAL CHANGE FOR HKS 2024 our $gsheets_api_key; our $dbname = 'skvidarlang'; our $dbuser = 'skvidarlang'; -- 2.39.2