Skip to content

Commit

Permalink
Merge pull request #76 from solocommand/reporting-dates
Browse files Browse the repository at this point in the history
Change default report dates
  • Loading branch information
zarathustra323 authored Sep 18, 2019
2 parents 9025ccb + 6f356cb commit f8d353b
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ package.json.ember-try
.DS_Store
coverage
.nyc_output
.env
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
import Controller from '@ember/controller';
import { computed } from '@ember/object';
import ImpressionDataMixin from 'fortnight/mixins/impression-data-mixin';
import moment from 'moment';

export default Controller.extend(ImpressionDataMixin, {

startDate: computed('model.criteria.start', function() {
const start = this.get('model.criteria.start');
if (start) return moment(start);
return moment().subtract(14, 'days');
}),

endDate: computed('model.criteria.end', function() {
const end = this.get('model.criteria.end');
const now = moment();
if (!end) return now;
return end > now ? now : moment(end);
}),

impressionSummaryTimeSeries: computed('model.creatives.@each', function() {
return this.get('model.creatives').map(item => {
const type = 'line';
Expand Down
15 changes: 15 additions & 0 deletions app/controllers/portal/campaigns/manage/report/summary.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
import Controller from '@ember/controller';
import { inject } from '@ember/service';
import { computed } from '@ember/object';
import moment from 'moment';

import reportByDay from 'fortnight/gql/queries/campaign/reports/by-day';
import campaignMetrics from 'fortnight/gql/queries/campaign/metrics';

export default Controller.extend({
apollo: inject(),

startDate: computed('model.criteria.start', function() {
const start = this.get('model.criteria.start');
if (start) return moment(start);
return moment().subtract(14, 'days');
}),

endDate: computed('model.criteria.end', function() {
const end = this.get('model.criteria.end');
const now = moment();
if (!end) return now;
return end > now ? now : moment(end);
}),

isReportRunning: false,
areMetricsLoading: false,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ query PortalCampaignsManageReportCreativeBreakdown($input: CampaignHashInput!) {
campaignHash(input: $input) {
id
hash
criteria {
start
end
}
creatives {
...CampaignCreativeFragment
}
Expand Down
2 changes: 2 additions & 0 deletions app/templates/components/-report/campaign/creative.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<div class="col">
{{-report/campaign/chart
isLoading=isReportRunning
startDate=startDate
endDate=endDate
rows=rows
oninsert=(action "runByDayReport")
onchange=(action "runByDayReport")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

<div class="col-lg-8">
{{-report/campaign/creative
startDate=startDate
endDate=endDate
campaignId=model.id
creativeId=creative.id
}}
Expand Down
3 changes: 2 additions & 1 deletion app/templates/portal/campaigns/manage/report/summary.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@

<h4 class="text-muted px-3 mb-2">Metrics Over Time</h4>
{{-report/campaign/chart
startDate=startDate
endDate=endDate
isLoading=isReportRunning
rows=rows
oninsert=(action "runByDayReport")
Expand All @@ -66,4 +68,3 @@
</div>
</div>
</div>

0 comments on commit f8d353b

Please sign in to comment.