Skip to content

feat(coderd/database): use template_usage_stats in GetTemplateAppInsights query #12669

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

Merged
merged 5 commits into from
Mar 25, 2024

Conversation

mafredri
Copy link
Member

@mafredri mafredri commented Mar 19, 2024

This PR updates the GetTemplateAppInsights query to use rolled up template_usage_stats instead of raw agent and app stats.

@mafredri mafredri force-pushed the mafredri/rewrite-gettemplateinsightsbytemplate branch from 2eae8f8 to 4ae3521 Compare March 20, 2024 10:25
@mafredri mafredri force-pushed the mafredri/rewrite-gettemplateappinsights branch from d384842 to c10b34b Compare March 20, 2024 10:25
wa.agent_id = was.agent_id
AND wa.slug = was.slug_or_port
WITH
app_insights AS (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: you may want to drop a comment here, many joins around

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, in my opinion it's a self-contained sequence of joins and there is a comment inline, is there something more you would like explained in the comment? This is a common pattern when we need to lookup agent (or in our case app) -> template association.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, exactly this :)

prevent going through joins and "fast-forward" reading query code by human

@mafredri mafredri force-pushed the mafredri/rewrite-gettemplateinsightsbytemplate branch from 4ae3521 to 2ac8855 Compare March 20, 2024 12:37
@mafredri mafredri force-pushed the mafredri/rewrite-gettemplateappinsights branch from c10b34b to c45caeb Compare March 20, 2024 12:37
@mafredri mafredri force-pushed the mafredri/rewrite-gettemplateinsightsbytemplate branch 2 times, most recently from eb52bb7 to 37f6f3a Compare March 20, 2024 14:53
@mafredri mafredri force-pushed the mafredri/rewrite-gettemplateappinsights branch from c45caeb to d481905 Compare March 20, 2024 14:53
@mafredri mafredri force-pushed the mafredri/rewrite-gettemplateinsightsbytemplate branch from 37f6f3a to 70ba902 Compare March 20, 2024 16:02
@mafredri mafredri force-pushed the mafredri/rewrite-gettemplateappinsights branch from 3d14fe4 to 04b5c07 Compare March 20, 2024 16:02
@mafredri mafredri force-pushed the mafredri/rewrite-gettemplateinsightsbytemplate branch from 70ba902 to 4d27721 Compare March 20, 2024 19:04
@mafredri mafredri force-pushed the mafredri/rewrite-gettemplateappinsights branch from 11871be to 8a9eb15 Compare March 20, 2024 19:04
@mafredri mafredri force-pushed the mafredri/rewrite-gettemplateinsightsbytemplate branch from 4d27721 to 53a54b0 Compare March 20, 2024 19:19
@mafredri mafredri force-pushed the mafredri/rewrite-gettemplateappinsights branch from 8a9eb15 to 772aa60 Compare March 20, 2024 19:19
@mafredri mafredri force-pushed the mafredri/rewrite-gettemplateappinsights branch from 772aa60 to 460c244 Compare March 20, 2024 19:55
@mafredri mafredri force-pushed the mafredri/rewrite-gettemplateinsightsbytemplate branch from a234c5d to 02b3828 Compare March 21, 2024 12:46
@mafredri mafredri changed the base branch from mafredri/rewrite-gettemplateinsightsbytemplate to mafredri/rewrite-gettemplateinsightsbyinterval March 21, 2024 15:06
@mafredri mafredri force-pushed the mafredri/rewrite-gettemplateappinsights branch from 460c244 to 87f22f1 Compare March 21, 2024 15:06
@mafredri mafredri force-pushed the mafredri/rewrite-gettemplateinsightsbyinterval branch from 958785d to 05780db Compare March 21, 2024 17:54
@mafredri mafredri force-pushed the mafredri/rewrite-gettemplateappinsights branch 2 times, most recently from 2cf5f94 to 02d0f24 Compare March 21, 2024 18:06
@mafredri mafredri force-pushed the mafredri/rewrite-gettemplateinsightsbyinterval branch from 05780db to 3c67005 Compare March 22, 2024 15:40
@mafredri mafredri force-pushed the mafredri/rewrite-gettemplateappinsights branch from 02d0f24 to dfa069b Compare March 22, 2024 15:40
@mafredri mafredri force-pushed the mafredri/rewrite-gettemplateinsightsbyinterval branch from 3c67005 to bf27a9f Compare March 22, 2024 17:11
@mafredri mafredri force-pushed the mafredri/rewrite-gettemplateappinsights branch from dfa069b to 6fca988 Compare March 22, 2024 17:11
@mafredri mafredri force-pushed the mafredri/rewrite-gettemplateinsightsbyinterval branch from bf27a9f to 8b32a8c Compare March 22, 2024 17:15
@mafredri mafredri force-pushed the mafredri/rewrite-gettemplateappinsights branch from 6fca988 to 0cd1f85 Compare March 22, 2024 17:15
@mafredri mafredri changed the title feat(coderd/database): rewrite GetTemplateAppInsights to use template_usage_stats feat(coderd/database): use template_usage_stats in GetTemplateAppInsights query Mar 25, 2024
@mafredri mafredri force-pushed the mafredri/rewrite-gettemplateinsightsbyinterval branch from 8b32a8c to bfe4b8a Compare March 25, 2024 11:18
@mafredri mafredri force-pushed the mafredri/rewrite-gettemplateappinsights branch from 0cd1f85 to 549a837 Compare March 25, 2024 11:18
@mafredri mafredri marked this pull request as ready for review March 25, 2024 12:57
Copy link
Member Author

mafredri commented Mar 25, 2024

Merge activity

  • Mar 25, 9:33 AM EDT: @mafredri started a stack merge that includes this pull request via Graphite.
  • Mar 25, 9:47 AM EDT: Graphite rebased this pull request as part of a merge.
  • Mar 25, 9:58 AM EDT: @mafredri merged this pull request with Graphite.

@mafredri mafredri force-pushed the mafredri/rewrite-gettemplateinsightsbyinterval branch from bfe4b8a to cb74f29 Compare March 25, 2024 13:33
Base automatically changed from mafredri/rewrite-gettemplateinsightsbyinterval to main March 25, 2024 13:45
@mafredri mafredri force-pushed the mafredri/rewrite-gettemplateappinsights branch from 549a837 to 6813b73 Compare March 25, 2024 13:46
@mafredri mafredri merged commit 5738a03 into main Mar 25, 2024
@mafredri mafredri deleted the mafredri/rewrite-gettemplateappinsights branch March 25, 2024 13:58
@github-actions github-actions bot locked and limited conversation to collaborators Mar 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants