# for each user; earlier ones are irrelevant and don't count. But it
# doesn't deduplicate across reactions. Meh.)
sub create_reaction_log {
- my ($dbh, $invitation_ts, $slack_userid_to_real_name, $slack_userid_to_slack_name) = @_;
+ my ($dbh, $channel, $invitation_ts, $interval, $slack_userid_to_real_name, $slack_userid_to_slack_name) = @_;
- my $q = $dbh->prepare('select userid,event_type,reaction,to_char(event_ts,\'YYYY-mm-dd HH24:MI\') as event_ts from ( select distinct on (channel,ts,userid,reaction) userid,event_type,reaction,timestamptz \'1970-01-01 utc\' + event_ts::float * interval \'1 second\' as event_ts from reaction_log where channel=? and ts=? and reaction in (\'heart\',\'open_mouth\',\'blue_heart\',\'orange_heart\') order by channel,ts,userid,reaction,event_ts desc ) t1 where event_ts > current_timestamp - interval \'8 hours\' order by event_ts desc limit 50');
- $q->execute($config::invitation_channel, $invitation_ts);
+ my $q = $dbh->prepare('select userid,event_type,reaction,to_char(event_ts,\'YYYY-mm-dd HH24:MI\') as event_ts from ( select distinct on (channel,ts,userid,reaction) userid,event_type,reaction,timestamptz \'1970-01-01 utc\' + event_ts::float * interval \'1 second\' as event_ts from reaction_log where channel=? and ts=? and reaction in (\'heart\',\'open_mouth\',\'blue_heart\',\'orange_heart\') order by channel,ts,userid,reaction,event_ts desc ) t1 where event_ts > current_timestamp - ?::interval order by event_ts desc limit 50');
+ $q->execute($channel, $invitation_ts, $interval);
my @recent_changes = ();
while (my $ref = $q->fetchrow_hashref) {
my $msg = $ref->{'event_ts'};
}
}
- my @recent_changes = create_reaction_log($dbh, $invitation_ts, \%slack_userid_to_real_name, \%slack_userid_to_slack_name);
+ my @recent_changes = create_reaction_log($dbh, $config::invitation_channel, $invitation_ts, '8 hours', \%slack_userid_to_real_name, \%slack_userid_to_slack_name);
push @yellow_updates, {
updateCells => {
rows => \@recent_changes,
fields => 'userEnteredValue.stringValue',
range => {
sheetId => $config::log_tab_id,
- startRowIndex => 4,
- endRowIndex => 4 + scalar @recent_changes,
+ startRowIndex => 3,
+ endRowIndex => 3 + scalar @recent_changes,
startColumnIndex => 0,
endColumnIndex => 1
}
}
}
};
+
+ my @hks_recent_changes = create_reaction_log($dbh, 'C06C34L2R6G', '1712686401.430939', '30 days', \%slack_userid_to_real_name, \%slack_userid_to_slack_name);
+ push @yellow_updates, {
+ updateCells => {
+ rows => \@hks_recent_changes,
+ fields => 'userEnteredValue.stringValue',
+ range => {
+ sheetId => $config::hks_tab_id,
+ startRowIndex => 1,
+ endRowIndex => 1 + scalar @hks_recent_changes,
+ startColumnIndex => 3,
+ endColumnIndex => 4
+ }
+ }
+ };
# END LOCAL CHANGE FOR HKS 2024
# Push the final set of updates (including the log).