From e7b3965991c5be5f29833d8e4dc45d48c37749c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Salvador=20P=C3=A9rez=20Garc=C3=ADa?= Date: Thu, 12 Jul 2018 11:02:34 +0200 Subject: [PATCH] Fixes #212 Vertical lines appear only for executed resources Labels for daily graph do not include the year in the x-axis. --- app/assets/javascripts/dashboard_graphs.js | 24 ++++++++++++++++++--- app/services/proposal_achievements_query.rb | 2 ++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/dashboard_graphs.js b/app/assets/javascripts/dashboard_graphs.js index 26f0aebb5..ec913bf0a 100644 --- a/app/assets/javascripts/dashboard_graphs.js +++ b/app/assets/javascripts/dashboard_graphs.js @@ -141,9 +141,8 @@ } ProposalGraph.prototype.draw = function(data) { - this.xColumnValues = this.xColumnValues.sort(); - this.xColumnValues.unshift('x'); - + this.formatXColumnValues(); + this.chart = c3.generate({ bindto: '#' + this.targetId, data: { @@ -187,6 +186,25 @@ }); }; + ProposalGraph.prototype.formatXColumnValues = function () { + var i, l, parts; + + this.xColumnValues = this.xColumnValues.sort(); + + if (this.isDailyGrouped()) { + for (i = 0, l = this.xColumnValues.length; i < l; i += 1) { + parts = this.xColumnValues[i].match(/^(\d{4})-(\d{1,2})-(\d{1,2})$/); + this.xColumnValues[i] = parts[2] + "/" + parts[3]; + } + } + + this.xColumnValues.unshift('x'); + } + + ProposalGraph.prototype.isDailyGrouped = function() { + return this.groupBy === undefined || this.groupBy === '' || this.groupBy === null + }; + $(document).ready(function () { $('[data-proposal-graph-url]').each(function () { var graph = new ProposalGraph($(this).data('proposal-graph-url')); diff --git a/app/services/proposal_achievements_query.rb b/app/services/proposal_achievements_query.rb index 084fd9f71..efd978f6a 100644 --- a/app/services/proposal_achievements_query.rb +++ b/app/services/proposal_achievements_query.rb @@ -37,8 +37,10 @@ class ProposalAchievementsQuery def achievements ProposalExecutedDashboardAction + .joins(:proposal_dashboard_action) .includes(:proposal_dashboard_action) .where(proposal: proposal, executed_at: start_date.beginning_of_day..end_date.end_of_day) + .where(proposal_dashboard_actions: { action_type: 1 }) .order(executed_at: :asc) end