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

Add project fact type based on SQL query #103

Open
dave-shawley opened this issue Aug 8, 2024 · 0 comments
Open

Add project fact type based on SQL query #103

dave-shawley opened this issue Aug 8, 2024 · 0 comments

Comments

@dave-shawley
Copy link
Contributor

We were discussing how to add a project fact that tracks the number of recent restarts as an indicator of quality recently. It would be trivial to implement if we had a way to periodically run

SELECT COUNT(o.id)
  FROM v1.operations_log AS o
 WHERE o.project_id = %(project_id)s
   AND o.change_type = 'Restarted'
   AND o.recorded_at > CURRENT_TIMESTAMP - INTERVAL '14d'

and assign the value to the Recent Restart Count fact.

This shouldn't be too difficult to implement... without thinking too hard about it:

  1. add a new fact type named query -- current values are enum, range, & free-form
  2. create v1.project_fact_types_query to hold the query and frequency
  3. add a periodic task somewhere that runs queries for projects with a "query" fact type -- pgcron?
  4. add necessary CRUD to the Admin UI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant