-
Notifications
You must be signed in to change notification settings - Fork 23
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
Feature/sdl server statistics #150
Changes from all commits
4214683
8f8bb40
87020e7
b2818fa
ed6384b
7234793
edacf7d
8fc7862
f51be8b
710f100
858ff13
2cdad24
9549158
62f8757
9ac047a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -4,6 +4,17 @@ const sql = require('./sql.js'); | |||||
const flow = app.locals.flow; | ||||||
const async = require('async'); | ||||||
|
||||||
function getReport (req, res, next) { | ||||||
if(req.query.id === null || req.query.id === undefined) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
return res.parcel.setStatus(400).setMessage('id required').deliver(); | ||||||
} | ||||||
helper.getAggregateReportByAppId(req.query.id, function (reportData) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Logic executes code which may result in an error (such as a SQL connection or query error), but errors in callbacks seem to be ignored throughout this PR. Please revise to include proper error handling. All callbacks are expected to be in the format of |
||||||
return res.parcel.setStatus(200) | ||||||
.setData(reportData) | ||||||
.deliver(); | ||||||
}); | ||||||
} | ||||||
|
||||||
function get (req, res, next) { | ||||||
//prioritize id, uuid, approval status, in that order. | ||||||
//only one parameter can be acted upon in one request | ||||||
|
@@ -294,6 +305,7 @@ function queryAndStoreApplicationsFlow (queryObj, notifyOEM = true) { | |||||
|
||||||
module.exports = { | ||||||
get: get, | ||||||
getReport: getReport, | ||||||
actionPost: actionPost, | ||||||
putServicePermission: putServicePermission, | ||||||
autoPost: autoPost, | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ const flame = app.locals.flame; | |
const log = app.locals.log; | ||
const db = app.locals.db; | ||
const config = app.locals.config; | ||
const moment = require('moment'); | ||
|
||
//validation functions | ||
|
||
|
@@ -264,7 +265,12 @@ function attemptRetry(milliseconds, retryQueue){ | |
}, milliseconds); | ||
} | ||
|
||
function getAggregateReportByAppId (appId, cb) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary function. Function calls another function without any additions or modifications. |
||
return app.locals.reportingService.getAppUsageReport(appId, cb); | ||
} | ||
|
||
module.exports = { | ||
getAggregateReportByAppId: getAggregateReportByAppId, | ||
validateActionPost: validateActionPost, | ||
validateAutoPost: validateAutoPost, | ||
validateAdministratorPost: validateAdministratorPost, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,14 @@ const model = require('./model.js'); | |
const flow = app.locals.flow; | ||
const cache = require('../../../custom/cache'); | ||
|
||
function getReport (req, res) { | ||
helper.getAggregateReport(function (reportData) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing error handling. |
||
return res.parcel.setStatus(200) | ||
.setData(reportData) | ||
.deliver(); | ||
}); | ||
} | ||
|
||
function get (req, res, next) { | ||
//if environment is not of value "staging", then set the environment to production | ||
const isProduction = !req.query.environment || req.query.environment.toLowerCase() !== 'staging'; | ||
|
@@ -59,7 +67,8 @@ function post (isProduction, req, res, next) { | |
} | ||
|
||
module.exports = { | ||
get: get, | ||
post: post.bind(null, false), | ||
promote: post.bind(null, true) | ||
getReport: getReport, | ||
get: get, | ||
post: post.bind(null, false), | ||
promote: post.bind(null, true) | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ const app = require('../app'); | |
const flow = app.locals.flow; | ||
const setupSql = app.locals.db.setupSqlCommand; | ||
const sql = require('./sql.js'); | ||
const reportingService = app.locals.reportingService; | ||
|
||
//validation functions | ||
|
||
|
@@ -96,7 +97,24 @@ function getModuleConfigFlow (property, value) { | |
], {method: 'waterfall', eventLoop: true}); | ||
} | ||
|
||
function getAggregateReport (cb) { | ||
let obj = { | ||
report_days: reportingService.expirationDays, | ||
}; | ||
|
||
reportingService.getDeviceReport(function (deviceReport) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing error handling. |
||
reportingService.getPolicyTableUpdatesReport(function (policyTableUpdatesReport) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing error handling. |
||
Object.assign(obj, | ||
deviceReport, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indentation. |
||
policyTableUpdatesReport | ||
); | ||
cb(obj); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing error param in callback execution. |
||
}); | ||
}); | ||
} | ||
|
||
module.exports = { | ||
getAggregateReport: getAggregateReport, | ||
validatePost: validatePost, | ||
getModuleConfigFlow: getModuleConfigFlow | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please reference the database library and config file within the reporting-service rather than passing them as parameters. See existing project files for precedent.