-
-
Notifications
You must be signed in to change notification settings - Fork 736
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
feat: rework application overview db query #8518
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.OpenSSF Scorecard
Scanned Manifest Files |
@@ -313,29 +313,40 @@ export default class ClientApplicationsStore | |||
), | |||
]) | |||
.from('client_metrics_env as cme') | |||
.where('cme.app_name', appName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra where clause to reduce query scope
qb.select([ | ||
'ci.app_name', | ||
'ci.environment', | ||
this.db.raw( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now we count in database level, instead of joining and returning all.
this.db.raw( | ||
'COUNT(DISTINCT ci.instance_id) as unique_instance_count', | ||
), | ||
this.db.raw( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also count these in database.
this.db.raw( | ||
'ARRAY_AGG(DISTINCT ci.sdk_version) as sdk_versions', | ||
), | ||
this.db.raw('MAX(ci.last_seen) as latest_last_seen'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also last seen, max will be taken, instead of doing it in memory.
@@ -397,25 +405,14 @@ export default class ClientApplicationsStore | |||
}; | |||
acc.push(env); | |||
} else { | |||
if (instance_id) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got rid of all of this logic done in memory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, can we validate this in sandbox before rolling out? Maybe checking prometheus metrics before and after the change or just checking in Grafana
.orderBy('m.environment', 'asc'); | ||
console.log(query.toQuery()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console.log(query.toQuery()); |
Previously we were returning all instance names from database, but now we count them in database.