setup sql to pull prior week messages

This commit is contained in:
Paul Trowbridge 2023-04-17 08:23:15 -04:00
parent 90cc2ba2b6
commit c2a313dc64
2 changed files with 9 additions and 1 deletions

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash
#$PG -t -A -c "SELECT '## 2023-03-31' UNION ALL SELECT ' - ' ||(message->>'text') from rlarp.thirtysec where mdate >= '2023-03-31'" | fold -s -w 80 | sed -E 's/^([^ -])/ \1/;s/^(-{1,2} )/ \1/;s/^/ /' #$PG -t -A -c "SELECT '## 2023-03-31' UNION ALL SELECT ' - ' ||(message->>'text') from rlarp.thirtysec where mdate >= '2023-03-31'" | fold -s -w 80 | sed -E 's/^([^ -])/ \1/;s/^(-{1,2} )/ \1/;s/^/ /'
$PG -t -A -c "SELECT '## 2023-04-06' UNION ALL SELECT '- ' ||mdate||' [[]] '||(message->>'text') from rlarp.thirtysec where mdate >= '2023-04-06'" >> /mnt/c/Users/PTrowbridge/hc_notes/30sec.md $PG -t -A -f last_week.pg.sql >> /mnt/c/Users/PTrowbridge/hc_notes/30sec.md

8
last_week.pg.sql Normal file
View File

@ -0,0 +1,8 @@
SELECT
'## '||(SELECT (SELECT MAX(mdate) FROM rlarp.thirtysec)::date - ((EXTRACT(DOW FROM (SELECT MAX(mdate) FROM rlarp.thirtysec)::date) - 5 + 7) % 7) * INTERVAL '1 day' AS last_friday)
UNION ALL
SELECT '- ' ||mdate||' [[]] '||(message->>'text')
FROM
rlarp.thirtysec
WHERE
mdate >= (SELECT (SELECT MAX(mdate) FROM rlarp.thirtysec)::date - ((EXTRACT(DOW FROM (SELECT MAX(mdate) FROM rlarp.thirtysec)::date) - 5 + 7) % 7) * INTERVAL '1 day' AS last_friday)