endlessm / azafea

Service to track device activations and usage metrics
Mozilla Public License 2.0
10 stars 2 forks source link

metrics: Make queries simpler #62

Closed bochecha closed 4 years ago

bochecha commented 4 years ago

Most queries we want to run on the database are based on the image "product" and "personality".

At the moment that implies joining the metrics_request_v2 and image_version tables, filtering by the result of a function you must write in the query, then joining that with the tables you want to actually query.

This branch makes it significantly easier by adding a machine/image mapping, and a couple of functions to get the image product and personality for a given request.

This will also be the base of the row-level security for the Endless deployment: a given user will only have access to the requests corresponding to machines running a given product/personality. (#46)