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

Integrate context filtering logic into the Aim GetRunMetrics and SearchAlignedMetrics endpoints. #787

Merged
merged 31 commits into from
Feb 1, 2024
Merged

Integrate context filtering logic into the Aim GetRunMetrics and SearchAlignedMetrics endpoints. #787

merged 31 commits into from
Feb 1, 2024

Conversation

dsuhinin
Copy link
Collaborator

@dsuhinin dsuhinin commented Jan 4, 2024

Whats inside the box:

  • adopted GetRunMetrics and SearchAlignedMetrics endpoints to work with context filtering.
  • adjusted integration tests to test context filtering.

@dsuhinin dsuhinin changed the title Adapt the Aim GetRunMetrics and SearchAlignedMetrics endpoints to filter the query down based on the context. Adapt the Aim GetRunMetrics and SearchAlignedMetrics endpoints to filter the query based on the context. Jan 4, 2024
@dsuhinin dsuhinin changed the title Adapt the Aim GetRunMetrics and SearchAlignedMetrics endpoints to filter the query based on the context. Integrate context filtering logic into the Aim GetRunMetrics and SearchAlignedMetrics endpoints. Jan 4, 2024
Comment on lines 204 to 227
// fetch run metrics based on provided criteria.
var data []database.Metric
if err := database.DB.Where(
"run_uuid = ?", p.ID,
).InnerJoins(
"Context",
func() *gorm.DB {
subQuery := database.DB
for _, context := range contexts {
sql, args := repositories.BuildJsonCondition(database.DB.Dialector.Name(), "json", context)
subQuery = subQuery.Or(sql, args...)
}
return subQuery
}(),
).Where(
"key IN ?", metricKeys,
).Order(
"iter",
).Find(
&data,
).Error; err != nil {
return fmt.Errorf("unable to find run metrics: %w", err)
}

Copy link
Collaborator Author

@dsuhinin dsuhinin Jan 4, 2024

Choose a reason for hiding this comment

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

I decided to split it, because in that case it looks more clear and it is much easy to construct and support queries.

@dsuhinin dsuhinin marked this pull request as ready for review January 4, 2024 18:48
suprjinx
suprjinx previously approved these changes Jan 23, 2024
@dsuhinin dsuhinin merged commit dd785a7 into G-Research:main Feb 1, 2024
17 checks passed
@dsuhinin dsuhinin deleted the dsuhinin/adopt-endpoints-to-filter-by-context branch February 1, 2024 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants