SWATCH-2951: Allow to filter by metrics in the Instances Table API #3834
+288
−98
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Jira issue: SWATCH-2951
Description
The payg and non payg views are aggregating all the metrics into a single row in jsonb format. And the problem is that we can't easily filter and order using these metrics because it is in jsonb.
So, instead of dealing with the metrics jsonb column, we're now adding a left join to the measurements table (for payg is "instance_monthly_totals" and for non payg is "instance_measurements") - note about performance: that these tables are indexed.
Therefore, we're now using this relationship to filter and also to order the result set. These relationships will not be used when mapping the query result set to the DTO.
Changes
Testing
Added a JUnit test to mimic the scenario.