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

[PG] Return latest chart version #1433

Merged
merged 2 commits into from
Jan 13, 2020
Merged

[PG] Return latest chart version #1433

merged 2 commits into from
Jan 13, 2020

Conversation

andresmgot
Copy link
Contributor

Description of the change

It's not explicit but the chartVersion returned by getChartsWithFilters should be the latest version in order to return it to the client. That's is later used by the dashboard to determine if there are updates available. Since the charts are ordered, it should return the first one of the array.

c.ChartVersions = []models.ChartVersion{cv}
if _, found := containsVersionAndAppVersion(c.ChartVersions, version, appVersion); found {
// Return only the latest ChartVersion
c.ChartVersions = []models.ChartVersion{c.ChartVersions[0]}
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like the wrong place to change the data? The function is getChartsWithFilters(), which should return all charts which match the filter. If I were to see this function and re-use it for some other purpose, it'd be very surprising that it actually modifies the result (truncating the chart versions for the chart).

So my question is: why does this function need to truncate the chart versions for the returned charts at all?

The specific call-site in this case (the handler) can choose to overwrite c.ChartVersions = []models.ChartVersion[c.ChartVersions[0] if the handler should return just the one chart version, but I don't think it should be part of this util function?

Copy link
Contributor Author

@andresmgot andresmgot Jan 13, 2020

Choose a reason for hiding this comment

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

I actually agree, my bad reason to do this is because in the mongodb-utils it's done this way. There, I believe the reason we are doing this is because of the performance. It's encoded in the MongoDB query so it's only returning one version which I believe is faster.

In any case, it's not the case here so I am okay changing the behavior.

[EDIT] Actually there is already code in the dashboard to get the latest version so this seems to be unnecessary.

Copy link
Contributor

@absoludity absoludity left a comment

Choose a reason for hiding this comment

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

Great, thanks for the background.

@absoludity absoludity merged commit d9ddf6a into master Jan 13, 2020
@absoludity absoludity deleted the latestChartVersion branch January 13, 2020 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants