Skip to content

[IMPAC-666] Refactor thresholds#407

Merged
xaun merged 2 commits intomaestrano:stagingfrom
xaun:refactor-threshold
Sep 20, 2017
Merged

[IMPAC-666] Refactor thresholds#407
xaun merged 2 commits intomaestrano:stagingfrom
xaun:refactor-threshold

Conversation

@xaun
Copy link
Copy Markdown
Contributor

@xaun xaun commented Sep 14, 2017

@cesar-tonnoir please review this refactor for the thresholds. Note this is excluding the threshold tooltips as I am experiencing problems with this and stock charts, but wanted to get at least this refactor finished today.

This refactor is linked to your comments made here: #393

@xaun xaun requested a review from cesar-tonnoir September 14, 2017 17:34
buildThresholdsFromKpis = ->
targets = ctrl.widget.kpis? && ctrl.widget.kpis[0] && ctrl.widget.kpis[0].targets
return [] unless ImpacKpisSvc.validateKpiTargets(targets)
[{ kpiId: ctrl.widget.kpis[0].id, value: targets.threshold[0].min, name: 'Alert Threshold', color: ctrl.thresholdColor, onClickEvent: onThresholdClick }]
Copy link
Copy Markdown
Contributor Author

@xaun xaun Sep 14, 2017

Choose a reason for hiding this comment

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

@cesar-tonnoir I have left the threshold name static for now as I don't think it makes sense for the widget controller to set this (how would that be if / when this is extended to iterate over multiple widget kpis?), and the UI/UX requirements for the name displayed have not been defined as of yet.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ok

@xaun
Copy link
Copy Markdown
Contributor Author

xaun commented Sep 14, 2017

Firefox is timing out on the build, any ideas? I cannot reproduce this on local. Looking online and not too sure either.

Copy link
Copy Markdown
Contributor

@cesar-tonnoir cesar-tonnoir left a comment

Choose a reason for hiding this comment

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

I like it. I like it a lot.
ctrl.chart.addThreshold... ctrl.chart.removeThreshold... sounds like a toolbox :)

LGTM

)
return unless validateHistParameters()
Highcharts.addEvent(chart.hc.container, 'click', onChartClick)
_.each buildThresholdsFromKpis(), (threshold)->
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nice 👍

buildThresholdsFromKpis = ->
targets = ctrl.widget.kpis? && ctrl.widget.kpis[0] && ctrl.widget.kpis[0].targets
return [] unless ImpacKpisSvc.validateKpiTargets(targets)
[{ kpiId: ctrl.widget.kpis[0].id, value: targets.threshold[0].min, name: 'Alert Threshold', color: ctrl.thresholdColor, onClickEvent: onThresholdClick }]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ok

@cesar-tonnoir
Copy link
Copy Markdown
Contributor

Regarding the build, this may be because of the changes done on KpisSvc?

@xaun
Copy link
Copy Markdown
Contributor Author

xaun commented Sep 15, 2017

@cesar-tonnoir please review my latest commit fixing bug discovered during stress-testing. I have stress tested with this commit & working well.

@cesar-tonnoir cesar-tonnoir changed the title Refactor thresholds [IMPAC-666] Refactor thresholds Sep 19, 2017
Highcharts.addEvent(chart.hc.container, 'click', onChartClick)
_.each buildThresholdsFromKpis(), (threshold)->
ctrl.chart.addThreshold(threshold)
thresholdSerie = ctrl.chart.findThreshold(threshold.kpiId)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wouldn't use the kpi id as the key here: couldn't we in the future add thresholds to a chart without them be related to a kpi?
Maybe use the series name instead?

thresholdSerie
@hc.addSeries(threshold)

removeThreshold: (kpiId)->
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same here: would it work if you were to use the series name instead of the kpi id?

@xaun xaun changed the base branch from release/v1.6.1 to staging September 20, 2017 17:32
@xaun xaun merged commit e8b0357 into maestrano:staging Sep 20, 2017
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