Skip to content

Commit

Permalink
Merge pull request #81 from ScottLogic/SDE-192-fix-report-generation
Browse files Browse the repository at this point in the history
Locked report generation library versions
  • Loading branch information
antreaspas authored Oct 29, 2019
2 parents d54e48c + be4cd42 commit 4304cd1
Show file tree
Hide file tree
Showing 7 changed files with 572 additions and 828 deletions.
18 changes: 0 additions & 18 deletions api_models/GraphicalReportInputModel.json

This file was deleted.

9 changes: 9 additions & 0 deletions api_models/ReportInputModel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "ReportInputModel",
"type": "object",
"required": ["download"],
"properties": {
"download": { "type": "boolean" }
}
}
16 changes: 10 additions & 6 deletions common/graphicalReport/graphGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ import ESSearch from './search';
import SVGBuilder from './svgbuilder';
import S3Output from './s3-output';

const buildRequestJSON = (paramJSON = {}) => {
const dateRange = paramJSON.search.find(x => x.dateRange);
const startDate = new Date(dateRange ? dateRange.dateRange[0] : Date.now());
const endDate = new Date(dateRange ? dateRange.dateRange[1] : Date.now());
if (!dateRange) startDate.setDate(startDate.getDate() - 1);
const buildRequestJSON = (paramJSON) => {
let dateRange;
if (Object.prototype.hasOwnProperty.call(paramJSON, 'search')) {
dateRange = paramJSON.search.find(x => x.dateRange);
} else {
dateRange = [Date.now() - 1, Date.now()];
}
const startDate = new Date(dateRange[0]);
const endDate = new Date(dateRange[1]);

return {
index: 'posts',
Expand Down Expand Up @@ -52,7 +56,7 @@ class graphGenerator {
}

// Entry Point.
async generateGraph(paramJSON = {}) {
async generateGraph(paramJSON) {
const reportData = await this.getReportData(paramJSON);
const reportSVG = await this.buildGraph(reportData);
return this.saveToBucket(reportSVG, paramJSON.download);
Expand Down
14 changes: 8 additions & 6 deletions common/hybridReport/hybridGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,15 @@ class HybridGenerator {
return fileURL;
}

static buildRequestJSON(paramJSON = {}) {
const dateRange = paramJSON.search.find(x => x.dateRange);
const startDate = new Date(dateRange ? dateRange.dateRange[0] : Date.now());
const endDate = new Date(dateRange ? dateRange.dateRange[1] : Date.now());
if (!dateRange) {
startDate.setDate(startDate.getDate() - 1);
static buildRequestJSON(paramJSON) {
let dateRange;
if (Object.prototype.hasOwnProperty.call(paramJSON, 'search')) {
dateRange = paramJSON.search.find(x => x.dateRange);
} else {
dateRange = [Date.now() - 1, Date.now()];
}
const startDate = new Date(dateRange[0]);
const endDate = new Date(dateRange[1]);

return {
index: 'posts',
Expand Down
Loading

0 comments on commit 4304cd1

Please sign in to comment.