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

Fix Containers dashboard heatmaps #14857

Merged
merged 1 commit into from
May 31, 2017
Merged

Conversation

zakiva
Copy link
Contributor

@zakiva zakiva commented Apr 24, 2017

BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1439671
UI side and tests in ManageIQ/manageiq-ui-classic#608

@simon3z @zeari @moolitayer Please review

@miq-bot add_label providers/containers, bug, fine/yes

Copy link

@zeari zeari left a comment

Choose a reason for hiding this comment

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

@zakiva
Copy link
Contributor Author

zakiva commented May 10, 2017

@kbrock Can you please take a look?

metrics = Metric.where(:resource_type => resource_type)
metrics = metrics.where(:resource_id => resource_ids) if resource_ids
metrics = metrics.order(:resource_id, :timestamp => :desc)
metrics = metrics.where('timestamp > ?', 10.minutes.ago.utc)
Copy link
Contributor

Choose a reason for hiding this comment

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

@zakiva why 10.minutes.ago.utc? Is it dependent on any other value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@simon3z That is the time interval we agreed on for "realtime" metrics that we display in the dashboard. Same value is used here:
https://github.com/ManageIQ/manageiq-ui-classic/blob/master/app/services/container_dashboard_service.rb#L395
(we can change it easily of course)

Copy link
Contributor

Choose a reason for hiding this comment

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

@zakiva then it seems to me that this should be a single constant in the code (or a setting?) instead that having 10.minutes.ago.utc hard-coded, so in case we need to tweak it we change the value in a single place.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, I will fix that.

@@ -198,4 +198,12 @@ def self.get_time_interval(obj, timestamp)

start_time..timestamp
end

def self.latest_metrics(resource_type, resource_ids = nil)
metrics = Metric.where(:resource_type => resource_type)
Copy link
Contributor

Choose a reason for hiding this comment

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

@kbrock any way to make the syntax of the whole query (these 5 lines) nicer? Any syntactic sugar?

Copy link
Member

Choose a reason for hiding this comment

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

Yea, not perfect, but it will work.

@simon3z
Copy link
Contributor

simon3z commented May 18, 2017

@kbrock can you review this?

@simon3z
Copy link
Contributor

simon3z commented May 18, 2017

@Fryguy can you take a look? Thanks.

@simon3z
Copy link
Contributor

simon3z commented May 22, 2017

@miq-bot assign kbrock

@miq-bot miq-bot assigned kbrock and unassigned simon3z May 22, 2017
@@ -198,4 +198,12 @@ def self.get_time_interval(obj, timestamp)

start_time..timestamp
end

def self.latest_metrics(resource_type, timestamp, resource_ids = nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

@zakiva is it more clear to use since_timestamp instead of just timestamp?

@miq-bot
Copy link
Member

miq-bot commented May 22, 2017

Checked commit zakiva@12ad5b5 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
2 files checked, 0 offenses detected
Everything looks fine. 🏆

@simon3z
Copy link
Contributor

simon3z commented May 22, 2017

@kbrock can you review/approve/merge?
Thanks.

metrics = metrics.where(:resource_id => resource_ids) if resource_ids
metrics = metrics.order(:resource_id, :timestamp => :desc)
metrics = metrics.where('timestamp > ?', since_timestamp)
metrics.select('DISTINCT ON (metrics.resource_id) metrics.*')
Copy link
Member

Choose a reason for hiding this comment

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

think metrics.distinct(:resource_id) is an alternative

@kbrock kbrock merged commit 5d0ec5b into ManageIQ:master May 31, 2017
@kbrock kbrock added this to the Sprint 62 Ending Jun 5, 2017 milestone May 31, 2017
simaishi pushed a commit that referenced this pull request Jun 9, 2017
@simaishi
Copy link
Contributor

simaishi commented Jun 9, 2017

Fine backport details:

$ git log -1
commit 5fc3450f3cd5ac77b24c1103fb9cabbaee91c3e3
Author: Keenan Brock <[email protected]>
Date:   Wed May 31 16:47:20 2017 -0400

    Merge pull request #14857 from zakiva/fix_realtime_heatmaps
    
    Fix Containers dashboard heatmaps
    (cherry picked from commit 5d0ec5b2e81f0e7666d08b9cae8c9df39cb60975)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1460357

@chrisarcand
Copy link
Member

Why the added 'helper' here? This module is already a bucket of random things. Seems like this could have been a few scopes on the Metric model with the helper in ui-classic utilizing them.

@simon3z
Copy link
Contributor

simon3z commented Aug 25, 2017

Why the added 'helper' here? This module is already a bucket of random things. Seems like this could have been a few scopes on the Metric model with the helper in ui-classic utilizing them.

@zakiva how hard is this refactoring? Is it just moving some code around?
@chrisarcand if you can coordinate a quick merge of the code in the two repos we can refactor this for master.

@zakiva
Copy link
Contributor Author

zakiva commented Aug 28, 2017

@chrisarcand I'm not sure I understand you right, can you please explain what change exactly would you like to see here? Back then a similar code was in the ui-classic repo and I was asked to move it here.

@chrisarcand
Copy link
Member

@zakiva This code is basically just layers of scoping on the metrics model. I'm suggesting actually using ActiveRecord scopes instead of this class method.

Forget about it, it's not really worth correcting at this point. I also understand if it's mostly just a code move that you were asked to do :)

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.

7 participants