Created
September 10, 2024 20:30
-
-
Save judell/9b5d60bee6b780aafd145556d552a926 to your computer and use it in GitHub Desktop.
hn_mentions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query "mentions" { | |
sql = <<EOQ | |
with names as ( | |
select | |
unnest( $1::text[] ) as name | |
), | |
counts as ( | |
select | |
name, | |
( | |
select | |
count(*) | |
from | |
hn | |
where | |
title ~* name | |
and (extract(epoch from now() - time::timestamptz) / 60)::int between symmetric $2 and $3 | |
) as mentions | |
from | |
names | |
) | |
select | |
replace(name, '\', '') as name, | |
mentions | |
from | |
counts | |
where | |
mentions > 0 | |
order by | |
mentions desc | |
EOQ | |
param "names" {} | |
param "min_minutes_ago" {} | |
param "max_minutes_ago" {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment