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

Order channels by track/risk/branch #1581

Merged
merged 2 commits into from Feb 11, 2019
Merged

Conversation

Lukewh
Copy link
Contributor

@Lukewh Lukewh commented Feb 8, 2019

Fixes #1475

It also updates a few things.

  • Added a channels module for sorting arbitrary channel strings (will update the channel map to use this at some point).
  • Added "defaultTrack" to metrics page (currently hardcoded for node
  • Moved the hardcoded logic for node to the helpers module.
  • Made the tooltip appear above the site navigation

QA

  • Pull the branch
  • ./run
  • Visit http://0.0.0.0:8004/<snap_name>/metrics?active-devices=channel
  • Hover over the graph and move about - the order of channels should only change if there's no data for that channel on that day.

@codecov-io
Copy link

codecov-io commented Feb 8, 2019

Codecov Report

Merging #1581 into master will increase coverage by 0.26%.
The diff coverage is 100%.

Impacted Files Coverage Δ
static/js/libs/channels.js 100% <100%> (ø)
webapp/store/views.py 47.95% <100%> (+0.26%) ⬆️
webapp/helpers.py 71.42% <100%> (+4.76%) ⬆️
webapp/publisher/snaps/views.py 89.3% <100%> (+0.04%) ⬆️

@webteam-app
Copy link

@bartaz
Copy link
Contributor

bartaz commented Feb 11, 2019

Works well.

One thing I noticed, that is a bit related, but I'm not sure if we can fix this - is the ordering of sections on the graph itself.

Currently it's different from the order on the tooltip which is a bit confusing - especially that the 'bold' on tooltip that highlights current channel is not very visible.

Hovering over first top section (green) - first 10/stable channel is highlighted:
screenshot 2019-02-11 at 09 17 15

Hovering over second from top (red) - way below 11/stable is highlighted:
screenshot 2019-02-11 at 09 17 22

Should the order on the graph be the same as in the tooltip? Can we even control it?

risk: false,
branch: false
};
const channelArr = ["latest", undefined, "_base"];
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any reason for doing this in array instead of 3 variables (track, risk, branch)?

Also isn't the default branch empty? If we start using "_base" we may end up detecting a branch when there isn't any. But maybe as we approach adding support for branches in more elements of UI we should just start using "_base" as default. If that's the case it would be good to have "_base" (but "latest" as well) defined somewhere as consts and reused instead of being copied.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So I introduced the "_base" as a concept to have both a common format for all track/risks, regardless of whether they have branches and also to help with parsing in other parts in this file, for example reducing/ sorting ["stable/test", "stable"] was producing ["stable/test"] so stripping the "base" stable channel.

Setting "_base" hopefully makes it clear for anyone calling this code in the future (for another part of the site)

* ...
*
* @param {[string]} channels An array of "risk" / "track/risk" / "track/risk/branch"
* @param {{defaultTrack: string}} options
Copy link
Contributor

Choose a reason for hiding this comment

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

If there is no other option then defaultTrack maybe it just could be a defaultTrack param?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted to make it generic for future and be more descriptive in the code that calls it. I find:
sortChannels([], "randomString") harder to parse than sortChannels([], { defaultTrack: "randomString" }) when scanning code... I'm open to arguments against though!

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if "randomString" would be used in such way directly in code. I would guess in most cases default track would be passed as a variable, so it would be something more like sortChannels([...], defaultTrack) which would be more clear.

But, I agree that unnamed option params may be confusing (especially when passing booleans), so I'm not against for sure.

In this case I just wondered if there is any reason to pass it via object. And because it seems like it's used like that consistently in at least 2 functions I'm fine with leaving it as it is.
Code is clear to read, and works, so not worth spending time changing it for little benefit.

@Lukewh
Copy link
Contributor Author

Lukewh commented Feb 11, 2019

@bartaz thinking about your ordering comment some more:

We could alter the order to match but the current implementation ensures that any new channel/ version/ os appears from the bottom to take a share of those above. Changing the order in the specific case you've shown would work (as they're all established channels) but if a new "latest/stable/test" was released, where should it appear?

I don't think it's worth the extra effort/ code/ calculations, but I could easily be wrong :D

@bartaz
Copy link
Contributor

bartaz commented Feb 11, 2019

@Lukewh Sure, never mind then. This issue is about order in the tooltip anyway.

Copy link
Contributor

@bartaz bartaz left a comment

Choose a reason for hiding this comment

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

Thanks for updates. LGTM now.

@Lukewh Lukewh merged commit fd542ec into canonical:master Feb 11, 2019
@Lukewh Lukewh deleted the metrics-updates branch February 11, 2019 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants