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
UI needs help getting stats for pages #795
Comments
I am thinking this would get solved with a view or something... but this is not my specialty. If there is a way to get this with postgrest that would be great. Let me know. |
How about using a Examples:
Then, fetching the last 7 days would mean taking the current timestamp and truncating it to a 'day' grain, and then subtracting 7 days to identify the beginning of the range. |
Probably stating the obvious, but there is an ambiguity in timestamps between 'day' and 'month' grains, where the first day of the month is the same timestamp as the month grain itself. But there is also a specific column calling out the grain to delineate these cases. The grain timestamps are constructed here by the typescript derivation: flow/ops-catalog/catalog-stats.ts Lines 34 to 59 in 4b1aa5e
So perhaps a chained a set of filters with one being for the list of catalog names, another for the computed timestamp predicate, and an |
UI PR that will add stats: estuary/ui#422 Below are example queries that the UI will be using for stats. One thing that I didn't think about until now is that the app uses Date Fns and it extends the build in I also am not sure what we feel is best in terms of using a Examples:Testing at December 14, 2022 10:16pm today yesterday this week last week this month last month |
After a talk with Will I am switching this query to use equals where possible and follow the pattern where the stats are stored at the start of a grain. Examples: today ts: eq.2022-12-19 00:00:00+00 this week last week this month last month |
I think we're good with the UI using |
I'm not sure where the timezone discussion netted out, but one note about local vs UTC: Edit to add: this probably is irrelevant for current-day data, as "past 24 hours" and "current UTC day" are different things, but could be confusing when looking at historical data? |
TL;DR
UI needs to query an array of
catalog_name
s and narrow down thets
s so we receive a single item back percatalog_name
.Background
The initial plan for fetching stats with the UI was to have each row query to get its own stats via the
catalog_name
and sort by thets
and limit to a single response. However, this would mean the UI is making a lot of calls for stats.Instead of this - the UI is wanting to query once to fetch all the stats needed for the catalogs in a single view. This means we are using the in operator. When the UI uses this approach we run into issues with limiting this to only fetch the
ts
s we want. For instance, we cannot query "All catalogs latest daily stat".Queries
To give an example of what kind of queries we want to run. We would like to lookup up via a single
catalog_name
or via an array ofcatalog_name
s and fetch one of these time frames:Last 6 Months
Last Month
This Month
Last Week
This Week
Yesterday
Today
Links
I initially thought that I would want to query with group/distinct to get what we need... but it looks like Postgrest does not support this:
PostgREST/postgrest#915
The text was updated successfully, but these errors were encountered: