-
Notifications
You must be signed in to change notification settings - Fork 515
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
aggregate by all if aggregate is empty #2376
aggregate by all if aggregate is empty #2376
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
pkg/cloudcost/queryservice_helper.go
Outdated
@@ -38,6 +38,11 @@ func ParseCloudCostRequest(qp httputil.QueryParams) (*QueryRequest, error) { | |||
aggregateBy = append(aggregateBy, prop) | |||
} | |||
|
|||
// if we're aggregating by nothing (aka `item` on the frontend) then aggregate by all | |||
if aggregateBy != nil && len(aggregateBy) < 1 { |
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.
GetList()
returns nil
if the string is empty https://github.com/opencost/opencost/blob/develop/pkg/util/mapper/mapper.go#L440
if aggregateBy != nil && len(aggregateBy) < 1 { | |
if len(aggregateBy) == 0 { |
should work
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 fails the tests
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.
aggregateBy != nil
was what fixed it but probably caused the issue to not get solved
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.
I think we should change the test; behavior isn't working as its supposed to so we're fixing a bug. I'd say that the unit test is wrong.
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.
So, we probably need to do the "all" thing and treat both nil
and {}
as "do not aggregate." Which might mean that we need a test change? Does that sound right?
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.
ok let me nuke the test for now just to make sure this solves the problem
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.
I'm not sure I'm clear on what "do not aggregate" means. Would that just return one line item or something?
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.
By "do not aggregate" I believe niko means "return maximum-resolution lines", the same as a "full group by"
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.
So what's all
then? I thought that would be full group by
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.
I believe "all" is supposed to produce a single, fully-totalled, line
Signed-off-by: nickcurie <ncurie@kubecost.com>
53214dc
to
82d7065
Compare
Signed-off-by: nickcurie <ncurie@kubecost.com>
7531495
to
6c19d08
Compare
* aggregate by all if aggregate is empty Signed-off-by: nickcurie <ncurie@kubecost.com> * resolved broken test Signed-off-by: nickcurie <ncurie@kubecost.com> --------- Signed-off-by: nickcurie <ncurie@kubecost.com>
* aggregate by all if aggregate is empty Signed-off-by: nickcurie <ncurie@kubecost.com> * resolved broken test Signed-off-by: nickcurie <ncurie@kubecost.com> --------- Signed-off-by: nickcurie <ncurie@kubecost.com> Signed-off-by: Michael Dresser <michaelmdresser@gmail.com>
* aggregate by all if aggregate is empty * resolved broken test --------- Signed-off-by: nickcurie <ncurie@kubecost.com> Signed-off-by: Michael Dresser <michaelmdresser@gmail.com> Co-authored-by: Nick Curie <32180999+nickcurie@users.noreply.github.com>
What does this PR change?
Does this PR relate to any other PRs?
How will this PR impact users?
Does this PR address any GitHub or Zendesk issues?
How was this PR tested?
Does this PR require changes to documentation?
Have you labeled this PR and its corresponding Issue as "next release" if it should be part of the next OpenCost release? If not, why not?