Skip to content

Instantly share code, notes, and snippets.

@timwis
Last active November 4, 2016 18:21
Show Gist options
  • Save timwis/caee9cb1284082059183b14fd6cc8371 to your computer and use it in GitHub Desktop.
Save timwis/caee9cb1284082059183b14fd6cc8371 to your computer and use it in GitHub Desktop.
subscribeme

subscribeme

Monitors an API for new data and sends digest emails to subscribers.

Schema

queries

id query
3 status=active

subscribers

id email query frequency
1 x@x.x 3 daily

query-matches

query-id record-id
3 124098

Although this wouldn't work if subscribers have different frequencies... Maybe MVP requires all queries be daily? Perhaps we can flush the query-matches cache each run and only fill it with the record-ids of the most recent query.

Alternate schema

records-observed

id date-observed
22 2016-11--04T12:32Z

queries

id query last-ran
3 status=active 2016-11-03T12:23Z

Query

SELECT id
FROM records-observed
WHERE date-observed < ${query.last-ran}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment