Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System to poll Airtable for changes #5

Closed
alexquick opened this issue Mar 28, 2020 · 2 comments · Fixed by #10
Closed

System to poll Airtable for changes #5

alexquick opened this issue Mar 28, 2020 · 2 comments · Fixed by #10
Assignees
Labels
enhancement New feature or request

Comments

@alexquick
Copy link
Contributor

alexquick commented Mar 28, 2020

When an intake volunteer marks a Request as "Send to Slack" / "Ready For Aid" it needs to get sent to Slack

Notes

Airflow doesn't have any simple push notifications, but we can poll. This will likely involve creating 2 hidden fields: meta and an auto last_modified column. The last_modified will let the system narrow down the number of rows to examine, and meta will be a hidden json-encoded text column of the last values observed. This way we can tell exactly which fields changed and to what. This is inspired as a generalized version of: https://github.com/bedstuystrong/firebase-functions/blob/master/functions/airtable.js#L78

The internal API could look something like:

const changes = new AirtableChanges(base);
changes.onChange((record, beforeValues, afterValues)=>{
   . . . callback . . .
});
changes.start();

Polling changes could look like:

  1. Get all rows changed since last last_modified (maybe include a jitter or overlap)
  2. Compare each row's non-meta fields vs cached values in meta (json). Filter out rows that have not had any field actually change vs meta
  3. Dispatch change events for the affected fields (could use eventemitter or skip entirely and hard-code the send-to-slack logic for the time being)
  4. Update meta with the current values and save. This means that the row will end up at 1. again unfortunately, but will get filtered out at 2.

Related: #1

@alexquick alexquick self-assigned this Mar 28, 2020
@alexquick alexquick added the enhancement New feature or request label Mar 28, 2020
@mjmaurer
Copy link
Contributor

could we add a field last-processed field that is set a tiny bit in the future? then we could have an airtable formula like last_modified > last_processed

@mjmaurer
Copy link
Contributor

mjmaurer commented Apr 1, 2020

I think notifying slack should be out of scope for this bug. Polling out be huge

@alexquick alexquick changed the title Poll for Request state changes and notify slack System to poll Airtable for changes Apr 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants