From a9b44566aa9c2715bffeb54a233da4e989b088fd Mon Sep 17 00:00:00 2001 From: Davisson Paulino <dhp14@inf.ufpr.br> Date: Mon, 24 Jul 2017 10:32:03 -0300 Subject: [PATCH 01/30] added course_treatment route --- package.json | 8 +- routes/agent.js | 313 +++++++++++++++++++++++++++++++++++++++++++----- server.js | 5 +- 3 files changed, 296 insertions(+), 30 deletions(-) diff --git a/package.json b/package.json index 38d2e9f..b4b28c6 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,12 @@ "version": "0.0.0", "description": "Webservice para receber dados do agente PInSIS", "author": "Davisson Paulino <dhpaulino@gmail.com>", + "license": "GPL-3.0", "main": "server.js", + "repository": { + "type": "git", + "url": "git@gitlab.c3sl.ufpr.br:PInSIS/webservice-pinsis.git" + }, "scripts": { "start": "node server.js" }, @@ -15,6 +20,7 @@ "pg-copy-streams": "^1.2.0", "minimist": "1.2.0", "cuid": "^1.2.4", - "bunyan": "^1.0.1" + "bunyan": "^1.0.1", + "collect-webservice": "git+ssh://git@gitlab.c3sl.ufpr.br:c3sl/collect-webservice.git" } } diff --git a/routes/agent.js b/routes/agent.js index 9b2560c..54fb809 100644 --- a/routes/agent.js +++ b/routes/agent.js @@ -22,35 +22,7 @@ var async = require('async'); -function isSubSet (array1, array2) { - return array1.every(function(item1) { - return array2.some(function(item2) { - return item1 == item2; - }); - }); -} -function dateFormat (date) { - - if (!date) { - return null; - } - - return date.getFullYear() + '-' + - ("0" + (date.getMonth() + 1)).slice(-2) + '-' + - ("0" + date.getDate()).slice(-2); -} - -function timeFormat (date) { - - if (!date) { - return null; - } - - return ("0" + date.getHours()).slice(-2) + ':' + - ("0" + date.getMinutes()).slice(-2) + ':' + - ("0" + date.getSeconds()).slice(-2); -} var routes = { /*"net_usage": { @@ -88,8 +60,293 @@ var routes = { }*/ }; + +var config = { + global: { + fromBody: false, + param: "type" + }, + filters: {}, + collect_types: { + "course_treatment": { + "courses":{ + required: true, + isArray: true, + filters: [], + inner:{ + "CourseSer" : { + required: true, + isArray: false, + filters: [] + }, + "PatientSer" : { + required: true, + isArray: false, + filters: [] + }, + "CourseId" : { + required: true, + isArray: false, + filters: [] + }, + "StartDateTime" : { + required: true, + isArray: false, + filters: [] + }, + "ClinicalStatus" : { + required: true, + isArray: false, + filters: [] + }, + "CompletedByUserName" : { + required: true, + isArray: false, + filters: [] + }, + "CompletedDateTime" : { + required: true, + isArray: false, + filters: [] + }, + "Comment" : { + required: true, + isArray: false, + filters: [] + }, + "ClinicalProtocolDir" : { + required: true, + isArray: false, + filters: [] + }, + "HstryUserName" : { + required: true, + isArray: false, + filters: [] + }, + "HstryTimeStamp" : { + required: true, + isArray: false, + filters: [] + }, + "HstryDateTime" : { + required: true, + isArray: false, + filters: [] + }, + "TransactionId" : { + required: true, + isArray: false, + filters: [] + }, + "HstryTaskName" : { + required: true, + isArray: false, + filters: [] + }, + "sessions":{ + required: false, + isArray: true, + filters: [], + inner:{ + "sessionSer": { + required: true, + isArray: false, + filters: [] + }, + "SessionNum": { + required: true, + isArray: false, + filters: [] + }, + "Comment": { + required: true, + isArray: false, + filters: [] + }, + "HstryUserName": { + required: true, + isArray: false, + filters: [] + }, + "HstryTimeStamp": { + required: true, + isArray: false, + filters: [] + }, + "HstryDateTime": { + required: true, + isArray: false, + filters: [] + }, + "HstryTaskName": { + required: true, + isArray: false, + filters: [] + }, + "CourseSer": { + required: true, + isArray: false, + filters: [] + }, + "SessionProcedurePart":{//FIXME: Is it required? + required: true, + isArray: false, + filters: [], + inner:{ + "RadiationSer" : { + required: true, + isArray: false, + filters: [] + }, + "ImageType" : { + required: true, + isArray: false, + filters: [] + }, + "SequenceNumber" : { + required: true, + isArray: false, + filters: [] + }, + "SessionProcedurePartSer" : { + required: true, + isArray: false, + filters: [] + }, + "AcqAdjustment" : { + required: true, + isArray: false, + filters: [] + }, + "AutoSave" : { + required: true, + isArray: false, + filters: [] + }, + "DoseAccumulation" : { + required: true, + isArray: false, + filters: [] + }, + "Continuous" : { + required: true, + isArray: false, + filters: [] + }, + "BeamOff" : { + required: true, + isArray: false, + filters: [] + }, + "DeviationImage" : { + required: true, + isArray: false, + filters: [] + }, + "DevEnergy" : { + required: true, + isArray: false, + filters: [] + }, + "DevDoseRate" : { + required: true, + isArray: false, + filters: [] + }, + "DevGeometry" : { + required: true, + isArray: false, + filters: [] + }, + "JawState" : { + required: true, + isArray: false, + filters: [] + }, + "DevCollX1" : { + required: true, + isArray: false, + filters: [] + }, + "DevCollX2" : { + required: true, + isArray: false, + filters: [] + }, + "DevCollY1" : { + required: true, + isArray: false, + filters: [] + }, + "DevCollY2" : { + required: true, + isArray: false, + filters: [] + }, + "MUSubtraction" : { + required: true, + isArray: false, + filters: [] + }, + "AcquisitionMode" : { + required: true, + isArray: false, + filters: [] + }, + "HstryUserName" : { + required: true, + isArray: false, + filters: [] + }, + "HstryTimeStamp" : { + required: true, + isArray: false, + filters: [] + }, + "HstryDateTime" : { + required: true, + isArray: false, + filters: [] + }, + "HstryTaskName" : { + required: true, + isArray: false, + filters: [] + }, + "SessionProcedureSer" : { + required: true, + isArray: false, + filters: [] + }, + "ImageModality" : { + required: true, + isArray: false, + filters: [] + }, + "RTPlanSer" : { + required: true, + isArray: false, + filters: [] + } + } + } + } + } + } + } + } + + } +}; + + + + module.exports = function(agentVersion) { + return { + config_validation : config, collect: function(req, res) { var route = routes[req.params.type]; if(!route) { diff --git a/server.js b/server.js index a0cb67d..f235db6 100644 --- a/server.js +++ b/server.js @@ -32,6 +32,7 @@ var express = require('express'); var minimist = require('minimist'); var path = require('path'); var exec = require('child_process').execFile; +var collect = require('collect-webservice'); // // Parse command line arguments @@ -183,7 +184,9 @@ else { app.get('/api/ping', ping.get); - app.post('/api/agent/collect/:type(inventory|net_usage)', agent.collect); + + var collect_mw = collect(agent.config_validation); + app.post('/api/agent/collect/:type(course_treatment)', collect_mw, function(req, res) {return res.status(200).json({value:"ok"});}); app.get('/api/agent/version', agent.version); // -- GitLab From 6a553a905426173258a10115f305d4eb578d8ffa Mon Sep 17 00:00:00 2001 From: Davisson Paulino <dhp14@inf.ufpr.br> Date: Mon, 24 Jul 2017 11:16:07 -0300 Subject: [PATCH 02/30] separated validation --- .gitignore | 2 + routes/agent.js | 282 ------------------------------ server.js | 4 +- validation/course_treatment.js | 309 +++++++++++++++++++++++++++++++++ 4 files changed, 314 insertions(+), 283 deletions(-) create mode 100644 validation/course_treatment.js diff --git a/.gitignore b/.gitignore index 57a1234..d464d83 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ node_modules/ config.js logs/ *.swp +nohup.out +package-lock.json diff --git a/routes/agent.js b/routes/agent.js index 54fb809..c3a8f3e 100644 --- a/routes/agent.js +++ b/routes/agent.js @@ -61,292 +61,10 @@ var routes = { }; -var config = { - global: { - fromBody: false, - param: "type" - }, - filters: {}, - collect_types: { - "course_treatment": { - "courses":{ - required: true, - isArray: true, - filters: [], - inner:{ - "CourseSer" : { - required: true, - isArray: false, - filters: [] - }, - "PatientSer" : { - required: true, - isArray: false, - filters: [] - }, - "CourseId" : { - required: true, - isArray: false, - filters: [] - }, - "StartDateTime" : { - required: true, - isArray: false, - filters: [] - }, - "ClinicalStatus" : { - required: true, - isArray: false, - filters: [] - }, - "CompletedByUserName" : { - required: true, - isArray: false, - filters: [] - }, - "CompletedDateTime" : { - required: true, - isArray: false, - filters: [] - }, - "Comment" : { - required: true, - isArray: false, - filters: [] - }, - "ClinicalProtocolDir" : { - required: true, - isArray: false, - filters: [] - }, - "HstryUserName" : { - required: true, - isArray: false, - filters: [] - }, - "HstryTimeStamp" : { - required: true, - isArray: false, - filters: [] - }, - "HstryDateTime" : { - required: true, - isArray: false, - filters: [] - }, - "TransactionId" : { - required: true, - isArray: false, - filters: [] - }, - "HstryTaskName" : { - required: true, - isArray: false, - filters: [] - }, - "sessions":{ - required: false, - isArray: true, - filters: [], - inner:{ - "sessionSer": { - required: true, - isArray: false, - filters: [] - }, - "SessionNum": { - required: true, - isArray: false, - filters: [] - }, - "Comment": { - required: true, - isArray: false, - filters: [] - }, - "HstryUserName": { - required: true, - isArray: false, - filters: [] - }, - "HstryTimeStamp": { - required: true, - isArray: false, - filters: [] - }, - "HstryDateTime": { - required: true, - isArray: false, - filters: [] - }, - "HstryTaskName": { - required: true, - isArray: false, - filters: [] - }, - "CourseSer": { - required: true, - isArray: false, - filters: [] - }, - "SessionProcedurePart":{//FIXME: Is it required? - required: true, - isArray: false, - filters: [], - inner:{ - "RadiationSer" : { - required: true, - isArray: false, - filters: [] - }, - "ImageType" : { - required: true, - isArray: false, - filters: [] - }, - "SequenceNumber" : { - required: true, - isArray: false, - filters: [] - }, - "SessionProcedurePartSer" : { - required: true, - isArray: false, - filters: [] - }, - "AcqAdjustment" : { - required: true, - isArray: false, - filters: [] - }, - "AutoSave" : { - required: true, - isArray: false, - filters: [] - }, - "DoseAccumulation" : { - required: true, - isArray: false, - filters: [] - }, - "Continuous" : { - required: true, - isArray: false, - filters: [] - }, - "BeamOff" : { - required: true, - isArray: false, - filters: [] - }, - "DeviationImage" : { - required: true, - isArray: false, - filters: [] - }, - "DevEnergy" : { - required: true, - isArray: false, - filters: [] - }, - "DevDoseRate" : { - required: true, - isArray: false, - filters: [] - }, - "DevGeometry" : { - required: true, - isArray: false, - filters: [] - }, - "JawState" : { - required: true, - isArray: false, - filters: [] - }, - "DevCollX1" : { - required: true, - isArray: false, - filters: [] - }, - "DevCollX2" : { - required: true, - isArray: false, - filters: [] - }, - "DevCollY1" : { - required: true, - isArray: false, - filters: [] - }, - "DevCollY2" : { - required: true, - isArray: false, - filters: [] - }, - "MUSubtraction" : { - required: true, - isArray: false, - filters: [] - }, - "AcquisitionMode" : { - required: true, - isArray: false, - filters: [] - }, - "HstryUserName" : { - required: true, - isArray: false, - filters: [] - }, - "HstryTimeStamp" : { - required: true, - isArray: false, - filters: [] - }, - "HstryDateTime" : { - required: true, - isArray: false, - filters: [] - }, - "HstryTaskName" : { - required: true, - isArray: false, - filters: [] - }, - "SessionProcedureSer" : { - required: true, - isArray: false, - filters: [] - }, - "ImageModality" : { - required: true, - isArray: false, - filters: [] - }, - "RTPlanSer" : { - required: true, - isArray: false, - filters: [] - } - } - } - } - } - } - } - } - - } -}; - - - module.exports = function(agentVersion) { return { - config_validation : config, collect: function(req, res) { var route = routes[req.params.type]; if(!route) { diff --git a/server.js b/server.js index f235db6..1249718 100644 --- a/server.js +++ b/server.js @@ -152,6 +152,8 @@ else { var ping = require('./routes/ping.js'); var agent = require('./routes/agent.js')(config.agentVersion); + //Data validation + var ct_validator = require('./validation/course_treatment.js'); // // Setup express app @@ -185,7 +187,7 @@ else { app.get('/api/ping', ping.get); - var collect_mw = collect(agent.config_validation); + var collect_mw = collect(ct_validator()); app.post('/api/agent/collect/:type(course_treatment)', collect_mw, function(req, res) {return res.status(200).json({value:"ok"});}); app.get('/api/agent/version', agent.version); diff --git a/validation/course_treatment.js b/validation/course_treatment.js new file mode 100644 index 0000000..2ede82d --- /dev/null +++ b/validation/course_treatment.js @@ -0,0 +1,309 @@ +/* + * Copyright (C) 2012-2017 Centro de Computacao Cientifica e Software Livre + * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR + * + * This file is part of simmc + * + * simmc is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + */ + + +var config = { + global: { + fromBody: false, + param: "type" + }, + filters: {}, + collect_types: { + "course_treatment": { + "courses":{ + required: true, + isArray: true, + filters: [], + inner:{ + "CourseSer" : { + required: true, + isArray: false, + filters: [] + }, + "PatientSer" : { + required: true, + isArray: false, + filters: [] + }, + "CourseId" : { + required: true, + isArray: false, + filters: [] + }, + "StartDateTime" : { + required: true, + isArray: false, + filters: [] + }, + "ClinicalStatus" : { + required: true, + isArray: false, + filters: [] + }, + "CompletedByUserName" : { + required: true, + isArray: false, + filters: [] + }, + "CompletedDateTime" : { + required: true, + isArray: false, + filters: [] + }, + "Comment" : { + required: true, + isArray: false, + filters: [] + }, + "ClinicalProtocolDir" : { + required: true, + isArray: false, + filters: [] + }, + "HstryUserName" : { + required: true, + isArray: false, + filters: [] + }, + "HstryTimeStamp" : { + required: true, + isArray: false, + filters: [] + }, + "HstryDateTime" : { + required: true, + isArray: false, + filters: [] + }, + "TransactionId" : { + required: true, + isArray: false, + filters: [] + }, + "HstryTaskName" : { + required: true, + isArray: false, + filters: [] + }, + "sessions":{ + required: false, + isArray: true, + filters: [], + inner:{ + "sessionSer": { + required: true, + isArray: false, + filters: [] + }, + "SessionNum": { + required: true, + isArray: false, + filters: [] + }, + "Comment": { + required: true, + isArray: false, + filters: [] + }, + "HstryUserName": { + required: true, + isArray: false, + filters: [] + }, + "HstryTimeStamp": { + required: true, + isArray: false, + filters: [] + }, + "HstryDateTime": { + required: true, + isArray: false, + filters: [] + }, + "HstryTaskName": { + required: true, + isArray: false, + filters: [] + }, + "CourseSer": { + required: true, + isArray: false, + filters: [] + }, + "SessionProcedurePart":{//FIXME: Is it required? + required: true, + isArray: false, + filters: [], + inner:{ + "RadiationSer" : { + required: true, + isArray: false, + filters: [] + }, + "ImageType" : { + required: true, + isArray: false, + filters: [] + }, + "SequenceNumber" : { + required: true, + isArray: false, + filters: [] + }, + "SessionProcedurePartSer" : { + required: true, + isArray: false, + filters: [] + }, + "AcqAdjustment" : { + required: true, + isArray: false, + filters: [] + }, + "AutoSave" : { + required: true, + isArray: false, + filters: [] + }, + "DoseAccumulation" : { + required: true, + isArray: false, + filters: [] + }, + "Continuous" : { + required: true, + isArray: false, + filters: [] + }, + "BeamOff" : { + required: true, + isArray: false, + filters: [] + }, + "DeviationImage" : { + required: true, + isArray: false, + filters: [] + }, + "DevEnergy" : { + required: true, + isArray: false, + filters: [] + }, + "DevDoseRate" : { + required: true, + isArray: false, + filters: [] + }, + "DevGeometry" : { + required: true, + isArray: false, + filters: [] + }, + "JawState" : { + required: true, + isArray: false, + filters: [] + }, + "DevCollX1" : { + required: true, + isArray: false, + filters: [] + }, + "DevCollX2" : { + required: true, + isArray: false, + filters: [] + }, + "DevCollY1" : { + required: true, + isArray: false, + filters: [] + }, + "DevCollY2" : { + required: true, + isArray: false, + filters: [] + }, + "MUSubtraction" : { + required: true, + isArray: false, + filters: [] + }, + "AcquisitionMode" : { + required: true, + isArray: false, + filters: [] + }, + "HstryUserName" : { + required: true, + isArray: false, + filters: [] + }, + "HstryTimeStamp" : { + required: true, + isArray: false, + filters: [] + }, + "HstryDateTime" : { + required: true, + isArray: false, + filters: [] + }, + "HstryTaskName" : { + required: true, + isArray: false, + filters: [] + }, + "SessionProcedureSer" : { + required: true, + isArray: false, + filters: [] + }, + "ImageModality" : { + required: true, + isArray: false, + filters: [] + }, + "RTPlanSer" : { + required: true, + isArray: false, + filters: [] + } + } + } + } + } + } + } + } + + } +}; + + + + +module.exports = function() { + + return config; +}; -- GitLab From a2d88e779eea2402ec349024f4f3bfacb190582b Mon Sep 17 00:00:00 2001 From: Davisson Paulino <dhp14@inf.ufpr.br> Date: Thu, 27 Jul 2017 09:57:32 -0300 Subject: [PATCH 03/30] separeted data send to course_treatment --- validation/course_treatment.js | 593 +++++++++++++++++---------------- 1 file changed, 298 insertions(+), 295 deletions(-) diff --git a/validation/course_treatment.js b/validation/course_treatment.js index 2ede82d..e619d17 100644 --- a/validation/course_treatment.js +++ b/validation/course_treatment.js @@ -1,309 +1,312 @@ /* - * Copyright (C) 2012-2017 Centro de Computacao Cientifica e Software Livre - * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR - * - * This file is part of simmc - * - * simmc is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ +* Copyright (C) 2012-2017 Centro de Computacao Cientifica e Software Livre +* Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR +* +* This file is part of simmc +* +* simmc is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +* USA. +*/ var config = { - global: { - fromBody: false, - param: "type" - }, - filters: {}, - collect_types: { - "course_treatment": { - "courses":{ - required: true, - isArray: true, - filters: [], - inner:{ - "CourseSer" : { - required: true, - isArray: false, - filters: [] - }, - "PatientSer" : { - required: true, - isArray: false, - filters: [] - }, - "CourseId" : { - required: true, - isArray: false, - filters: [] - }, - "StartDateTime" : { - required: true, - isArray: false, - filters: [] - }, - "ClinicalStatus" : { - required: true, - isArray: false, - filters: [] - }, - "CompletedByUserName" : { - required: true, - isArray: false, - filters: [] - }, - "CompletedDateTime" : { - required: true, - isArray: false, - filters: [] - }, - "Comment" : { - required: true, - isArray: false, - filters: [] - }, - "ClinicalProtocolDir" : { - required: true, - isArray: false, - filters: [] - }, - "HstryUserName" : { - required: true, - isArray: false, - filters: [] - }, - "HstryTimeStamp" : { - required: true, - isArray: false, - filters: [] - }, - "HstryDateTime" : { - required: true, - isArray: false, - filters: [] - }, - "TransactionId" : { - required: true, - isArray: false, - filters: [] - }, - "HstryTaskName" : { - required: true, - isArray: false, - filters: [] - }, - "sessions":{ - required: false, - isArray: true, - filters: [], - inner:{ - "sessionSer": { - required: true, - isArray: false, - filters: [] - }, - "SessionNum": { - required: true, - isArray: false, - filters: [] - }, - "Comment": { - required: true, - isArray: false, - filters: [] - }, - "HstryUserName": { - required: true, - isArray: false, - filters: [] - }, - "HstryTimeStamp": { - required: true, - isArray: false, - filters: [] - }, - "HstryDateTime": { - required: true, - isArray: false, - filters: [] - }, - "HstryTaskName": { - required: true, - isArray: false, - filters: [] - }, - "CourseSer": { - required: true, - isArray: false, - filters: [] - }, - "SessionProcedurePart":{//FIXME: Is it required? - required: true, - isArray: false, - filters: [], - inner:{ - "RadiationSer" : { - required: true, - isArray: false, - filters: [] - }, - "ImageType" : { - required: true, - isArray: false, - filters: [] - }, - "SequenceNumber" : { - required: true, - isArray: false, - filters: [] - }, - "SessionProcedurePartSer" : { - required: true, - isArray: false, - filters: [] - }, - "AcqAdjustment" : { - required: true, - isArray: false, - filters: [] - }, - "AutoSave" : { - required: true, - isArray: false, - filters: [] - }, - "DoseAccumulation" : { - required: true, - isArray: false, - filters: [] - }, - "Continuous" : { - required: true, - isArray: false, - filters: [] - }, - "BeamOff" : { - required: true, - isArray: false, - filters: [] - }, - "DeviationImage" : { - required: true, - isArray: false, - filters: [] - }, - "DevEnergy" : { - required: true, - isArray: false, - filters: [] - }, - "DevDoseRate" : { - required: true, - isArray: false, - filters: [] - }, - "DevGeometry" : { - required: true, - isArray: false, - filters: [] - }, - "JawState" : { - required: true, - isArray: false, - filters: [] - }, - "DevCollX1" : { - required: true, - isArray: false, - filters: [] - }, - "DevCollX2" : { - required: true, - isArray: false, - filters: [] - }, - "DevCollY1" : { - required: true, - isArray: false, - filters: [] - }, - "DevCollY2" : { - required: true, - isArray: false, - filters: [] - }, - "MUSubtraction" : { - required: true, - isArray: false, - filters: [] - }, - "AcquisitionMode" : { - required: true, - isArray: false, - filters: [] - }, - "HstryUserName" : { - required: true, - isArray: false, - filters: [] - }, - "HstryTimeStamp" : { - required: true, - isArray: false, - filters: [] - }, - "HstryDateTime" : { - required: true, - isArray: false, - filters: [] - }, - "HstryTaskName" : { - required: true, - isArray: false, - filters: [] - }, - "SessionProcedureSer" : { - required: true, - isArray: false, - filters: [] - }, - "ImageModality" : { - required: true, - isArray: false, - filters: [] - }, - "RTPlanSer" : { - required: true, - isArray: false, - filters: [] - } - } - } - } - } - } - } + global: { + fromBody: false, + param: "type" + }, + filters: {}, + collect_types: { + "course_treatment": { + "courses":{ + required: false, + isArray: true, + filters: [], + inner:{ + "CourseSer" : { + required: true, + isArray: false, + filters: [] + }, + "PatientSer" : { + required: true, + isArray: false, + filters: [] + }, + "CourseId" : { + required: true, + isArray: false, + filters: [] + }, + "StartDateTime" : { + required: true, + isArray: false, + filters: [] + }, + "ClinicalStatus" : { + required: true, + isArray: false, + filters: [] + }, + "CompletedByUserName" : { + required: true, + isArray: false, + filters: [] + }, + "CompletedDateTime" : { + required: true, + isArray: false, + filters: [] + }, + "Comment" : { + required: true, + isArray: false, + filters: [] + }, + "ClinicalProtocolDir" : { + required: true, + isArray: false, + filters: [] + }, + "HstryUserName" : { + required: true, + isArray: false, + filters: [] + }, + "HstryTimeStamp" : { + required: true, + isArray: false, + filters: [] + }, + "HstryDateTime" : { + required: true, + isArray: false, + filters: [] + }, + "TransactionId" : { + required: true, + isArray: false, + filters: [] + }, + "HstryTaskName" : { + required: true, + isArray: false, + filters: [] + } + } + }, + "sessions":{ + required: false, + isArray: true, + filters: [], + inner:{ + "sessionSer": { + required: true, + isArray: false, + filters: [] + }, + "SessionNum": { + required: true, + isArray: false, + filters: [] + }, + "Comment": { + required: true, + isArray: false, + filters: [] + }, + "HstryUserName": { + required: true, + isArray: false, + filters: [] + }, + "HstryTimeStamp": { + required: true, + isArray: false, + filters: [] + }, + "HstryDateTime": { + required: true, + isArray: false, + filters: [] + }, + "HstryTaskName": { + required: true, + isArray: false, + filters: [] + }, + "CourseSer": { + required: true, + isArray: false, + filters: [] + }, + } + }, + "sessionProcedureParts":{//FIXME: Is it required? + required: false, + isArray: true, + filters: [], + inner:{ + "RadiationSer" : { + required: true, + isArray: false, + filters: [] + }, + "ImageType" : { + required: true, + isArray: false, + filters: [] + }, + "SequenceNumber" : { + required: true, + isArray: false, + filters: [] + }, + "SessionProcedurePartSer" : { + required: true, + isArray: false, + filters: [] + }, + "AcqAdjustment" : { + required: true, + isArray: false, + filters: [] + }, + "AutoSave" : { + required: true, + isArray: false, + filters: [] + }, + "DoseAccumulation" : { + required: true, + isArray: false, + filters: [] + }, + "Continuous" : { + required: true, + isArray: false, + filters: [] + }, + "BeamOff" : { + required: true, + isArray: false, + filters: [] + }, + "DeviationImage" : { + required: true, + isArray: false, + filters: [] + }, + "DevEnergy" : { + required: true, + isArray: false, + filters: [] + }, + "DevDoseRate" : { + required: true, + isArray: false, + filters: [] + }, + "DevGeometry" : { + required: true, + isArray: false, + filters: [] + }, + "JawState" : { + required: true, + isArray: false, + filters: [] + }, + "DevCollX1" : { + required: true, + isArray: false, + filters: [] + }, + "DevCollX2" : { + required: true, + isArray: false, + filters: [] + }, + "DevCollY1" : { + required: true, + isArray: false, + filters: [] + }, + "DevCollY2" : { + required: true, + isArray: false, + filters: [] + }, + "MUSubtraction" : { + required: true, + isArray: false, + filters: [] + }, + "AcquisitionMode" : { + required: true, + isArray: false, + filters: [] + }, + "HstryUserName" : { + required: true, + isArray: false, + filters: [] + }, + "HstryTimeStamp" : { + required: true, + isArray: false, + filters: [] + }, + "HstryDateTime" : { + required: true, + isArray: false, + filters: [] + }, + "HstryTaskName" : { + required: true, + isArray: false, + filters: [] + }, + "SessionProcedureSer" : { + required: true, + isArray: false, + filters: [] + }, + "ImageModality" : { + required: true, + isArray: false, + filters: [] + }, + "RTPlanSer" : { + required: true, + isArray: false, + filters: [] + } + } + } } + } }; +var parser = function(body){ +} module.exports = function() { - - return config; + + return config; }; -- GitLab From 0c2f874503e85207ab17e0aae7333f3cb68466a4 Mon Sep 17 00:00:00 2001 From: Davisson Paulino <dhp14@inf.ufpr.br> Date: Tue, 1 Aug 2017 10:09:02 -0300 Subject: [PATCH 04/30] Persisting request and made query builder --- config.js.example | 40 --- db/query_builder.js | 21 ++ package-lock.json | 480 --------------------------------- package.json | 1 + routes/agent.js | 215 ++++++++------- server.js | 14 +- validation/course_treatment.js | 2 +- 7 files changed, 152 insertions(+), 621 deletions(-) delete mode 100644 config.js.example create mode 100644 db/query_builder.js delete mode 100644 package-lock.json diff --git a/config.js.example b/config.js.example deleted file mode 100644 index b2deb06..0000000 --- a/config.js.example +++ /dev/null @@ -1,40 +0,0 @@ -var config = module.exports = {}; - -config.db_config = { - user: 'user', - password: 'password', - database: 'dbname', - host: 'localhost', - port: 5432 -}; - -config.mail = { - port: 25 - , host: 'localhost' - , ignoreTLS: true - , secure: false - , from: 'noreply@simmc.c3sl.ufpr.br' -}; - -config.report_config = { - imagesPath: './reports/reports/images/' - , outputPath: './tmp/reports' -}; - -config.alert_config = { - alertsPath: '/home/simmc/simmc/scripts/alerts/' -}; - -config.fqdn = 'simmc.c3sl.ufpr.br'; - -config.agentVersion = 1.0; - -config.secret = '123mudar'; - -// Uncomment to enable memcached -// -// config.memcached = { -// server: 'localhost:11211', -// options: { retries: 1, timeout: 1000, poolSize: 1 }, -// lifetime: 3600 // 1 hour in seconds -// }; diff --git a/db/query_builder.js b/db/query_builder.js new file mode 100644 index 0000000..c2a50e8 --- /dev/null +++ b/db/query_builder.js @@ -0,0 +1,21 @@ +module.exports = function(){ + + squel = require("squel").useFlavour('postgres'); + + + return { + set_from_attr : function (query, obj){ + for (var property in obj) { + if (obj.hasOwnProperty(property)) { + query.set(property, obj[property]); + } + } + return query; + }, + insert: function (table, obj){ + var q = squel.insert().into(table); + this.set_from_attr(q, obj); + return q; + } + } +} diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index cacdd20..0000000 --- a/package-lock.json +++ /dev/null @@ -1,480 +0,0 @@ -{ - "name": "webservice-pinsis", - "version": "0.0.0", - "lockfileVersion": 1, - "dependencies": { - "accepts": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.3.tgz", - "integrity": "sha1-w8p0NJOGSMPg2cHjKN1otiLChMo=" - }, - "ap": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/ap/-/ap-0.2.0.tgz", - "integrity": "sha1-rglCYAspkS8NKxTsYMRejzMLYRA=" - }, - "array-flatten": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", - "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" - }, - "async": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/async/-/async-2.5.0.tgz", - "integrity": "sha512-e+lJAJeNWuPCNyxZKOBdaJGyLGHugXVQtrAwtuAe2vhxTYxFTKE73p8JuTmdH0qdQZtDvI4dhJwjZc5zsfIsYw==" - }, - "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "optional": true - }, - "body-parser": { - "version": "1.17.2", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.17.2.tgz", - "integrity": "sha1-+IkqvI+eYn1Crtr7yma/WrmRBO4=" - }, - "brace-expansion": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", - "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", - "optional": true - }, - "browser-fingerprint": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/browser-fingerprint/-/browser-fingerprint-0.0.1.tgz", - "integrity": "sha1-jfPNyiW/fVs1QtYVRdcwBT/OYEo=" - }, - "buffer-writer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/buffer-writer/-/buffer-writer-1.0.1.tgz", - "integrity": "sha1-Iqk2kB4wKa/NdUfrRIfOtpejvwg=" - }, - "bunyan": { - "version": "1.8.10", - "resolved": "https://registry.npmjs.org/bunyan/-/bunyan-1.8.10.tgz", - "integrity": "sha1-IB/t0mxwgLYy9BYHL1OpC5pSmBw=" - }, - "bytes": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-2.4.0.tgz", - "integrity": "sha1-fZcZb51br39pNeJZhVSe3SpsIzk=" - }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "optional": true - }, - "content-disposition": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", - "integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ=" - }, - "content-type": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.2.tgz", - "integrity": "sha1-t9ETrueo3Se9IRM8TcJSnfFyHu0=" - }, - "cookie": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", - "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=" - }, - "cookie-signature": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", - "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" - }, - "core-js": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-1.2.7.tgz", - "integrity": "sha1-ZSKUwUZR2yj6k70tX/KYOk8IxjY=" - }, - "cuid": { - "version": "1.3.8", - "resolved": "https://registry.npmjs.org/cuid/-/cuid-1.3.8.tgz", - "integrity": "sha1-S4deCWm612T37AcGz0T1+wgx9rc=" - }, - "debug": { - "version": "2.6.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.7.tgz", - "integrity": "sha1-krrR9tBbu2u6Isyoi80OyJTChh4=" - }, - "depd": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.0.tgz", - "integrity": "sha1-4b2Cxqq2ztlluXuIsX7T5SjKGMM=" - }, - "destroy": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", - "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" - }, - "dtrace-provider": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/dtrace-provider/-/dtrace-provider-0.8.3.tgz", - "integrity": "sha1-uhv8ZJMoXM/PxqtpzVxh10wqQ78=", - "optional": true - }, - "ee-first": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", - "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" - }, - "encodeurl": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.1.tgz", - "integrity": "sha1-eePVhlU0aQn+bw9Fpd5oEDspTSA=" - }, - "escape-html": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", - "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" - }, - "etag": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.0.tgz", - "integrity": "sha1-b2Ma7zNtbEY2K1F2QETOIWvjwFE=" - }, - "express": { - "version": "4.15.3", - "resolved": "https://registry.npmjs.org/express/-/express-4.15.3.tgz", - "integrity": "sha1-urZdDwOqgMNYQIly/HAPkWlEtmI=" - }, - "finalhandler": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.0.3.tgz", - "integrity": "sha1-70fneVDpmXgOhgIqVg4yF+DQzIk=" - }, - "forwarded": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.0.tgz", - "integrity": "sha1-Ge+YdMSuHCl7zweP3mOgm2aoQ2M=" - }, - "fresh": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.0.tgz", - "integrity": "sha1-9HTKXmqSRtb9jglTz6m5yAWvp44=" - }, - "generic-pool": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/generic-pool/-/generic-pool-2.4.3.tgz", - "integrity": "sha1-eAw29p360FpaBF3Te+etyhGk9v8=" - }, - "glob": { - "version": "6.0.4", - "resolved": "https://registry.npmjs.org/glob/-/glob-6.0.4.tgz", - "integrity": "sha1-DwiGD2oVUSey+t1PnOJLGqtuTSI=", - "optional": true - }, - "http-errors": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.1.tgz", - "integrity": "sha1-X4uO2YrKVFZWv1cplzh/kEpyIlc=" - }, - "iconv-lite": { - "version": "0.4.15", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.15.tgz", - "integrity": "sha1-/iZaIYrGpXz+hUkn6dBMGYJe3es=" - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "optional": true - }, - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" - }, - "ipaddr.js": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.3.0.tgz", - "integrity": "sha1-HgOlL9rYOou7KyXL9JmLTP/NPew=" - }, - "lodash": { - "version": "4.17.4", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", - "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=" - }, - "media-typer": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", - "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" - }, - "merge-descriptors": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", - "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" - }, - "methods": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", - "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" - }, - "mime": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/mime/-/mime-1.3.4.tgz", - "integrity": "sha1-EV+eO2s9rylZmDyzjxSaLUDrXVM=" - }, - "mime-db": { - "version": "1.27.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.27.0.tgz", - "integrity": "sha1-gg9XIpa70g7CXtVeW13oaeVDbrE=" - }, - "mime-types": { - "version": "2.1.15", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.15.tgz", - "integrity": "sha1-pOv1BkCUVpI3uM9wBGd20J/JKu0=" - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "optional": true - }, - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" - }, - "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", - "optional": true, - "dependencies": { - "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "optional": true - } - } - }, - "moment": { - "version": "2.18.1", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.18.1.tgz", - "integrity": "sha1-w2GT3Tzhwu7SrbfIAtu8d6gbHA8=", - "optional": true - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" - }, - "mv": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/mv/-/mv-2.1.1.tgz", - "integrity": "sha1-rmzg1vbV4KT32JN5jQPB6pVZtqI=", - "optional": true - }, - "nan": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.6.2.tgz", - "integrity": "sha1-5P805slf37WuzAjeZZb0NgWn20U=", - "optional": true - }, - "ncp": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ncp/-/ncp-2.0.0.tgz", - "integrity": "sha1-GVoh1sRuNh0vsSgbo4uR6d9727M=", - "optional": true - }, - "negotiator": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", - "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=" - }, - "node-fingerprint": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/node-fingerprint/-/node-fingerprint-0.0.2.tgz", - "integrity": "sha1-Mcur63GmeufdWn3AQuUcPHWGhQE=" - }, - "object-assign": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.0.tgz", - "integrity": "sha1-ejs9DpgGPUP0wD8uiubNUahog6A=" - }, - "on-finished": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", - "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=" - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=" - }, - "packet-reader": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/packet-reader/-/packet-reader-0.3.1.tgz", - "integrity": "sha1-zWLmCvjX/qinBexP+ZCHHEaHHyc=" - }, - "parseurl": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.1.tgz", - "integrity": "sha1-yKuMkiO6NIiKpkopeyiFO+wY2lY=" - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "optional": true - }, - "path-to-regexp": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", - "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" - }, - "pg": { - "version": "6.4.0", - "resolved": "https://registry.npmjs.org/pg/-/pg-6.4.0.tgz", - "integrity": "sha1-y3a6Lnwuq4n8ZL96n+ZIztckNtw=" - }, - "pg-connection-string": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-0.1.3.tgz", - "integrity": "sha1-2hhHsglA5C7hSSvq9l1J2RskXfc=" - }, - "pg-copy-streams": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/pg-copy-streams/-/pg-copy-streams-1.2.0.tgz", - "integrity": "sha1-ez+d7gtsX8IGj1nED6IY4MHXQkk=" - }, - "pg-pool": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-1.8.0.tgz", - "integrity": "sha1-9+xzgkw3oD8Hb1G/33DjQBR8Tzc=" - }, - "pg-types": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/pg-types/-/pg-types-1.12.0.tgz", - "integrity": "sha1-itO3uJfj/UY+Yt4kGtX8ZAtKZvA=" - }, - "pgpass": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/pgpass/-/pgpass-1.0.2.tgz", - "integrity": "sha1-Knu0G2BltnkH6R2hsHwYR8h3swY=" - }, - "postgres-array": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-1.0.2.tgz", - "integrity": "sha1-jgsy6wO/d6XAp4UeBEHBaaJWojg=" - }, - "postgres-bytea": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/postgres-bytea/-/postgres-bytea-1.0.0.tgz", - "integrity": "sha1-AntTPAqokOJtFy1Hz5zOzFIazTU=" - }, - "postgres-date": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.3.tgz", - "integrity": "sha1-4tiXAu/bJY/52c7g/pG9BpdSV6g=" - }, - "postgres-interval": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-1.1.0.tgz", - "integrity": "sha1-EDHnusNFZBMoYq3J62xtLzqnW7Q=" - }, - "proxy-addr": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-1.1.4.tgz", - "integrity": "sha1-J+VF9pYKRKYn2bREZ+NcG2tM4vM=" - }, - "qs": { - "version": "6.4.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.4.0.tgz", - "integrity": "sha1-E+JtKK1rD/qpExLNO/cI7TUecjM=" - }, - "range-parser": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", - "integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4=" - }, - "raw-body": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.2.0.tgz", - "integrity": "sha1-mUl2z2pQlqQRYoQEkvC9xdbn+5Y=" - }, - "rimraf": { - "version": "2.4.5", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.4.5.tgz", - "integrity": "sha1-7nEM5dk6j9uFb7Xqj/Di11k0sto=", - "optional": true - }, - "safe-json-stringify": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/safe-json-stringify/-/safe-json-stringify-1.0.4.tgz", - "integrity": "sha1-gaCY9Efku8P/MxKiQ1IbwGDvWRE=", - "optional": true - }, - "semver": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-4.3.2.tgz", - "integrity": "sha1-x6BxWKgL7dBSNVt3DYLWZA+AO+c=" - }, - "send": { - "version": "0.15.3", - "resolved": "https://registry.npmjs.org/send/-/send-0.15.3.tgz", - "integrity": "sha1-UBP5+ZAj31DRvZiSwZ4979HVMwk=" - }, - "serve-static": { - "version": "1.12.3", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.12.3.tgz", - "integrity": "sha1-n0uhni8wMMVH+K+ZEHg47DjVseI=" - }, - "setprototypeof": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz", - "integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ=" - }, - "split": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/split/-/split-1.0.0.tgz", - "integrity": "sha1-xDlc5oOrzSVLwo/h2rtuXCfc/64=" - }, - "statuses": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", - "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=" - }, - "through": { - "version": "2.3.8", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" - }, - "type-is": { - "version": "1.6.15", - "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.15.tgz", - "integrity": "sha1-yrEPtJCeRByChC6v4a1kbIGARBA=" - }, - "unpipe": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", - "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" - }, - "utils-merge": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.0.tgz", - "integrity": "sha1-ApT7kiu5N1FTVBxPcJYjHyh8ivg=" - }, - "vary": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.1.tgz", - "integrity": "sha1-Z1Neu2lMHVIldFeYRmUyP1h+jTc=" - }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" - }, - "xtend": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", - "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=" - } - } -} diff --git a/package.json b/package.json index b4b28c6..0708173 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "minimist": "1.2.0", "cuid": "^1.2.4", "bunyan": "^1.0.1", + "squel": "^5.10.0", "collect-webservice": "git+ssh://git@gitlab.c3sl.ufpr.br:c3sl/collect-webservice.git" } } diff --git a/routes/agent.js b/routes/agent.js index c3a8f3e..1764767 100644 --- a/routes/agent.js +++ b/routes/agent.js @@ -1,107 +1,136 @@ /* - * Copyright (C) 2012-2017 Centro de Computacao Cientifica e Software Livre - * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR - * - * This file is part of simmc - * - * simmc is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ +* Copyright (C) 2012-2017 Centro de Computacao Cientifica e Software Livre +* Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR +* +* This file is part of simmc +* +* simmc is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +* USA. +*/ var async = require('async'); var routes = { - /*"net_usage": { - validation: function(body) { - if(!body) { - return false; - } - else { - var keys = [ - 'id_point', - 'mac_address', - 'bytes_recived', - 'bytes_transmited', - 'collect_time', - 'packets_recived', - 'packets_transmited', - ]; - return isSubSet(Object.keys(body), keys); - } - }, - parser: function(body) { - return [ - dateFormat(new Date()), - body.id_point, - body.mac_address, - dateFormat(body.collect_time), - timeFormat(body.collect_time), - body.bytes_recived, - body.packets_recived, - body.bytes_transmited, - body.packets_transmited, - ]; - }, - query: 'collect/net_usage.sql' - }*/ + /*"net_usage": { + validation: function(body) { + if(!body) { + return false; +} +else { +var keys = [ +'id_point', +'mac_address', +'bytes_recived', +'bytes_transmited', +'collect_time', +'packets_recived', +'packets_transmited', +]; +return isSubSet(Object.keys(body), keys); +} +}, +parser: function(body) { +return [ +dateFormat(new Date()), +body.id_point, +body.mac_address, +dateFormat(body.collect_time), +timeFormat(body.collect_time), +body.bytes_recived, +body.packets_recived, +body.bytes_transmited, +body.packets_transmited, +]; +}, +query: 'collect/net_usage.sql' +}*/ }; module.exports = function(agentVersion) { - - return { - collect: function(req, res) { - var route = routes[req.params.type]; - if(!route) { - return res.status(400).json({error: 'invalid_parameter'}); - } - if(route.validation(req.body)) { - var data = route.parser(req.body); - req.db.connect(function(err, conn, done) { - if (err) { - req.log.error(err); - res.status(500).json({error: 'db_connection_failed'}); - return; - } - async.waterfall([ - conn.transaction, - function(callback) { - conn.queryFromFile(route.query, data, callback); - }, - conn.commit - ], function (err, result) { - if(err) { - req.log.error(err); - res.staus(500).json({error: 'db_query_failed'}); - conn.rollback(done); - return; - } - res.status(200).json({}); - done(); - }); - }); - } - else { - return res.status(400).json({error: 'invalid_body'}); - } - }, - version : function (req, res) { - return res.status(200).json({version: agentVersion}); + qb = require("../db/query_builder.js")(); + + return { + collect: function(req, res) { + //console.log(req.body.courses[0]); + var queries = new Array(); + if(req.body.hasOwnProperty("courses")){ + for(var i=0;i < req.body.courses.length; i++){ + var course = req.body.courses[i]; + var q = qb.insert('Course', course); + queries.push(q); + } + + } + + if(req.body.hasOwnProperty("sessions")){ + req.body.sessions.forEach(function(session){ + queries.push(qb.insert('Session', session)); + }); + + } + + if(req.body.hasOwnProperty("sessionProcedureParts")){ + req.body.sessionProcedureParts.forEach(function(spp){ + queries.push(qb.insert('sessionProcedureParts', spp)); + }); + + } + req.db.connect(function(err, conn, done) { + if (err) { + req.log.error(err); + res.status(500).json({error: 'db_connection_failed'}); + return; } - }; + async.waterfall([ + conn.transaction, + function(callback) { + + async.everySeries(queries, async function(q){ + try{ + await conn.query(q.toParam().text, q.toParam().values); + return true; + }catch(err){ + callback(err); + return false; + } + }, function(err, result){ + if(result){ + callback(null); + } + }); + }, + conn.commit + ], function (err, result) { + if(err) { + req.log.error(err); + console.log(err); + res.status(500).json({error: 'db_query_failed'}); + conn.rollback(done); + return; + } + res.status(200).json({}); + done(); + }); + }); + }, + version : function (req, res) { + return res.status(200).json({version: agentVersion}); + } + }; }; diff --git a/server.js b/server.js index 1249718..0b19c41 100644 --- a/server.js +++ b/server.js @@ -141,14 +141,14 @@ else { // // Middlewares // - + var db = require('./middleware/db.js'); var utils = require('./lib/utils.js'); // // Routes // - + var ping = require('./routes/ping.js'); var agent = require('./routes/agent.js')(config.agentVersion); @@ -165,10 +165,10 @@ else { app.use(bodyParser.urlencoded({extended: true})); - + app.use(db.pool(config.db_config)); - + // acquire user id and ip address app.use(function (req, res, next) { @@ -176,19 +176,19 @@ else { next(); }); - + // // Setup routes // - + app.get('/api/ping', ping.get); var collect_mw = collect(ct_validator()); - app.post('/api/agent/collect/:type(course_treatment)', collect_mw, function(req, res) {return res.status(200).json({value:"ok"});}); + app.post('/api/agent/collect/:type(course_treatment)', collect_mw, agent.collect); app.get('/api/agent/version', agent.version); // diff --git a/validation/course_treatment.js b/validation/course_treatment.js index e619d17..188fd29 100644 --- a/validation/course_treatment.js +++ b/validation/course_treatment.js @@ -301,7 +301,7 @@ var config = { } }; -var parser = function(body){ +var parser = function(body){//TODO: remove extra fields in the body } -- GitLab From 74bd9aa40f20b1729f1cb888c7ab296d0b0feecf Mon Sep 17 00:00:00 2001 From: Davisson Paulino <dhp14@inf.ufpr.br> Date: Tue, 1 Aug 2017 11:39:26 -0300 Subject: [PATCH 05/30] adde gulp and jhslint --- gulpfile.js | 25 +++++++++++++++++++++++++ package.json | 7 +++++++ routes/agent.js | 2 +- validation/course_treatment.js | 2 +- 4 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 gulpfile.js diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..3a03d86 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,25 @@ +var gulp = require('gulp'), + jshint = require('gulp-jshint'), + shell = require('gulp-shell'); + +var js_files = "**/*.js"; + +// define the default task and add the watch task to it +gulp.task('default', ['run','watch']); + +// configure the jshint task +gulp.task('jshint', function() { + return gulp.src([js_files, "!node_modules/**/*.js"]) + .pipe(jshint()) + .pipe(jshint.reporter('jshint-stylish')); +}); + +// configure which files to watch and what tasks to use on file changes +gulp.task('watch', function() { + gulp.watch(js_files, ['jshint']); +}); + +gulp.task('run', function(){ + return gulp.src("*") + .pipe(shell('npm start')); +}) diff --git a/package.json b/package.json index 0708173..661972a 100644 --- a/package.json +++ b/package.json @@ -23,5 +23,12 @@ "bunyan": "^1.0.1", "squel": "^5.10.0", "collect-webservice": "git+ssh://git@gitlab.c3sl.ufpr.br:c3sl/collect-webservice.git" + }, + "devDependencies": { + "gulp": "^3.9.1", + "gulp-jshint": "^2.0.4", + "gulp-shell": "^0.6.3", + "jshint": "^2.9.5", + "jshint-stylish": "^2.2.1" } } diff --git a/routes/agent.js b/routes/agent.js index 1764767..cad1fae 100644 --- a/routes/agent.js +++ b/routes/agent.js @@ -68,7 +68,7 @@ module.exports = function(agentVersion) { return { collect: function(req, res) { //console.log(req.body.courses[0]); - var queries = new Array(); + var queries = []; if(req.body.hasOwnProperty("courses")){ for(var i=0;i < req.body.courses.length; i++){ var course = req.body.courses[i]; diff --git a/validation/course_treatment.js b/validation/course_treatment.js index 188fd29..f97d032 100644 --- a/validation/course_treatment.js +++ b/validation/course_treatment.js @@ -303,7 +303,7 @@ var config = { var parser = function(body){//TODO: remove extra fields in the body -} +}; module.exports = function() { -- GitLab From 24b22475c0f3e517eccc07acd5a3a0f92a6c97ed Mon Sep 17 00:00:00 2001 From: Davisson Paulino <dhp14@inf.ufpr.br> Date: Mon, 14 Aug 2017 10:09:00 -0300 Subject: [PATCH 06/30] Create course_treatment test and automatized database creation --- .gitignore | 1 + .gitlab-ci.yml | 22 + config.js.example | 13 + coverage/base.css | 212 ++++ coverage/index.html | 158 +++ coverage/prettify.css | 1 + coverage/prettify.js | 1 + coverage/sort-arrow-sprite.png | Bin 0 -> 209 bytes coverage/sorter.js | 158 +++ coverage/webservice-pinsis/config.js.html | 104 ++ coverage/webservice-pinsis/db/index.html | 93 ++ .../db/query_builder.js.html | 128 +++ coverage/webservice-pinsis/index.html | 106 ++ coverage/webservice-pinsis/lib/index.html | 106 ++ coverage/webservice-pinsis/lib/logger.js.html | 476 ++++++++ coverage/webservice-pinsis/lib/utils.js.html | 329 ++++++ .../webservice-pinsis/middleware/db.js.html | 569 ++++++++++ .../webservice-pinsis/middleware/index.html | 93 ++ .../webservice-pinsis/routes/agent.js.html | 464 ++++++++ coverage/webservice-pinsis/routes/index.html | 106 ++ .../webservice-pinsis/routes/ping.js.html | 164 +++ coverage/webservice-pinsis/server.js.html | 743 ++++++++++++ .../validation/course_treatment.js.html | 1001 +++++++++++++++++ .../webservice-pinsis/validation/index.html | 93 ++ database/create.sh | 105 ++ database/create/schema/bd.sql | 69 ++ database/create_user.sh | 54 + database/pg_hba.conf | 100 ++ gulpfile.js | 35 +- package.json | 10 +- routes/agent.js | 5 +- server.js | 125 +- test/agent.js | 40 + test/config.js.example | 13 + 34 files changed, 5635 insertions(+), 62 deletions(-) create mode 100644 .gitlab-ci.yml create mode 100644 config.js.example create mode 100644 coverage/base.css create mode 100644 coverage/index.html create mode 100644 coverage/prettify.css create mode 100644 coverage/prettify.js create mode 100644 coverage/sort-arrow-sprite.png create mode 100644 coverage/sorter.js create mode 100644 coverage/webservice-pinsis/config.js.html create mode 100644 coverage/webservice-pinsis/db/index.html create mode 100644 coverage/webservice-pinsis/db/query_builder.js.html create mode 100644 coverage/webservice-pinsis/index.html create mode 100644 coverage/webservice-pinsis/lib/index.html create mode 100644 coverage/webservice-pinsis/lib/logger.js.html create mode 100644 coverage/webservice-pinsis/lib/utils.js.html create mode 100644 coverage/webservice-pinsis/middleware/db.js.html create mode 100644 coverage/webservice-pinsis/middleware/index.html create mode 100644 coverage/webservice-pinsis/routes/agent.js.html create mode 100644 coverage/webservice-pinsis/routes/index.html create mode 100644 coverage/webservice-pinsis/routes/ping.js.html create mode 100644 coverage/webservice-pinsis/server.js.html create mode 100644 coverage/webservice-pinsis/validation/course_treatment.js.html create mode 100644 coverage/webservice-pinsis/validation/index.html create mode 100755 database/create.sh create mode 100755 database/create/schema/bd.sql create mode 100755 database/create_user.sh create mode 100644 database/pg_hba.conf create mode 100644 test/agent.js create mode 100644 test/config.js.example diff --git a/.gitignore b/.gitignore index d464d83..bbd1eea 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ logs/ *.swp nohup.out package-lock.json +.nyc_output/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..f9118f0 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,22 @@ +stages: + - test + +services: + - postgres +variables: + NODE_ENV: 'test' + +before_script: + - npm install --global mocha gulp + - npm install + +run_tests: + stage: test + script: + - mv config.json.example config.json + - gulp test + tags: + - node + cache: + paths: + - node_modules/ diff --git a/config.js.example b/config.js.example new file mode 100644 index 0000000..d611233 --- /dev/null +++ b/config.js.example @@ -0,0 +1,13 @@ +var config = module.exports = {}; + +config.db_config = { + user: 'user', + password: 'password', + database: 'dbname', + host: 'localhost', + port: 5432 +}; + +config.fqdn = 'pinsis.c3sl.ufpr.br'; + +config.agentVersion = 0.0; diff --git a/coverage/base.css b/coverage/base.css new file mode 100644 index 0000000..417c7ad --- /dev/null +++ b/coverage/base.css @@ -0,0 +1,212 @@ +body, html { + margin:0; padding: 0; + height: 100%; +} +body { + font-family: Helvetica Neue, Helvetica, Arial; + font-size: 14px; + color:#333; +} +.small { font-size: 12px; } +*, *:after, *:before { + -webkit-box-sizing:border-box; + -moz-box-sizing:border-box; + box-sizing:border-box; + } +h1 { font-size: 20px; margin: 0;} +h2 { font-size: 14px; } +pre { + font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace; + margin: 0; + padding: 0; + -moz-tab-size: 2; + -o-tab-size: 2; + tab-size: 2; +} +a { color:#0074D9; text-decoration:none; } +a:hover { text-decoration:underline; } +.strong { font-weight: bold; } +.space-top1 { padding: 10px 0 0 0; } +.pad2y { padding: 20px 0; } +.pad1y { padding: 10px 0; } +.pad2x { padding: 0 20px; } +.pad2 { padding: 20px; } +.pad1 { padding: 10px; } +.space-left2 { padding-left:55px; } +.space-right2 { padding-right:20px; } +.center { text-align:center; } +.clearfix { display:block; } +.clearfix:after { + content:''; + display:block; + height:0; + clear:both; + visibility:hidden; + } +.fl { float: left; } +@media only screen and (max-width:640px) { + .col3 { width:100%; max-width:100%; } + .hide-mobile { display:none!important; } +} + +.quiet { + color: #7f7f7f; + color: rgba(0,0,0,0.5); +} +.quiet a { opacity: 0.7; } + +.fraction { + font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; + font-size: 10px; + color: #555; + background: #E8E8E8; + padding: 4px 5px; + border-radius: 3px; + vertical-align: middle; +} + +div.path a:link, div.path a:visited { color: #333; } +table.coverage { + border-collapse: collapse; + margin: 10px 0 0 0; + padding: 0; +} + +table.coverage td { + margin: 0; + padding: 0; + vertical-align: top; +} +table.coverage td.line-count { + text-align: right; + padding: 0 5px 0 20px; +} +table.coverage td.line-coverage { + text-align: right; + padding-right: 10px; + min-width:20px; +} + +table.coverage td span.cline-any { + display: inline-block; + padding: 0 5px; + width: 100%; +} +.missing-if-branch { + display: inline-block; + margin-right: 5px; + border-radius: 3px; + position: relative; + padding: 0 4px; + background: #333; + color: yellow; +} + +.skip-if-branch { + display: none; + margin-right: 10px; + position: relative; + padding: 0 4px; + background: #ccc; + color: white; +} +.missing-if-branch .typ, .skip-if-branch .typ { + color: inherit !important; +} +.coverage-summary { + border-collapse: collapse; + width: 100%; +} +.coverage-summary tr { border-bottom: 1px solid #bbb; } +.keyline-all { border: 1px solid #ddd; } +.coverage-summary td, .coverage-summary th { padding: 10px; } +.coverage-summary tbody { border: 1px solid #bbb; } +.coverage-summary td { border-right: 1px solid #bbb; } +.coverage-summary td:last-child { border-right: none; } +.coverage-summary th { + text-align: left; + font-weight: normal; + white-space: nowrap; +} +.coverage-summary th.file { border-right: none !important; } +.coverage-summary th.pct { } +.coverage-summary th.pic, +.coverage-summary th.abs, +.coverage-summary td.pct, +.coverage-summary td.abs { text-align: right; } +.coverage-summary td.file { white-space: nowrap; } +.coverage-summary td.pic { min-width: 120px !important; } +.coverage-summary tfoot td { } + +.coverage-summary .sorter { + height: 10px; + width: 7px; + display: inline-block; + margin-left: 0.5em; + background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent; +} +.coverage-summary .sorted .sorter { + background-position: 0 -20px; +} +.coverage-summary .sorted-desc .sorter { + background-position: 0 -10px; +} +.status-line { height: 10px; } +/* dark red */ +.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 } +.low .chart { border:1px solid #C21F39 } +/* medium red */ +.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE } +/* light red */ +.low, .cline-no { background:#FCE1E5 } +/* light green */ +.high, .cline-yes { background:rgb(230,245,208) } +/* medium green */ +.cstat-yes { background:rgb(161,215,106) } +/* dark green */ +.status-line.high, .high .cover-fill { background:rgb(77,146,33) } +.high .chart { border:1px solid rgb(77,146,33) } + + +.medium .chart { border:1px solid #666; } +.medium .cover-fill { background: #666; } + +.cbranch-no { background: yellow !important; color: #111; } + +.cstat-skip { background: #ddd; color: #111; } +.fstat-skip { background: #ddd; color: #111 !important; } +.cbranch-skip { background: #ddd !important; color: #111; } + +span.cline-neutral { background: #eaeaea; } +.medium { background: #eaeaea; } + +.cover-fill, .cover-empty { + display:inline-block; + height: 12px; +} +.chart { + line-height: 0; +} +.cover-empty { + background: white; +} +.cover-full { + border-right: none !important; +} +pre.prettyprint { + border: none !important; + padding: 0 !important; + margin: 0 !important; +} +.com { color: #999 !important; } +.ignore-none { color: #999; font-weight: normal; } + +.wrapper { + min-height: 100%; + height: auto !important; + height: 100%; + margin: 0 auto -48px; +} +.footer, .push { + height: 48px; +} diff --git a/coverage/index.html b/coverage/index.html new file mode 100644 index 0000000..91daeca --- /dev/null +++ b/coverage/index.html @@ -0,0 +1,158 @@ +<!doctype html> +<html lang="en"> +<head> + <title>Code coverage report for All files</title> + <meta charset="utf-8" /> + <link rel="stylesheet" href="prettify.css" /> + <link rel="stylesheet" href="base.css" /> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <style type='text/css'> + .coverage-summary .sorter { + background-image: url(sort-arrow-sprite.png); + } + </style> +</head> +<body> +<div class='wrapper'> + <div class='pad1'> + <h1> + All files + </h1> + <div class='clearfix'> + <div class='fl pad1y space-right2'> + <span class="strong">53.92% </span> + <span class="quiet">Statements</span> + <span class='fraction'>172/319</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">46.56% </span> + <span class="quiet">Branches</span> + <span class='fraction'>61/131</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">45% </span> + <span class="quiet">Functions</span> + <span class='fraction'>27/60</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">54.78% </span> + <span class="quiet">Lines</span> + <span class='fraction'>172/314</span> + </div> + </div> + </div> + <div class='status-line medium'></div> +<div class="pad1"> +<table class="coverage-summary"> +<thead> +<tr> + <th data-col="file" data-fmt="html" data-html="true" class="file">File</th> + <th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th> + <th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th> + <th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th> + <th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th> + <th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th> + <th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th> + <th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th> + <th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th> + <th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th> +</tr> +</thead> +<tbody><tr> + <td class="file medium" data-value="webservice-pinsis"><a href="webservice-pinsis/index.html">webservice-pinsis</a></td> + <td data-value="62.5" class="pic medium"><div class="chart"><div class="cover-fill" style="width: 62%;"></div><div class="cover-empty" style="width:38%;"></div></div></td> + <td data-value="62.5" class="pct medium">62.5%</td> + <td data-value="96" class="abs medium">60/96</td> + <td data-value="62.96" class="pct medium">62.96%</td> + <td data-value="54" class="abs medium">34/54</td> + <td data-value="33.33" class="pct low">33.33%</td> + <td data-value="3" class="abs low">1/3</td> + <td data-value="62.5" class="pct medium">62.5%</td> + <td data-value="96" class="abs medium">60/96</td> + </tr> + +<tr> + <td class="file high" data-value="webservice-pinsis/db"><a href="webservice-pinsis/db/index.html">webservice-pinsis/db</a></td> + <td data-value="100" class="pic high"><div class="chart"><div class="cover-fill cover-full" style="width: 100%;"></div><div class="cover-empty" style="width:0%;"></div></div></td> + <td data-value="100" class="pct high">100%</td> + <td data-value="10" class="abs high">10/10</td> + <td data-value="50" class="pct medium">50%</td> + <td data-value="2" class="abs medium">1/2</td> + <td data-value="100" class="pct high">100%</td> + <td data-value="3" class="abs high">3/3</td> + <td data-value="100" class="pct high">100%</td> + <td data-value="10" class="abs high">10/10</td> + </tr> + +<tr> + <td class="file low" data-value="webservice-pinsis/lib"><a href="webservice-pinsis/lib/index.html">webservice-pinsis/lib</a></td> + <td data-value="41.67" class="pic low"><div class="chart"><div class="cover-fill" style="width: 41%;"></div><div class="cover-empty" style="width:59%;"></div></div></td> + <td data-value="41.67" class="pct low">41.67%</td> + <td data-value="72" class="abs low">30/72</td> + <td data-value="30.77" class="pct low">30.77%</td> + <td data-value="39" class="abs low">12/39</td> + <td data-value="33.33" class="pct low">33.33%</td> + <td data-value="9" class="abs low">3/9</td> + <td data-value="44.12" class="pct low">44.12%</td> + <td data-value="68" class="abs low">30/68</td> + </tr> + +<tr> + <td class="file low" data-value="webservice-pinsis/middleware"><a href="webservice-pinsis/middleware/index.html">webservice-pinsis/middleware</a></td> + <td data-value="44.44" class="pic low"><div class="chart"><div class="cover-fill" style="width: 44%;"></div><div class="cover-empty" style="width:56%;"></div></div></td> + <td data-value="44.44" class="pct low">44.44%</td> + <td data-value="90" class="abs low">40/90</td> + <td data-value="36.36" class="pct low">36.36%</td> + <td data-value="22" class="abs low">8/22</td> + <td data-value="38.71" class="pct low">38.71%</td> + <td data-value="31" class="abs low">12/31</td> + <td data-value="44.94" class="pct low">44.94%</td> + <td data-value="89" class="abs low">40/89</td> + </tr> + +<tr> + <td class="file medium" data-value="webservice-pinsis/routes"><a href="webservice-pinsis/routes/index.html">webservice-pinsis/routes</a></td> + <td data-value="59.57" class="pic medium"><div class="chart"><div class="cover-fill" style="width: 59%;"></div><div class="cover-empty" style="width:41%;"></div></div></td> + <td data-value="59.57" class="pct medium">59.57%</td> + <td data-value="47" class="abs medium">28/47</td> + <td data-value="42.86" class="pct low">42.86%</td> + <td data-value="14" class="abs low">6/14</td> + <td data-value="58.33" class="pct medium">58.33%</td> + <td data-value="12" class="abs medium">7/12</td> + <td data-value="59.57" class="pct medium">59.57%</td> + <td data-value="47" class="abs medium">28/47</td> + </tr> + +<tr> + <td class="file high" data-value="webservice-pinsis/validation"><a href="webservice-pinsis/validation/index.html">webservice-pinsis/validation</a></td> + <td data-value="100" class="pic high"><div class="chart"><div class="cover-fill cover-full" style="width: 100%;"></div><div class="cover-empty" style="width:0%;"></div></div></td> + <td data-value="100" class="pct high">100%</td> + <td data-value="4" class="abs high">4/4</td> + <td data-value="100" class="pct high">100%</td> + <td data-value="0" class="abs high">0/0</td> + <td data-value="50" class="pct medium">50%</td> + <td data-value="2" class="abs medium">1/2</td> + <td data-value="100" class="pct high">100%</td> + <td data-value="4" class="abs high">4/4</td> + </tr> + +</tbody> +</table> +</div><div class='push'></div><!-- for sticky footer --> +</div><!-- /wrapper --> +<div class='footer quiet pad2 space-top1 center small'> + Code coverage + generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu Aug 10 2017 11:42:01 GMT-0300 (BRT) +</div> +</div> +<script src="prettify.js"></script> +<script> +window.onload = function () { + if (typeof prettyPrint === 'function') { + prettyPrint(); + } +}; +</script> +<script src="sorter.js"></script> +</body> +</html> diff --git a/coverage/prettify.css b/coverage/prettify.css new file mode 100644 index 0000000..b317a7c --- /dev/null +++ b/coverage/prettify.css @@ -0,0 +1 @@ +.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} diff --git a/coverage/prettify.js b/coverage/prettify.js new file mode 100644 index 0000000..ef51e03 --- /dev/null +++ b/coverage/prettify.js @@ -0,0 +1 @@ +window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V<U;++V){var ae=Z[V];if(ae.ignoreCase){ac=true}else{if(/[a-z]/i.test(ae.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){S=true;ac=false;break}}}var Y={b:8,t:9,n:10,v:11,f:12,r:13};function ab(ah){var ag=ah.charCodeAt(0);if(ag!==92){return ag}var af=ah.charAt(1);ag=Y[af];if(ag){return ag}else{if("0"<=af&&af<="7"){return parseInt(ah.substring(1),8)}else{if(af==="u"||af==="x"){return parseInt(ah.substring(2),16)}else{return ah.charCodeAt(1)}}}}function T(af){if(af<32){return(af<16?"\\x0":"\\x")+af.toString(16)}var ag=String.fromCharCode(af);if(ag==="\\"||ag==="-"||ag==="["||ag==="]"){ag="\\"+ag}return ag}function X(am){var aq=am.substring(1,am.length-1).match(new RegExp("\\\\u[0-9A-Fa-f]{4}|\\\\x[0-9A-Fa-f]{2}|\\\\[0-3][0-7]{0,2}|\\\\[0-7]{1,2}|\\\\[\\s\\S]|-|[^-\\\\]","g"));var ak=[];var af=[];var ao=aq[0]==="^";for(var ar=ao?1:0,aj=aq.length;ar<aj;++ar){var ah=aq[ar];if(/\\[bdsw]/i.test(ah)){ak.push(ah)}else{var ag=ab(ah);var al;if(ar+2<aj&&"-"===aq[ar+1]){al=ab(aq[ar+2]);ar+=2}else{al=ag}af.push([ag,al]);if(!(al<65||ag>122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;ar<af.length;++ar){var at=af[ar];if(at[0]<=ap[1]+1){ap[1]=Math.max(ap[1],at[1])}else{ai.push(ap=at)}}var an=["["];if(ao){an.push("^")}an.push.apply(an,ak);for(var ar=0;ar<ai.length;++ar){var at=ai[ar];an.push(T(at[0]));if(at[1]>at[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak<ah;++ak){var ag=aj[ak];if(ag==="("){++am}else{if("\\"===ag.charAt(0)){var af=+ag.substring(1);if(af&&af<=am){an[af]=-1}}}}for(var ak=1;ak<an.length;++ak){if(-1===an[ak]){an[ak]=++ad}}for(var ak=0,am=0;ak<ah;++ak){var ag=aj[ak];if(ag==="("){++am;if(an[am]===undefined){aj[ak]="(?:"}}else{if("\\"===ag.charAt(0)){var af=+ag.substring(1);if(af&&af<=am){aj[ak]="\\"+an[am]}}}}for(var ak=0,am=0;ak<ah;++ak){if("^"===aj[ak]&&"^"!==aj[ak+1]){aj[ak]=""}}if(al.ignoreCase&&S){for(var ak=0;ak<ah;++ak){var ag=aj[ak];var ai=ag.charAt(0);if(ag.length>=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V<U;++V){var ae=Z[V];if(ae.global||ae.multiline){throw new Error(""+ae)}aa.push("(?:"+W(ae)+")")}return new RegExp(aa.join("|"),ac?"gi":"g")}function a(V){var U=/(?:^|\s)nocode(?:\s|$)/;var X=[];var T=0;var Z=[];var W=0;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=document.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Y=S&&"pre"===S.substring(0,3);function aa(ab){switch(ab.nodeType){case 1:if(U.test(ab.className)){return}for(var ae=ab.firstChild;ae;ae=ae.nextSibling){aa(ae)}var ad=ab.nodeName;if("BR"===ad||"LI"===ad){X[W]="\n";Z[W<<1]=T++;Z[(W++<<1)|1]=ab}break;case 3:case 4:var ac=ab.nodeValue;if(ac.length){if(!Y){ac=ac.replace(/[ \t\r\n]+/g," ")}else{ac=ac.replace(/\r\n?/g,"\n")}X[W]=ac;Z[W<<1]=T;T+=ac.length;Z[(W++<<1)|1]=ab}break}}aa(V);return{sourceCode:X.join("").replace(/\n$/,""),spans:Z}}function B(S,U,W,T){if(!U){return}var V={sourceCode:U,basePos:S};W(V);T.push.apply(T,V.decorations)}var v=/\S/;function o(S){var V=undefined;for(var U=S.firstChild;U;U=U.nextSibling){var T=U.nodeType;V=(T===1)?(V?S:U):(T===3)?(v.test(U.nodeValue)?S:V):V}return V===S?undefined:V}function g(U,T){var S={};var V;(function(){var ad=U.concat(T);var ah=[];var ag={};for(var ab=0,Z=ad.length;ab<Z;++ab){var Y=ad[ab];var ac=Y[3];if(ac){for(var ae=ac.length;--ae>=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae<aq;++ae){var ag=an[ae];var ap=aj[ag];var ai=void 0;var am;if(typeof ap==="string"){am=false}else{var aa=S[ag.charAt(0)];if(aa){ai=ag.match(aa[1]);ap=aa[0]}else{for(var ao=0;ao<X;++ao){aa=T[ao];ai=ag.match(aa[1]);if(ai){ap=aa[0];break}}if(!ai){ap=F}}am=ap.length>=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y<W.length;++Y){ae(W[Y])}if(ag===(ag|0)){W[0].setAttribute("value",ag)}var aa=ac.createElement("OL");aa.className="linenums";var X=Math.max(0,((ag-1))|0)||0;for(var Y=0,T=W.length;Y<T;++Y){af=W[Y];af.className="L"+((Y+X)%10);if(!af.firstChild){af.appendChild(ac.createTextNode("\xA0"))}aa.appendChild(af)}V.appendChild(aa)}function D(ac){var aj=/\bMSIE\b/.test(navigator.userAgent);var am=/\n/g;var al=ac.sourceCode;var an=al.length;var V=0;var aa=ac.spans;var T=aa.length;var ah=0;var X=ac.decorations;var Y=X.length;var Z=0;X[Y]=an;var ar,aq;for(aq=ar=0;aq<Y;){if(X[aq]!==X[aq+2]){X[ar++]=X[aq++];X[ar++]=X[aq++]}else{aq+=2}}Y=ar;for(aq=ar=0;aq<Y;){var at=X[aq];var ab=X[aq+1];var W=aq+2;while(W+2<=Y&&X[W+1]===ab){W+=2}X[ar++]=at;X[ar++]=ab;aq=W}Y=X.length=ar;var ae=null;while(ah<T){var af=aa[ah];var S=aa[ah+2]||an;var ag=X[Z];var ap=X[Z+2]||an;var W=Math.min(S,ap);var ak=aa[ah+1];var U;if(ak.nodeType!==1&&(U=al.substring(V,W))){if(aj){U=U.replace(am,"\r")}ak.nodeValue=U;var ai=ak.ownerDocument;var ao=ai.createElement("SPAN");ao.className=X[Z+1];var ad=ak.parentNode;ad.replaceChild(ao,ak);ao.appendChild(ak);if(V<S){aa[ah+1]=ak=ai.createTextNode(al.substring(W,S));ad.insertBefore(ak,ao.nextSibling)}}V=W;if(V>=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*</.test(S)?"default-markup":"default-code"}return t[T]}c(K,["default-code"]);c(g([],[[F,/^[^<?]+/],[E,/^<!\w[^>]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa<ac.length;++aa){for(var Z=0,V=ac[aa].length;Z<V;++Z){T.push(ac[aa][Z])}}ac=null;var W=Date;if(!W.now){W={now:function(){return +(new Date)}}}var X=0;var S;var ab=/\blang(?:uage)?-([\w.]+)(?!\S)/;var ae=/\bprettyprint\b/;function U(){var ag=(window.PR_SHOULD_USE_CONTINUATION?W.now()+250:Infinity);for(;X<T.length&&W.now()<ag;X++){var aj=T[X];var ai=aj.className;if(ai.indexOf("prettyprint")>=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X<T.length){setTimeout(U,250)}else{if(ad){ad()}}}U()}window.prettyPrintOne=y;window.prettyPrint=b;window.PR={createSimpleLexer:g,registerLangHandler:c,sourceDecorator:i,PR_ATTRIB_NAME:P,PR_ATTRIB_VALUE:n,PR_COMMENT:j,PR_DECLARATION:E,PR_KEYWORD:z,PR_LITERAL:G,PR_NOCODE:N,PR_PLAIN:F,PR_PUNCTUATION:L,PR_SOURCE:J,PR_STRING:C,PR_TAG:m,PR_TYPE:O}})();PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_DECLARATION,/^<!\w[^>]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^<xmp\b[^>]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^<script\b[^>]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^<script\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:<!--|-->)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); diff --git a/coverage/sort-arrow-sprite.png b/coverage/sort-arrow-sprite.png new file mode 100644 index 0000000000000000000000000000000000000000..03f704a609c6fd0dbfdac63466a7d7c958b5cbf3 GIT binary patch literal 209 zcmeAS@N?(olHy`uVBq!ia0vp^>_9Bd!3HEZxJ@+%Qj#UE5hcO-X(i=}MX3yqDfvmM z3ZA)%>8U}fi7AzZCsS>Jii$m5978H@?Fn+^JD|Y9yzj{W`447Gxa{7*dM7nnnD-Lb z6^}Hx2)<t4^o6Wx*F;wxHx}=5N#Su@S-w&C^o$MC9b5+$B=T4;r?cPm)%Fj&wd;}X zP9-IMj(10vstZN_m^jtm<9|ljB!x{5tE86~eE-nSz|0W&!@{XNS*HVNJ%gvKpUXO@ GgeCxf+epL! literal 0 HcmV?d00001 diff --git a/coverage/sorter.js b/coverage/sorter.js new file mode 100644 index 0000000..6c5034e --- /dev/null +++ b/coverage/sorter.js @@ -0,0 +1,158 @@ +var addSorting = (function () { + "use strict"; + var cols, + currentSort = { + index: 0, + desc: false + }; + + // returns the summary table element + function getTable() { return document.querySelector('.coverage-summary'); } + // returns the thead element of the summary table + function getTableHeader() { return getTable().querySelector('thead tr'); } + // returns the tbody element of the summary table + function getTableBody() { return getTable().querySelector('tbody'); } + // returns the th element for nth column + function getNthColumn(n) { return getTableHeader().querySelectorAll('th')[n]; } + + // loads all columns + function loadColumns() { + var colNodes = getTableHeader().querySelectorAll('th'), + colNode, + cols = [], + col, + i; + + for (i = 0; i < colNodes.length; i += 1) { + colNode = colNodes[i]; + col = { + key: colNode.getAttribute('data-col'), + sortable: !colNode.getAttribute('data-nosort'), + type: colNode.getAttribute('data-type') || 'string' + }; + cols.push(col); + if (col.sortable) { + col.defaultDescSort = col.type === 'number'; + colNode.innerHTML = colNode.innerHTML + '<span class="sorter"></span>'; + } + } + return cols; + } + // attaches a data attribute to every tr element with an object + // of data values keyed by column name + function loadRowData(tableRow) { + var tableCols = tableRow.querySelectorAll('td'), + colNode, + col, + data = {}, + i, + val; + for (i = 0; i < tableCols.length; i += 1) { + colNode = tableCols[i]; + col = cols[i]; + val = colNode.getAttribute('data-value'); + if (col.type === 'number') { + val = Number(val); + } + data[col.key] = val; + } + return data; + } + // loads all row data + function loadData() { + var rows = getTableBody().querySelectorAll('tr'), + i; + + for (i = 0; i < rows.length; i += 1) { + rows[i].data = loadRowData(rows[i]); + } + } + // sorts the table using the data for the ith column + function sortByIndex(index, desc) { + var key = cols[index].key, + sorter = function (a, b) { + a = a.data[key]; + b = b.data[key]; + return a < b ? -1 : a > b ? 1 : 0; + }, + finalSorter = sorter, + tableBody = document.querySelector('.coverage-summary tbody'), + rowNodes = tableBody.querySelectorAll('tr'), + rows = [], + i; + + if (desc) { + finalSorter = function (a, b) { + return -1 * sorter(a, b); + }; + } + + for (i = 0; i < rowNodes.length; i += 1) { + rows.push(rowNodes[i]); + tableBody.removeChild(rowNodes[i]); + } + + rows.sort(finalSorter); + + for (i = 0; i < rows.length; i += 1) { + tableBody.appendChild(rows[i]); + } + } + // removes sort indicators for current column being sorted + function removeSortIndicators() { + var col = getNthColumn(currentSort.index), + cls = col.className; + + cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); + col.className = cls; + } + // adds sort indicators for current column being sorted + function addSortIndicators() { + getNthColumn(currentSort.index).className += currentSort.desc ? ' sorted-desc' : ' sorted'; + } + // adds event listeners for all sorter widgets + function enableUI() { + var i, + el, + ithSorter = function ithSorter(i) { + var col = cols[i]; + + return function () { + var desc = col.defaultDescSort; + + if (currentSort.index === i) { + desc = !currentSort.desc; + } + sortByIndex(i, desc); + removeSortIndicators(); + currentSort.index = i; + currentSort.desc = desc; + addSortIndicators(); + }; + }; + for (i =0 ; i < cols.length; i += 1) { + if (cols[i].sortable) { + // add the click event handler on the th so users + // dont have to click on those tiny arrows + el = getNthColumn(i).querySelector('.sorter').parentElement; + if (el.addEventListener) { + el.addEventListener('click', ithSorter(i)); + } else { + el.attachEvent('onclick', ithSorter(i)); + } + } + } + } + // adds sorting functionality to the UI + return function () { + if (!getTable()) { + return; + } + cols = loadColumns(); + loadData(cols); + addSortIndicators(); + enableUI(); + }; +})(); + +window.addEventListener('load', addSorting); diff --git a/coverage/webservice-pinsis/config.js.html b/coverage/webservice-pinsis/config.js.html new file mode 100644 index 0000000..a1d5a97 --- /dev/null +++ b/coverage/webservice-pinsis/config.js.html @@ -0,0 +1,104 @@ +<!doctype html> +<html lang="en"> +<head> + <title>Code coverage report for webservice-pinsis/config.js</title> + <meta charset="utf-8" /> + <link rel="stylesheet" href="../prettify.css" /> + <link rel="stylesheet" href="../base.css" /> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <style type='text/css'> + .coverage-summary .sorter { + background-image: url(../sort-arrow-sprite.png); + } + </style> +</head> +<body> +<div class='wrapper'> + <div class='pad1'> + <h1> + <a href="../index.html">All files</a> / <a href="index.html">webservice-pinsis</a> config.js + </h1> + <div class='clearfix'> + <div class='fl pad1y space-right2'> + <span class="strong">100% </span> + <span class="quiet">Statements</span> + <span class='fraction'>4/4</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">100% </span> + <span class="quiet">Branches</span> + <span class='fraction'>0/0</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">100% </span> + <span class="quiet">Functions</span> + <span class='fraction'>0/0</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">100% </span> + <span class="quiet">Lines</span> + <span class='fraction'>4/4</span> + </div> + </div> + </div> + <div class='status-line high'></div> +<pre><table class="coverage"> +<tr><td class="line-count quiet">1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14</td><td class="line-coverage quiet"><span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">var config = module.exports = {}; + +config.db_config = { + user: 'user', + password: 'password', + database: 'dbname', + host: 'localhost', + port: 5432 +}; + +config.fqdn = 'pinsis.c3sl.ufpr.br'; + +config.agentVersion = 0.0; + </pre></td></tr> +</table></pre> +<div class='push'></div><!-- for sticky footer --> +</div><!-- /wrapper --> +<div class='footer quiet pad2 space-top1 center small'> + Code coverage + generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu Aug 10 2017 11:42:01 GMT-0300 (BRT) +</div> +</div> +<script src="../prettify.js"></script> +<script> +window.onload = function () { + if (typeof prettyPrint === 'function') { + prettyPrint(); + } +}; +</script> +<script src="../sorter.js"></script> +</body> +</html> diff --git a/coverage/webservice-pinsis/db/index.html b/coverage/webservice-pinsis/db/index.html new file mode 100644 index 0000000..5958eca --- /dev/null +++ b/coverage/webservice-pinsis/db/index.html @@ -0,0 +1,93 @@ +<!doctype html> +<html lang="en"> +<head> + <title>Code coverage report for webservice-pinsis/db</title> + <meta charset="utf-8" /> + <link rel="stylesheet" href="../../prettify.css" /> + <link rel="stylesheet" href="../../base.css" /> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <style type='text/css'> + .coverage-summary .sorter { + background-image: url(../../sort-arrow-sprite.png); + } + </style> +</head> +<body> +<div class='wrapper'> + <div class='pad1'> + <h1> + <a href="../../index.html">All files</a> webservice-pinsis/db + </h1> + <div class='clearfix'> + <div class='fl pad1y space-right2'> + <span class="strong">100% </span> + <span class="quiet">Statements</span> + <span class='fraction'>10/10</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">50% </span> + <span class="quiet">Branches</span> + <span class='fraction'>1/2</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">100% </span> + <span class="quiet">Functions</span> + <span class='fraction'>3/3</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">100% </span> + <span class="quiet">Lines</span> + <span class='fraction'>10/10</span> + </div> + </div> + </div> + <div class='status-line high'></div> +<div class="pad1"> +<table class="coverage-summary"> +<thead> +<tr> + <th data-col="file" data-fmt="html" data-html="true" class="file">File</th> + <th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th> + <th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th> + <th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th> + <th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th> + <th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th> + <th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th> + <th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th> + <th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th> + <th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th> +</tr> +</thead> +<tbody><tr> + <td class="file high" data-value="query_builder.js"><a href="query_builder.js.html">query_builder.js</a></td> + <td data-value="100" class="pic high"><div class="chart"><div class="cover-fill cover-full" style="width: 100%;"></div><div class="cover-empty" style="width:0%;"></div></div></td> + <td data-value="100" class="pct high">100%</td> + <td data-value="10" class="abs high">10/10</td> + <td data-value="50" class="pct medium">50%</td> + <td data-value="2" class="abs medium">1/2</td> + <td data-value="100" class="pct high">100%</td> + <td data-value="3" class="abs high">3/3</td> + <td data-value="100" class="pct high">100%</td> + <td data-value="10" class="abs high">10/10</td> + </tr> + +</tbody> +</table> +</div><div class='push'></div><!-- for sticky footer --> +</div><!-- /wrapper --> +<div class='footer quiet pad2 space-top1 center small'> + Code coverage + generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu Aug 10 2017 11:42:01 GMT-0300 (BRT) +</div> +</div> +<script src="../../prettify.js"></script> +<script> +window.onload = function () { + if (typeof prettyPrint === 'function') { + prettyPrint(); + } +}; +</script> +<script src="../../sorter.js"></script> +</body> +</html> diff --git a/coverage/webservice-pinsis/db/query_builder.js.html b/coverage/webservice-pinsis/db/query_builder.js.html new file mode 100644 index 0000000..7f94df1 --- /dev/null +++ b/coverage/webservice-pinsis/db/query_builder.js.html @@ -0,0 +1,128 @@ +<!doctype html> +<html lang="en"> +<head> + <title>Code coverage report for webservice-pinsis/db/query_builder.js</title> + <meta charset="utf-8" /> + <link rel="stylesheet" href="../../prettify.css" /> + <link rel="stylesheet" href="../../base.css" /> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <style type='text/css'> + .coverage-summary .sorter { + background-image: url(../../sort-arrow-sprite.png); + } + </style> +</head> +<body> +<div class='wrapper'> + <div class='pad1'> + <h1> + <a href="../../index.html">All files</a> / <a href="index.html">webservice-pinsis/db</a> query_builder.js + </h1> + <div class='clearfix'> + <div class='fl pad1y space-right2'> + <span class="strong">100% </span> + <span class="quiet">Statements</span> + <span class='fraction'>10/10</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">50% </span> + <span class="quiet">Branches</span> + <span class='fraction'>1/2</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">100% </span> + <span class="quiet">Functions</span> + <span class='fraction'>3/3</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">100% </span> + <span class="quiet">Lines</span> + <span class='fraction'>10/10</span> + </div> + </div> + </div> + <div class='status-line high'></div> +<pre><table class="coverage"> +<tr><td class="line-count quiet">1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22</td><td class="line-coverage quiet"><span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">14x</span> +<span class="cline-any cline-yes">14x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">module.exports = function(){ + + squel = require("squel").useFlavour('postgres'); + + + return { + set_from_attr : function (query, obj){ + for (var property in obj) { + <span class="missing-if-branch" title="else path not taken" >E</span>if (obj.hasOwnProperty(property)) { + query.set(property, obj[property]); + } + } + return query; + }, + insert: function (table, obj){ + var q = squel.insert().into(table); + this.set_from_attr(q, obj); + return q; + } + } +} + </pre></td></tr> +</table></pre> +<div class='push'></div><!-- for sticky footer --> +</div><!-- /wrapper --> +<div class='footer quiet pad2 space-top1 center small'> + Code coverage + generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu Aug 10 2017 11:42:01 GMT-0300 (BRT) +</div> +</div> +<script src="../../prettify.js"></script> +<script> +window.onload = function () { + if (typeof prettyPrint === 'function') { + prettyPrint(); + } +}; +</script> +<script src="../../sorter.js"></script> +</body> +</html> diff --git a/coverage/webservice-pinsis/index.html b/coverage/webservice-pinsis/index.html new file mode 100644 index 0000000..4ca13fb --- /dev/null +++ b/coverage/webservice-pinsis/index.html @@ -0,0 +1,106 @@ +<!doctype html> +<html lang="en"> +<head> + <title>Code coverage report for webservice-pinsis</title> + <meta charset="utf-8" /> + <link rel="stylesheet" href="../prettify.css" /> + <link rel="stylesheet" href="../base.css" /> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <style type='text/css'> + .coverage-summary .sorter { + background-image: url(../sort-arrow-sprite.png); + } + </style> +</head> +<body> +<div class='wrapper'> + <div class='pad1'> + <h1> + <a href="../index.html">All files</a> webservice-pinsis + </h1> + <div class='clearfix'> + <div class='fl pad1y space-right2'> + <span class="strong">62.5% </span> + <span class="quiet">Statements</span> + <span class='fraction'>60/96</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">62.96% </span> + <span class="quiet">Branches</span> + <span class='fraction'>34/54</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">33.33% </span> + <span class="quiet">Functions</span> + <span class='fraction'>1/3</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">62.5% </span> + <span class="quiet">Lines</span> + <span class='fraction'>60/96</span> + </div> + </div> + </div> + <div class='status-line medium'></div> +<div class="pad1"> +<table class="coverage-summary"> +<thead> +<tr> + <th data-col="file" data-fmt="html" data-html="true" class="file">File</th> + <th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th> + <th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th> + <th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th> + <th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th> + <th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th> + <th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th> + <th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th> + <th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th> + <th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th> +</tr> +</thead> +<tbody><tr> + <td class="file high" data-value="config.js"><a href="config.js.html">config.js</a></td> + <td data-value="100" class="pic high"><div class="chart"><div class="cover-fill cover-full" style="width: 100%;"></div><div class="cover-empty" style="width:0%;"></div></div></td> + <td data-value="100" class="pct high">100%</td> + <td data-value="4" class="abs high">4/4</td> + <td data-value="100" class="pct high">100%</td> + <td data-value="0" class="abs high">0/0</td> + <td data-value="100" class="pct high">100%</td> + <td data-value="0" class="abs high">0/0</td> + <td data-value="100" class="pct high">100%</td> + <td data-value="4" class="abs high">4/4</td> + </tr> + +<tr> + <td class="file medium" data-value="server.js"><a href="server.js.html">server.js</a></td> + <td data-value="60.87" class="pic medium"><div class="chart"><div class="cover-fill" style="width: 60%;"></div><div class="cover-empty" style="width:40%;"></div></div></td> + <td data-value="60.87" class="pct medium">60.87%</td> + <td data-value="92" class="abs medium">56/92</td> + <td data-value="62.96" class="pct medium">62.96%</td> + <td data-value="54" class="abs medium">34/54</td> + <td data-value="33.33" class="pct low">33.33%</td> + <td data-value="3" class="abs low">1/3</td> + <td data-value="60.87" class="pct medium">60.87%</td> + <td data-value="92" class="abs medium">56/92</td> + </tr> + +</tbody> +</table> +</div><div class='push'></div><!-- for sticky footer --> +</div><!-- /wrapper --> +<div class='footer quiet pad2 space-top1 center small'> + Code coverage + generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu Aug 10 2017 11:42:01 GMT-0300 (BRT) +</div> +</div> +<script src="../prettify.js"></script> +<script> +window.onload = function () { + if (typeof prettyPrint === 'function') { + prettyPrint(); + } +}; +</script> +<script src="../sorter.js"></script> +</body> +</html> diff --git a/coverage/webservice-pinsis/lib/index.html b/coverage/webservice-pinsis/lib/index.html new file mode 100644 index 0000000..287459f --- /dev/null +++ b/coverage/webservice-pinsis/lib/index.html @@ -0,0 +1,106 @@ +<!doctype html> +<html lang="en"> +<head> + <title>Code coverage report for webservice-pinsis/lib</title> + <meta charset="utf-8" /> + <link rel="stylesheet" href="../../prettify.css" /> + <link rel="stylesheet" href="../../base.css" /> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <style type='text/css'> + .coverage-summary .sorter { + background-image: url(../../sort-arrow-sprite.png); + } + </style> +</head> +<body> +<div class='wrapper'> + <div class='pad1'> + <h1> + <a href="../../index.html">All files</a> webservice-pinsis/lib + </h1> + <div class='clearfix'> + <div class='fl pad1y space-right2'> + <span class="strong">41.67% </span> + <span class="quiet">Statements</span> + <span class='fraction'>30/72</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">30.77% </span> + <span class="quiet">Branches</span> + <span class='fraction'>12/39</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">33.33% </span> + <span class="quiet">Functions</span> + <span class='fraction'>3/9</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">44.12% </span> + <span class="quiet">Lines</span> + <span class='fraction'>30/68</span> + </div> + </div> + </div> + <div class='status-line low'></div> +<div class="pad1"> +<table class="coverage-summary"> +<thead> +<tr> + <th data-col="file" data-fmt="html" data-html="true" class="file">File</th> + <th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th> + <th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th> + <th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th> + <th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th> + <th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th> + <th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th> + <th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th> + <th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th> + <th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th> +</tr> +</thead> +<tbody><tr> + <td class="file medium" data-value="logger.js"><a href="logger.js.html">logger.js</a></td> + <td data-value="78.13" class="pic medium"><div class="chart"><div class="cover-fill" style="width: 78%;"></div><div class="cover-empty" style="width:22%;"></div></div></td> + <td data-value="78.13" class="pct medium">78.13%</td> + <td data-value="32" class="abs medium">25/32</td> + <td data-value="57.14" class="pct medium">57.14%</td> + <td data-value="21" class="abs medium">12/21</td> + <td data-value="75" class="pct medium">75%</td> + <td data-value="4" class="abs medium">3/4</td> + <td data-value="78.13" class="pct medium">78.13%</td> + <td data-value="32" class="abs medium">25/32</td> + </tr> + +<tr> + <td class="file low" data-value="utils.js"><a href="utils.js.html">utils.js</a></td> + <td data-value="12.5" class="pic low"><div class="chart"><div class="cover-fill" style="width: 12%;"></div><div class="cover-empty" style="width:88%;"></div></div></td> + <td data-value="12.5" class="pct low">12.5%</td> + <td data-value="40" class="abs low">5/40</td> + <td data-value="0" class="pct low">0%</td> + <td data-value="18" class="abs low">0/18</td> + <td data-value="0" class="pct low">0%</td> + <td data-value="5" class="abs low">0/5</td> + <td data-value="13.89" class="pct low">13.89%</td> + <td data-value="36" class="abs low">5/36</td> + </tr> + +</tbody> +</table> +</div><div class='push'></div><!-- for sticky footer --> +</div><!-- /wrapper --> +<div class='footer quiet pad2 space-top1 center small'> + Code coverage + generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu Aug 10 2017 11:42:01 GMT-0300 (BRT) +</div> +</div> +<script src="../../prettify.js"></script> +<script> +window.onload = function () { + if (typeof prettyPrint === 'function') { + prettyPrint(); + } +}; +</script> +<script src="../../sorter.js"></script> +</body> +</html> diff --git a/coverage/webservice-pinsis/lib/logger.js.html b/coverage/webservice-pinsis/lib/logger.js.html new file mode 100644 index 0000000..c1fbb67 --- /dev/null +++ b/coverage/webservice-pinsis/lib/logger.js.html @@ -0,0 +1,476 @@ +<!doctype html> +<html lang="en"> +<head> + <title>Code coverage report for webservice-pinsis/lib/logger.js</title> + <meta charset="utf-8" /> + <link rel="stylesheet" href="../../prettify.css" /> + <link rel="stylesheet" href="../../base.css" /> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <style type='text/css'> + .coverage-summary .sorter { + background-image: url(../../sort-arrow-sprite.png); + } + </style> +</head> +<body> +<div class='wrapper'> + <div class='pad1'> + <h1> + <a href="../../index.html">All files</a> / <a href="index.html">webservice-pinsis/lib</a> logger.js + </h1> + <div class='clearfix'> + <div class='fl pad1y space-right2'> + <span class="strong">78.13% </span> + <span class="quiet">Statements</span> + <span class='fraction'>25/32</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">57.14% </span> + <span class="quiet">Branches</span> + <span class='fraction'>12/21</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">75% </span> + <span class="quiet">Functions</span> + <span class='fraction'>3/4</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">78.13% </span> + <span class="quiet">Lines</span> + <span class='fraction'>25/32</span> + </div> + </div> + </div> + <div class='status-line medium'></div> +<pre><table class="coverage"> +<tr><td class="line-count quiet">1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138</td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">/* + * Copyright (C) 2012 Centro de Computacao Cientifica e Software Livre + * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR + * + * This file is part of simmc + * + * simmc is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + */ + + +var os = require('os'); +var cluster = require('cluster'); +var bunyan = require('bunyan'); +var cuid = require('cuid'); +var fs = require('fs'); + +// Serialize a request (remove unuseful information from requests, +// log only the necessary). +function requestSerializer(req) { + <span class="missing-if-branch" title="if path not taken" >I</span>if ((typeof(req) !== 'object') || (req === null)) { +<span class="cstat-no" title="statement not covered" > return req;</span> + } + + var headers = req.headers || <span class="branch-1 cbranch-no" title="branch not covered" >{};</span> + + return { + method: req.method, + url: req.url, + headers: { // selective choice of headers (no cookies) + "host": headers["host"], + "connection": headers["connection"], + "cache-control": headers["cache-control"], + "accept": headers["accept"], + "user-agent": headers["user-agent"], + "referer": headers["referer"], + "accept-encoding": headers["accept-encoding"], + "accept-language": headers["accept-language"] + }, + remoteAddress: req.ips[0] || req.ip || <span class="branch-2 cbranch-no" title="branch not covered" >null</span> + }; +} + +// Serialize a reponse (remove unuseful information from responses +// and calculate the reponse time). +function responseSerializer(res) { + <span class="missing-if-branch" title="if path not taken" >I</span>if ((typeof(res) !== 'object') || (res === null)) { +<span class="cstat-no" title="statement not covered" > return res;</span> + } + + // Calculate the response time + var responseTime; + <span class="missing-if-branch" title="else path not taken" >E</span>if (res.start) { + responseTime = (new Date() - res.start).toString() + " ms"; + } + + return { + statusCode: res.statusCode, + responseTime: responseTime + } +} + +// Make sure the logs dir exist +try { + fs.mkdirSync('logs'); +} +catch (e) { + <span class="missing-if-branch" title="if path not taken" >I</span>if ( e.code != 'EEXIST' ) +<span class="cstat-no" title="statement not covered" > throw e;</span> +} + +// Create the default logger +var defaultLogger = bunyan.createLogger({ + name: 'default', + streams: [{ + level: "info", + type: 'file', + path: 'logs/default.log', + }, + { + level: "debug", + type: 'file', + path: 'logs/debug.log', + }], + serializers: { + req: requestSerializer, + res: responseSerializer + } +}); +<span class="missing-if-branch" title="if path not taken" >I</span>if (!cluster.isMaster) { +<span class="cstat-no" title="statement not covered" > defaultLogger = defaultLogger.child({ worker: cluster.worker.id });</span> +} + +// Export the default logger +exports.default = defaultLogger; + +// Export the access logger (log express requests) +exports.expressAccess = function (req, res, next) { + // insert the current time into the response + // (for later calculation of reponse time). + res.start = new Date(); + + // Insert a log object into the request. + // The routes can use this object to log messages and all + // of them can be traced to the request (by req_id). + req.log = defaultLogger.child({ req_id: cuid.slug() }); + + // Log the request + req.log.debug({req: req}, 'request'); + + // Continue to the next handler + next(); + + // Log the response + req.log.debug({res: res}, 'response'); +} + +// Export the express error logger (log errors during request processing) +exports.expressError = <span class="fstat-no" title="function not covered" >fu</span>nction (err, req, res, next) { +<span class="cstat-no" title="statement not covered" > if (err) {</span> +<span class="cstat-no" title="statement not covered" > defaultLogger.error({err: err}, 'Error while processing request');</span> + } + +<span class="cstat-no" title="statement not covered" > next();</span> +} + </pre></td></tr> +</table></pre> +<div class='push'></div><!-- for sticky footer --> +</div><!-- /wrapper --> +<div class='footer quiet pad2 space-top1 center small'> + Code coverage + generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu Aug 10 2017 11:42:01 GMT-0300 (BRT) +</div> +</div> +<script src="../../prettify.js"></script> +<script> +window.onload = function () { + if (typeof prettyPrint === 'function') { + prettyPrint(); + } +}; +</script> +<script src="../../sorter.js"></script> +</body> +</html> diff --git a/coverage/webservice-pinsis/lib/utils.js.html b/coverage/webservice-pinsis/lib/utils.js.html new file mode 100644 index 0000000..3d7757d --- /dev/null +++ b/coverage/webservice-pinsis/lib/utils.js.html @@ -0,0 +1,329 @@ +<!doctype html> +<html lang="en"> +<head> + <title>Code coverage report for webservice-pinsis/lib/utils.js</title> + <meta charset="utf-8" /> + <link rel="stylesheet" href="../../prettify.css" /> + <link rel="stylesheet" href="../../base.css" /> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <style type='text/css'> + .coverage-summary .sorter { + background-image: url(../../sort-arrow-sprite.png); + } + </style> +</head> +<body> +<div class='wrapper'> + <div class='pad1'> + <h1> + <a href="../../index.html">All files</a> / <a href="index.html">webservice-pinsis/lib</a> utils.js + </h1> + <div class='clearfix'> + <div class='fl pad1y space-right2'> + <span class="strong">12.5% </span> + <span class="quiet">Statements</span> + <span class='fraction'>5/40</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">0% </span> + <span class="quiet">Branches</span> + <span class='fraction'>0/18</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">0% </span> + <span class="quiet">Functions</span> + <span class='fraction'>0/5</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">13.89% </span> + <span class="quiet">Lines</span> + <span class='fraction'>5/36</span> + </div> + </div> + </div> + <div class='status-line low'></div> +<pre><table class="coverage"> +<tr><td class="line-count quiet">1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89</td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">/* + * Copyright (C) 2012 Centro de Computacao Cientifica e Software Livre + * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR + * + * This file is part of simmc + * + * simmc is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + */ + +var crypto = require('crypto'); + +// Returns a filename starting with prefix (if not null) plus a md5-hash +// representing the obj given as argument, with "ext" as extension. +exports.hashFilename = <span class="fstat-no" title="function not covered" >fu</span>nction(prefix, obj, ext) { + var txt = <span class="cstat-no" title="statement not covered" >"";</span> +<span class="cstat-no" title="statement not covered" > for (i in obj) {</span> +<span class="cstat-no" title="statement not covered" > txt += i + obj[i]</span> + } + var hash = <span class="cstat-no" title="statement not covered" >crypto.createHash('md5').update(txt).digest('hex');</span> +<span class="cstat-no" title="statement not covered" > return (prefix? prefix + '_' + hash : hash) + '.' + ext;</span> +}; + +// returns a filename in the format: type project_date(day+month+year+'_'+hours+minutes).ext +exports.reportFilename = <span class="fstat-no" title="function not covered" >fu</span>nction(prefix, ext) { + var date = <span class="cstat-no" title="statement not covered" >formatDateReport(new Date());</span> +<span class="cstat-no" title="statement not covered" > return prefix+ '_'+ date + '.' + ext;</span> +}; + +// returns the date in the format day+month+year_hours+minutes +function <span class="fstat-no" title="function not covered" >formatDateReport(</span>date) { + var day = <span class="cstat-no" title="statement not covered" >date.getUTCDate(),</span> + month = <span class="cstat-no" title="statement not covered" >date.getUTCMonth() + 1,</span> //Months are zero based + year = <span class="cstat-no" title="statement not covered" >date.getUTCFullYear(),</span> + hours = <span class="cstat-no" title="statement not covered" >date.getHours(),</span> + minutes = <span class="cstat-no" title="statement not covered" >date.getMinutes();</span> + +<span class="cstat-no" title="statement not covered" > if (day < 10) <span class="cstat-no" title="statement not covered" >day = '0' + day;</span></span> +<span class="cstat-no" title="statement not covered" > if (month < 10) <span class="cstat-no" title="statement not covered" >month = '0' + month;</span></span> +<span class="cstat-no" title="statement not covered" > if (hours < 10) <span class="cstat-no" title="statement not covered" >hours = '0' + hours;</span></span> +<span class="cstat-no" title="statement not covered" > if (minutes < 10) <span class="cstat-no" title="statement not covered" >minutes = '0' + minutes;</span></span> + +<span class="cstat-no" title="statement not covered" > return day + month + year + '_' + hours + minutes;</span> +} + + +// returns the sum of every element in a array or object +exports.sum = <span class="fstat-no" title="function not covered" >fu</span>nction(x) { + var total = <span class="cstat-no" title="statement not covered" >0;</span> +<span class="cstat-no" title="statement not covered" > if (x.constructor == Array) {</span> +<span class="cstat-no" title="statement not covered" > for (var i=0; i<x.length; i++) {</span> +<span class="cstat-no" title="statement not covered" > total += x[i];</span> + } + } else { +<span class="cstat-no" title="statement not covered" > for (var i in x) {</span> +<span class="cstat-no" title="statement not covered" > total += x[i];</span> + } + } +<span class="cstat-no" title="statement not covered" > return total;</span> +} + +exports.checkEmail = <span class="fstat-no" title="function not covered" >fu</span>nction(email) { +<span class="cstat-no" title="statement not covered" > if (email.length < 4) {</span> +<span class="cstat-no" title="statement not covered" > return "Email deve conter pelo menos 4 caracteres.";</span> + } + +<span class="cstat-no" title="statement not covered" > if (email.length > 255) {</span> +<span class="cstat-no" title="statement not covered" > return "Email deve conter no máximo 255 caracteres.";</span> + } + +<span class="cstat-no" title="statement not covered" > if (!email.match(/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/)) {</span> +<span class="cstat-no" title="statement not covered" > return "Email não está em um formato válido.";</span> + } + +<span class="cstat-no" title="statement not covered" > return false;</span> +} + </pre></td></tr> +</table></pre> +<div class='push'></div><!-- for sticky footer --> +</div><!-- /wrapper --> +<div class='footer quiet pad2 space-top1 center small'> + Code coverage + generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu Aug 10 2017 11:42:01 GMT-0300 (BRT) +</div> +</div> +<script src="../../prettify.js"></script> +<script> +window.onload = function () { + if (typeof prettyPrint === 'function') { + prettyPrint(); + } +}; +</script> +<script src="../../sorter.js"></script> +</body> +</html> diff --git a/coverage/webservice-pinsis/middleware/db.js.html b/coverage/webservice-pinsis/middleware/db.js.html new file mode 100644 index 0000000..87c99d4 --- /dev/null +++ b/coverage/webservice-pinsis/middleware/db.js.html @@ -0,0 +1,569 @@ +<!doctype html> +<html lang="en"> +<head> + <title>Code coverage report for webservice-pinsis/middleware/db.js</title> + <meta charset="utf-8" /> + <link rel="stylesheet" href="../../prettify.css" /> + <link rel="stylesheet" href="../../base.css" /> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <style type='text/css'> + .coverage-summary .sorter { + background-image: url(../../sort-arrow-sprite.png); + } + </style> +</head> +<body> +<div class='wrapper'> + <div class='pad1'> + <h1> + <a href="../../index.html">All files</a> / <a href="index.html">webservice-pinsis/middleware</a> db.js + </h1> + <div class='clearfix'> + <div class='fl pad1y space-right2'> + <span class="strong">44.44% </span> + <span class="quiet">Statements</span> + <span class='fraction'>40/90</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">36.36% </span> + <span class="quiet">Branches</span> + <span class='fraction'>8/22</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">38.71% </span> + <span class="quiet">Functions</span> + <span class='fraction'>12/31</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">44.94% </span> + <span class="quiet">Lines</span> + <span class='fraction'>40/89</span> + </div> + </div> + </div> + <div class='status-line low'></div> +<pre><table class="coverage"> +<tr><td class="line-count quiet">1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169</td><td class="line-coverage quiet"><span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">3x</span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">3x</span> +<span class="cline-any cline-yes">2x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">var pg = require('pg'), + copyFrom = require('pg-copy-streams').from, + fs = require('fs'), + _ = require('lodash'); + +var tokenPattern = /\$[a-zA-Z]([a-zA-Z0-9_]*)\b/g; + +function <span class="fstat-no" title="function not covered" >numericFromNamed(</span>sql, parameters) { + var fillableTokens = <span class="cstat-no" title="statement not covered" >Object.keys(parameters);</span> + + var matchedTokens = <span class="cstat-no" title="statement not covered" >_.uniq(_.map(sql.match(tokenPattern), <span class="fstat-no" title="function not covered" >fu</span>nction (token) {</span> +<span class="cstat-no" title="statement not covered" > return token.substring(1); </span>// Remove leading dollar sign + })); + + var fillTokens = <span class="cstat-no" title="statement not covered" >_.intersection(fillableTokens, matchedTokens).sort();</span> + var fillValues = <span class="cstat-no" title="statement not covered" >_.map(fillTokens, <span class="fstat-no" title="function not covered" >fu</span>nction (token) {</span> +<span class="cstat-no" title="statement not covered" > return parameters[token];</span> + }); + + var unmatchedTokens = <span class="cstat-no" title="statement not covered" >_.difference(matchedTokens, fillableTokens);</span> + +<span class="cstat-no" title="statement not covered" > if (unmatchedTokens.length) {</span> + var missing = <span class="cstat-no" title="statement not covered" >unmatchedTokens.join(", ");</span> +<span class="cstat-no" title="statement not covered" > throw new Error("Missing Parameters: " + missing);</span> + } + + var interpolatedSql = <span class="cstat-no" title="statement not covered" >_.reduce(fillTokens, <span class="fstat-no" title="function not covered" >fu</span>nction (partiallyInterpolated, token, index) {</span> + var replaceAllPattern = <span class="cstat-no" title="statement not covered" >new RegExp('\\$' + fillTokens[index] + '\\b', "g");</span> +<span class="cstat-no" title="statement not covered" > return partiallyInterpolated.replace(replaceAllPattern, '$' + (index+1));</span> + }, sql); + + var out = <span class="cstat-no" title="statement not covered" >{};</span> +<span class="cstat-no" title="statement not covered" > out.sql = interpolatedSql;</span> +<span class="cstat-no" title="statement not covered" > out.values = fillValues;</span> + +<span class="cstat-no" title="statement not covered" > return out;</span> +} + +function namedPatch(client) { + var originalQuery = client.query; + + <span class="missing-if-branch" title="if path not taken" >I</span>if (originalQuery.patched) <span class="cstat-no" title="statement not covered" >return client;</span> + + originalQuery = originalQuery.bind(client); + + var patchedQuery = function(config, values, callback) { + <span class="missing-if-branch" title="if path not taken" >I</span>if (arguments.length === 1) { +<span class="cstat-no" title="statement not covered" > return originalQuery(config);</span> + } + else if (arguments.length === 2 && _.isFunction(values)) { + return originalQuery(config, values); + } + else <span class="missing-if-branch" title="else path not taken" >E</span>if (_.isArray(values)) { + return originalQuery(config, values, callback); + } else { + var reparameterized = <span class="cstat-no" title="statement not covered" >numericFromNamed(config, values);</span> +<span class="cstat-no" title="statement not covered" > return originalQuery(reparameterized.sql, reparameterized.values, callback);</span> + } + }; + + client.query = patchedQuery; + client.query.patched = true; + + return client; +} + +exports.pool = function (config) { + return function (req, res, next) { + req.db = { + connect: function (callback) { + pg.on('error', <span class="fstat-no" title="function not covered" >fu</span>nction(err) { +<span class="cstat-no" title="statement not covered" > return;</span> + }); + pg.connect(config, function (err, client, done) { + <span class="missing-if-branch" title="if path not taken" >I</span>if (err) { +<span class="cstat-no" title="statement not covered" > setTimeout(req.db.connect, 5000, callback);</span> +<span class="cstat-no" title="statement not covered" > return;</span> + } + + namedPatch(client); + callback(null, new Connection(client), done); + }); + } + }; + + next(); + }; +}; + +function Connection(client) { + this.query = function (query, params, callback) { + return client.query(query, params, callback); + }; + + this.execute = <span class="fstat-no" title="function not covered" >fu</span>nction (query, params) { + var $this = <span class="cstat-no" title="statement not covered" >this;</span> + +<span class="cstat-no" title="statement not covered" > return <span class="fstat-no" title="function not covered" >fu</span>nction (callback) {</span> +<span class="cstat-no" title="statement not covered" > $this.query(query, params, <span class="fstat-no" title="function not covered" >fu</span>nction (err) {</span> +<span class="cstat-no" title="statement not covered" > callback(err);</span> + }); + }; + }; + + this.queryFromFile = <span class="fstat-no" title="function not covered" >fu</span>nction(file, params, callback) { + var queries_dir = <span class="cstat-no" title="statement not covered" >__dirname + "/../queries/";</span> + +<span class="cstat-no" title="statement not covered" > fs.readFile(queries_dir + file, 'utf8', <span class="fstat-no" title="function not covered" >fu</span>nction (err, data) {</span> +<span class="cstat-no" title="statement not covered" > if (err) {</span> +<span class="cstat-no" title="statement not covered" > return callback(err);</span> + } + +<span class="cstat-no" title="statement not covered" > if (typeof params === 'undefined') {</span> +<span class="cstat-no" title="statement not covered" > params = [];</span> + } + +<span class="cstat-no" title="statement not covered" > client.query(data, params, callback);</span> + }); + }; + + this.executeFromFile = <span class="fstat-no" title="function not covered" >fu</span>nction(file, params) { + var $this = <span class="cstat-no" title="statement not covered" >this;</span> + +<span class="cstat-no" title="statement not covered" > return <span class="fstat-no" title="function not covered" >fu</span>nction (callback) {</span> +<span class="cstat-no" title="statement not covered" > $this.queryFromFile(file, params, <span class="fstat-no" title="function not covered" >fu</span>nction (err) {</span> +<span class="cstat-no" title="statement not covered" > callback(err);</span> + }); + }; + }; + + this.copyFrom = <span class="fstat-no" title="function not covered" >fu</span>nction (query, callback) { + var stream = <span class="cstat-no" title="statement not covered" >client.query(copyFrom(query));</span> +<span class="cstat-no" title="statement not covered" > stream.on('end', callback);</span> +<span class="cstat-no" title="statement not covered" > stream.on('error', callback);</span> +<span class="cstat-no" title="statement not covered" > return stream;</span> + }; + + this.transaction = function (callback) { + client.query('BEGIN;', function (err) { + callback(err); + }); + }; + + this.commit = <span class="fstat-no" title="function not covered" >fu</span>nction (callback) { +<span class="cstat-no" title="statement not covered" > client.query('COMMIT;', <span class="fstat-no" title="function not covered" >fu</span>nction (err) {</span> +<span class="cstat-no" title="statement not covered" > callback(err);</span> + }); + }; + + this.rollback = function (callback) { + client.query('ROLLBACK;', function (err) { + callback(err); + }); + }; + + this.auth = <span class="fstat-no" title="function not covered" >fu</span>nction (user, ip, action, comment) { +<span class="cstat-no" title="statement not covered" > return <span class="fstat-no" title="function not covered" >fu</span>nction (callback) {</span> +<span class="cstat-no" title="statement not covered" > if (!(user && user.id))</span> +<span class="cstat-no" title="statement not covered" > return callback('not_logged_in');</span> + +<span class="cstat-no" title="statement not covered" > client.query('SELECT auth.user_action($1, $2, $3, $4);',</span> + [user.id, ip, action, comment], +<span class="fstat-no" title="function not covered" > fu</span>nction (err) { +<span class="cstat-no" title="statement not covered" > callback(err);</span> + }); + }; + }; +}; + </pre></td></tr> +</table></pre> +<div class='push'></div><!-- for sticky footer --> +</div><!-- /wrapper --> +<div class='footer quiet pad2 space-top1 center small'> + Code coverage + generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu Aug 10 2017 11:42:01 GMT-0300 (BRT) +</div> +</div> +<script src="../../prettify.js"></script> +<script> +window.onload = function () { + if (typeof prettyPrint === 'function') { + prettyPrint(); + } +}; +</script> +<script src="../../sorter.js"></script> +</body> +</html> diff --git a/coverage/webservice-pinsis/middleware/index.html b/coverage/webservice-pinsis/middleware/index.html new file mode 100644 index 0000000..288814c --- /dev/null +++ b/coverage/webservice-pinsis/middleware/index.html @@ -0,0 +1,93 @@ +<!doctype html> +<html lang="en"> +<head> + <title>Code coverage report for webservice-pinsis/middleware</title> + <meta charset="utf-8" /> + <link rel="stylesheet" href="../../prettify.css" /> + <link rel="stylesheet" href="../../base.css" /> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <style type='text/css'> + .coverage-summary .sorter { + background-image: url(../../sort-arrow-sprite.png); + } + </style> +</head> +<body> +<div class='wrapper'> + <div class='pad1'> + <h1> + <a href="../../index.html">All files</a> webservice-pinsis/middleware + </h1> + <div class='clearfix'> + <div class='fl pad1y space-right2'> + <span class="strong">44.44% </span> + <span class="quiet">Statements</span> + <span class='fraction'>40/90</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">36.36% </span> + <span class="quiet">Branches</span> + <span class='fraction'>8/22</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">38.71% </span> + <span class="quiet">Functions</span> + <span class='fraction'>12/31</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">44.94% </span> + <span class="quiet">Lines</span> + <span class='fraction'>40/89</span> + </div> + </div> + </div> + <div class='status-line low'></div> +<div class="pad1"> +<table class="coverage-summary"> +<thead> +<tr> + <th data-col="file" data-fmt="html" data-html="true" class="file">File</th> + <th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th> + <th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th> + <th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th> + <th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th> + <th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th> + <th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th> + <th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th> + <th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th> + <th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th> +</tr> +</thead> +<tbody><tr> + <td class="file low" data-value="db.js"><a href="db.js.html">db.js</a></td> + <td data-value="44.44" class="pic low"><div class="chart"><div class="cover-fill" style="width: 44%;"></div><div class="cover-empty" style="width:56%;"></div></div></td> + <td data-value="44.44" class="pct low">44.44%</td> + <td data-value="90" class="abs low">40/90</td> + <td data-value="36.36" class="pct low">36.36%</td> + <td data-value="22" class="abs low">8/22</td> + <td data-value="38.71" class="pct low">38.71%</td> + <td data-value="31" class="abs low">12/31</td> + <td data-value="44.94" class="pct low">44.94%</td> + <td data-value="89" class="abs low">40/89</td> + </tr> + +</tbody> +</table> +</div><div class='push'></div><!-- for sticky footer --> +</div><!-- /wrapper --> +<div class='footer quiet pad2 space-top1 center small'> + Code coverage + generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu Aug 10 2017 11:42:01 GMT-0300 (BRT) +</div> +</div> +<script src="../../prettify.js"></script> +<script> +window.onload = function () { + if (typeof prettyPrint === 'function') { + prettyPrint(); + } +}; +</script> +<script src="../../sorter.js"></script> +</body> +</html> diff --git a/coverage/webservice-pinsis/routes/agent.js.html b/coverage/webservice-pinsis/routes/agent.js.html new file mode 100644 index 0000000..4477377 --- /dev/null +++ b/coverage/webservice-pinsis/routes/agent.js.html @@ -0,0 +1,464 @@ +<!doctype html> +<html lang="en"> +<head> + <title>Code coverage report for webservice-pinsis/routes/agent.js</title> + <meta charset="utf-8" /> + <link rel="stylesheet" href="../../prettify.css" /> + <link rel="stylesheet" href="../../base.css" /> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <style type='text/css'> + .coverage-summary .sorter { + background-image: url(../../sort-arrow-sprite.png); + } + </style> +</head> +<body> +<div class='wrapper'> + <div class='pad1'> + <h1> + <a href="../../index.html">All files</a> / <a href="index.html">webservice-pinsis/routes</a> agent.js + </h1> + <div class='clearfix'> + <div class='fl pad1y space-right2'> + <span class="strong">69.23% </span> + <span class="quiet">Statements</span> + <span class='fraction'>27/39</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">50% </span> + <span class="quiet">Branches</span> + <span class='fraction'>6/12</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">70% </span> + <span class="quiet">Functions</span> + <span class='fraction'>7/10</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">69.23% </span> + <span class="quiet">Lines</span> + <span class='fraction'>27/39</span> + </div> + </div> + </div> + <div class='status-line medium'></div> +<pre><table class="coverage"> +<tr><td class="line-count quiet">1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134</td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">/* +* Copyright (C) 2012-2017 Centro de Computacao Cientifica e Software Livre +* Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR +* +* This file is part of simmc +* +* simmc is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +* USA. +*/ + +var async = require('async'); + + + +var routes = { + /*"net_usage": { + validation: function(body) { + if(!body) { + return false; +} +else { +var keys = [ +'id_point', +'mac_address', +'bytes_recived', +'bytes_transmited', +'collect_time', +'packets_recived', +'packets_transmited', +]; +return isSubSet(Object.keys(body), keys); +} +}, +parser: function(body) { +return [ +dateFormat(new Date()), +body.id_point, +body.mac_address, +dateFormat(body.collect_time), +timeFormat(body.collect_time), +body.bytes_recived, +body.packets_recived, +body.bytes_transmited, +body.packets_transmited, +]; +}, +query: 'collect/net_usage.sql' +}*/ +}; + + + +module.exports = function(agentVersion) { + qb = require("../db/query_builder.js")(); + + return { + collect: function(req, res) { + var queries = []; + <span class="missing-if-branch" title="else path not taken" >E</span>if(req.body.hasOwnProperty("courses")){ + for(var i=0;i < req.body.courses.length; i++){ + var course = req.body.courses[i]; + var q = qb.insert('Course', course); + queries.push(q); + } + + } + + <span class="missing-if-branch" title="if path not taken" >I</span>if(req.body.hasOwnProperty("sessions")){ +<span class="cstat-no" title="statement not covered" > req.body.sessions.forEach(<span class="fstat-no" title="function not covered" >fu</span>nction(session){</span> +<span class="cstat-no" title="statement not covered" > queries.push(qb.insert('Session', session));</span> + }); + + } + + <span class="missing-if-branch" title="if path not taken" >I</span>if(req.body.hasOwnProperty("sessionProcedureParts")){ +<span class="cstat-no" title="statement not covered" > req.body.sessionProcedureParts.forEach(<span class="fstat-no" title="function not covered" >fu</span>nction(spp){</span> +<span class="cstat-no" title="statement not covered" > queries.push(qb.insert('sessionProcedureParts', spp));</span> + }); + + } + req.db.connect(function(err, conn, done) { + <span class="missing-if-branch" title="if path not taken" >I</span>if (err) { +<span class="cstat-no" title="statement not covered" > req.log.error(err);</span> +<span class="cstat-no" title="statement not covered" > res.status(500).json({error: 'db_connection_failed'});</span> +<span class="cstat-no" title="statement not covered" > return;</span> + } + async.waterfall([ + conn.transaction, + function(callback) { + async.everyLimit(queries, 1, async function(q){ + try{ + await conn.query(q.toParam().text, q.toParam().values); +<span class="cstat-no" title="statement not covered" > return true;</span> + }catch(err){ + callback(err); + return false; + } + }, function(err, result){ + <span class="missing-if-branch" title="if path not taken" >I</span>if(result){ +<span class="cstat-no" title="statement not covered" > callback(null);</span> + } + }); + }, + conn.commit + ], function (err, result) { + <span class="missing-if-branch" title="else path not taken" >E</span>if(err) { + req.log.error(err); + res.status(500).json({error: 'db_query_failed'}); + conn.rollback(done); + return; + } +<span class="cstat-no" title="statement not covered" > res.status(200).json({});</span> +<span class="cstat-no" title="statement not covered" > done();</span> + }); + }); + }, + version : <span class="fstat-no" title="function not covered" >fu</span>nction (req, res) { +<span class="cstat-no" title="statement not covered" > return res.status(200).json({version: agentVersion});</span> + } + }; +}; + </pre></td></tr> +</table></pre> +<div class='push'></div><!-- for sticky footer --> +</div><!-- /wrapper --> +<div class='footer quiet pad2 space-top1 center small'> + Code coverage + generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu Aug 10 2017 11:42:01 GMT-0300 (BRT) +</div> +</div> +<script src="../../prettify.js"></script> +<script> +window.onload = function () { + if (typeof prettyPrint === 'function') { + prettyPrint(); + } +}; +</script> +<script src="../../sorter.js"></script> +</body> +</html> diff --git a/coverage/webservice-pinsis/routes/index.html b/coverage/webservice-pinsis/routes/index.html new file mode 100644 index 0000000..2bf4bde --- /dev/null +++ b/coverage/webservice-pinsis/routes/index.html @@ -0,0 +1,106 @@ +<!doctype html> +<html lang="en"> +<head> + <title>Code coverage report for webservice-pinsis/routes</title> + <meta charset="utf-8" /> + <link rel="stylesheet" href="../../prettify.css" /> + <link rel="stylesheet" href="../../base.css" /> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <style type='text/css'> + .coverage-summary .sorter { + background-image: url(../../sort-arrow-sprite.png); + } + </style> +</head> +<body> +<div class='wrapper'> + <div class='pad1'> + <h1> + <a href="../../index.html">All files</a> webservice-pinsis/routes + </h1> + <div class='clearfix'> + <div class='fl pad1y space-right2'> + <span class="strong">59.57% </span> + <span class="quiet">Statements</span> + <span class='fraction'>28/47</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">42.86% </span> + <span class="quiet">Branches</span> + <span class='fraction'>6/14</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">58.33% </span> + <span class="quiet">Functions</span> + <span class='fraction'>7/12</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">59.57% </span> + <span class="quiet">Lines</span> + <span class='fraction'>28/47</span> + </div> + </div> + </div> + <div class='status-line medium'></div> +<div class="pad1"> +<table class="coverage-summary"> +<thead> +<tr> + <th data-col="file" data-fmt="html" data-html="true" class="file">File</th> + <th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th> + <th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th> + <th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th> + <th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th> + <th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th> + <th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th> + <th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th> + <th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th> + <th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th> +</tr> +</thead> +<tbody><tr> + <td class="file medium" data-value="agent.js"><a href="agent.js.html">agent.js</a></td> + <td data-value="69.23" class="pic medium"><div class="chart"><div class="cover-fill" style="width: 69%;"></div><div class="cover-empty" style="width:31%;"></div></div></td> + <td data-value="69.23" class="pct medium">69.23%</td> + <td data-value="39" class="abs medium">27/39</td> + <td data-value="50" class="pct medium">50%</td> + <td data-value="12" class="abs medium">6/12</td> + <td data-value="70" class="pct medium">70%</td> + <td data-value="10" class="abs medium">7/10</td> + <td data-value="69.23" class="pct medium">69.23%</td> + <td data-value="39" class="abs medium">27/39</td> + </tr> + +<tr> + <td class="file low" data-value="ping.js"><a href="ping.js.html">ping.js</a></td> + <td data-value="12.5" class="pic low"><div class="chart"><div class="cover-fill" style="width: 12%;"></div><div class="cover-empty" style="width:88%;"></div></div></td> + <td data-value="12.5" class="pct low">12.5%</td> + <td data-value="8" class="abs low">1/8</td> + <td data-value="0" class="pct low">0%</td> + <td data-value="2" class="abs low">0/2</td> + <td data-value="0" class="pct low">0%</td> + <td data-value="2" class="abs low">0/2</td> + <td data-value="12.5" class="pct low">12.5%</td> + <td data-value="8" class="abs low">1/8</td> + </tr> + +</tbody> +</table> +</div><div class='push'></div><!-- for sticky footer --> +</div><!-- /wrapper --> +<div class='footer quiet pad2 space-top1 center small'> + Code coverage + generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu Aug 10 2017 11:42:01 GMT-0300 (BRT) +</div> +</div> +<script src="../../prettify.js"></script> +<script> +window.onload = function () { + if (typeof prettyPrint === 'function') { + prettyPrint(); + } +}; +</script> +<script src="../../sorter.js"></script> +</body> +</html> diff --git a/coverage/webservice-pinsis/routes/ping.js.html b/coverage/webservice-pinsis/routes/ping.js.html new file mode 100644 index 0000000..d7e57e2 --- /dev/null +++ b/coverage/webservice-pinsis/routes/ping.js.html @@ -0,0 +1,164 @@ +<!doctype html> +<html lang="en"> +<head> + <title>Code coverage report for webservice-pinsis/routes/ping.js</title> + <meta charset="utf-8" /> + <link rel="stylesheet" href="../../prettify.css" /> + <link rel="stylesheet" href="../../base.css" /> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <style type='text/css'> + .coverage-summary .sorter { + background-image: url(../../sort-arrow-sprite.png); + } + </style> +</head> +<body> +<div class='wrapper'> + <div class='pad1'> + <h1> + <a href="../../index.html">All files</a> / <a href="index.html">webservice-pinsis/routes</a> ping.js + </h1> + <div class='clearfix'> + <div class='fl pad1y space-right2'> + <span class="strong">12.5% </span> + <span class="quiet">Statements</span> + <span class='fraction'>1/8</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">0% </span> + <span class="quiet">Branches</span> + <span class='fraction'>0/2</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">0% </span> + <span class="quiet">Functions</span> + <span class='fraction'>0/2</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">12.5% </span> + <span class="quiet">Lines</span> + <span class='fraction'>1/8</span> + </div> + </div> + </div> + <div class='status-line low'></div> +<pre><table class="coverage"> +<tr><td class="line-count quiet">1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34</td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">/* + * Copyright (C) 2012 Centro de Computacao Cientifica e Software Livre + * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR + * + * This file is part of simmc + * + * simmc is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + */ + +exports.get = <span class="fstat-no" title="function not covered" >fu</span>nction (req, res) { +<span class="cstat-no" title="statement not covered" > req.db.connect(<span class="fstat-no" title="function not covered" >fu</span>nction (err, conn, done) {</span> +<span class="cstat-no" title="statement not covered" > done(err);</span> +<span class="cstat-no" title="statement not covered" > if (err) {</span> +<span class="cstat-no" title="statement not covered" > res.status(200).json({ message: 'db_connection_failed' });</span> +<span class="cstat-no" title="statement not covered" > return;</span> + } +<span class="cstat-no" title="statement not covered" > res.status(200).json({ message: 'Pong' });</span> +<span class="cstat-no" title="statement not covered" > return;</span> + }); +}; + </pre></td></tr> +</table></pre> +<div class='push'></div><!-- for sticky footer --> +</div><!-- /wrapper --> +<div class='footer quiet pad2 space-top1 center small'> + Code coverage + generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu Aug 10 2017 11:42:01 GMT-0300 (BRT) +</div> +</div> +<script src="../../prettify.js"></script> +<script> +window.onload = function () { + if (typeof prettyPrint === 'function') { + prettyPrint(); + } +}; +</script> +<script src="../../sorter.js"></script> +</body> +</html> diff --git a/coverage/webservice-pinsis/server.js.html b/coverage/webservice-pinsis/server.js.html new file mode 100644 index 0000000..a1b9032 --- /dev/null +++ b/coverage/webservice-pinsis/server.js.html @@ -0,0 +1,743 @@ +<!doctype html> +<html lang="en"> +<head> + <title>Code coverage report for webservice-pinsis/server.js</title> + <meta charset="utf-8" /> + <link rel="stylesheet" href="../prettify.css" /> + <link rel="stylesheet" href="../base.css" /> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <style type='text/css'> + .coverage-summary .sorter { + background-image: url(../sort-arrow-sprite.png); + } + </style> +</head> +<body> +<div class='wrapper'> + <div class='pad1'> + <h1> + <a href="../index.html">All files</a> / <a href="index.html">webservice-pinsis</a> server.js + </h1> + <div class='clearfix'> + <div class='fl pad1y space-right2'> + <span class="strong">60.87% </span> + <span class="quiet">Statements</span> + <span class='fraction'>56/92</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">62.96% </span> + <span class="quiet">Branches</span> + <span class='fraction'>34/54</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">33.33% </span> + <span class="quiet">Functions</span> + <span class='fraction'>1/3</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">60.87% </span> + <span class="quiet">Lines</span> + <span class='fraction'>56/92</span> + </div> + </div> + </div> + <div class='status-line medium'></div> +<pre><table class="coverage"> +<tr><td class="line-count quiet">1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227</td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-no"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">#!/usr/bin/env node +/* + * Copyright (C) 2012 Centro de Computacao Cientifica e Software Livre + * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR + * + * This file is part of simmc + * + * simmc is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + */ + +// +// Libraries +// +var os = require('os'); +var fs = require('fs'); +var cluster = require('cluster'); +var bodyParser = require('body-parser'); +var express = require('express'); +var minimist = require('minimist'); +var path = require('path'); +var exec = require('child_process').execFile; +var collect = require('collect-webservice'); + +// +// Parse command line arguments +// +var argv = minimist(process.argv.slice(2)); +<span class="missing-if-branch" title="if path not taken" >I</span>if (argv.help || argv.h) { +<span class="cstat-no" title="statement not covered" > console.log('Usage: server.js [OPTION]...');</span> +<span class="cstat-no" title="statement not covered" > console.log('');</span> +<span class="cstat-no" title="statement not covered" > console.log('Where OPTION can be:');</span> +<span class="cstat-no" title="statement not covered" > console.log(' -c, --config alternative configuration file (default: config.js)');</span> +<span class="cstat-no" title="statement not covered" > console.log(' -p, --port port where the server will listen to');</span> +<span class="cstat-no" title="statement not covered" > console.log(' --insecure allows session cookies to be passed around in');</span> +<span class="cstat-no" title="statement not covered" > console.log(' in insecure connections');</span> +<span class="cstat-no" title="statement not covered" > console.log(' --dev force development mode');</span> +<span class="cstat-no" title="statement not covered" > console.log(' -n, --num-workers number of worker processes to spawn');</span> +<span class="cstat-no" title="statement not covered" > console.log(' -d, --daemon start the server as a daemon');</span> +<span class="cstat-no" title="statement not covered" > console.log(' --pid-file path for the pid file when running as a daemon');</span> +<span class="cstat-no" title="statement not covered" > console.log(' -h, --help show this help and exit');</span> +<span class="cstat-no" title="statement not covered" > return 0;</span> +} + +const app_mode = (process.env.NODE_ENV || <span class="branch-1 cbranch-no" title="branch not covered" >'development')</span>.trim().toLowerCase(); + +console.log(app_mode); + + +var configFile; + +//test config +<span class="missing-if-branch" title="if path not taken" >I</span>if(app_mode === 'test'){ +<span class="cstat-no" title="statement not covered" > configFile = argv.config || argv.c || 'test/config.js';</span> +}else{ + configFile = argv.config || argv.c || 'config.js'; +} + +var config; +try { + config = require(path.resolve('.', configFile)); +} +catch (e) { +<span class="cstat-no" title="statement not covered" > if (e.code === 'MODULE_NOT_FOUND') {</span> +<span class="cstat-no" title="statement not covered" > console.error('Missing configuration file ('+configFile+')!');</span> +<span class="cstat-no" title="statement not covered" > console.error('Perhaps you need to create it using:');</span> +<span class="cstat-no" title="statement not covered" > console.error(' $ cp config.example.js '+configFile);</span> +<span class="cstat-no" title="statement not covered" > console.error('');</span> +<span class="cstat-no" title="statement not covered" > return 1;</span> + } + else { +<span class="cstat-no" title="statement not covered" > console.error('Error while parsing configuration file ('+configFile+')!');</span> +<span class="cstat-no" title="statement not covered" > console.error('');</span> +<span class="cstat-no" title="statement not covered" > console.error(e.stack);</span> +<span class="cstat-no" title="statement not covered" > return 2;</span> + } +} + +var devMode = argv.dev || (process.env.NODE_ENV && (process.env.NODE_ENV.slice(0,3) === 'dev')); +var port = parseInt(argv.port || argv.p || process.env.PORT) || 3000; +var secureCookies = !argv.insecure; +var numWorkers = parseInt(argv['num-workers'] || argv.n) || (os.cpus().length * 2); +var daemon = argv.daemon || argv.d || false; +var pidfile = argv['pid-file'] || config.pid_file || process.env.PID_FILE || path.resolve('.', 'simmc.pid'); + +<span class="missing-if-branch" title="else path not taken" >E</span>if (app_mode === 'development' || <span class="branch-1 cbranch-no" title="branch not covered" >app_mode === 'test')</span> { + secureCookies = false; + + // Limit to only 1 worker in dev mode because sessions stored + // in memory are not shared between processes. + // In dev mode memcached is probably not configure therefore + // session storage falls back to memory resulting in sessions + // not persisting. + numWorkers = 1; +} + +// +// Setup logger +// +var logger = require('./lib/logger.js'); +var log = logger.default; + + +// +// Middlewares +// + +var db = require('./middleware/db.js'); +var utils = require('./lib/utils.js'); + +// +// Routes +// + +var ping = require('./routes/ping.js'); +var agent = require('./routes/agent.js')(config.agentVersion); + +//Data validation +var ct_validator = require('./validation/course_treatment.js'); + +// +// Setup express app +// +var app = express(); +app.use(logger.expressAccess); +app.use(logger.expressError); +app.use(bodyParser.json()); +app.use(bodyParser.urlencoded({extended: true})); + + + +app.use(db.pool(config.db_config)); + + + +// acquire user id and ip address +app.use(function (req, res, next) { + req.ip = req.ips[0] || req.ip || <span class="branch-2 cbranch-no" title="branch not covered" >null;</span> + next(); +}); + + + + + +// +// Setup routes +// + +app.get('/api/ping', ping.get); + + +var collect_mw = collect(ct_validator()); +app.post('/api/agent/collect/:type(course_treatment)', collect_mw, agent.collect); +app.get('/api/agent/version', agent.version); + + + + +// +// Fork process +// +<span class="missing-if-branch" title="else path not taken" >E</span>if (cluster.isMaster) { + // daemonize the process (useful for init.d scripts and similar) + <span class="missing-if-branch" title="if path not taken" >I</span>if (argv.daemon) { +<span class="cstat-no" title="statement not covered" > require('daemon')();</span> +<span class="cstat-no" title="statement not covered" > fs.writeFileSync(pidfile, process.pid+"\n");</span> + } + + log.info('Starting server in '+ (devMode ? 'development' : <span class="branch-1 cbranch-no" title="branch not covered" >'production')</span> + + ' mode, spawning ' + numWorkers + ' workers'); + + for (var i = 0; i < numWorkers; i++) { + cluster.fork(); + } + + + cluster.on('exit', <span class="fstat-no" title="function not covered" >fu</span>nction(worker, code, signal) { +<span class="cstat-no" title="statement not covered" > if (code || signal) {</span> +<span class="cstat-no" title="statement not covered" > log.error('Worker %d has ended (%s,%s).', worker.id, code, signal);</span> + } else { +<span class="cstat-no" title="statement not covered" > log.fatal('Worker %d has died. Restarting it...', worker.id);</span> +<span class="cstat-no" title="statement not covered" > cluster.fork();</span> + } + }); + + function <span class="fstat-no" title="function not covered" >exit(</span>) { +<span class="cstat-no" title="statement not covered" > log.info('Server exiting...');</span> + +<span class="cstat-no" title="statement not covered" > process.exit(0);</span> + } + + process.on('SIGTERM', exit); + process.on('SIGHUP', exit); + process.on('SIGINT', exit); +} +else { + + // + // Listen for incoming connections + // +<span class="cstat-no" title="statement not covered" > if (!module.parent) {</span> + // Only enter the listen loop if the script is executed directly + // (like: node server.js, not imported by another script). This check + // is useful for running automated tests which don't work if this + // module is "stuck" on listen loop. + +<span class="cstat-no" title="statement not covered" > log.info('Ready');</span> +<span class="cstat-no" title="statement not covered" > console.log('Worker '+cluster.worker.id+' listening...');</span> + +<span class="cstat-no" title="statement not covered" > app.listen(port);</span> + } +} +module.exports = app; + </pre></td></tr> +</table></pre> +<div class='push'></div><!-- for sticky footer --> +</div><!-- /wrapper --> +<div class='footer quiet pad2 space-top1 center small'> + Code coverage + generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu Aug 10 2017 11:42:01 GMT-0300 (BRT) +</div> +</div> +<script src="../prettify.js"></script> +<script> +window.onload = function () { + if (typeof prettyPrint === 'function') { + prettyPrint(); + } +}; +</script> +<script src="../sorter.js"></script> +</body> +</html> diff --git a/coverage/webservice-pinsis/validation/course_treatment.js.html b/coverage/webservice-pinsis/validation/course_treatment.js.html new file mode 100644 index 0000000..013d5f1 --- /dev/null +++ b/coverage/webservice-pinsis/validation/course_treatment.js.html @@ -0,0 +1,1001 @@ +<!doctype html> +<html lang="en"> +<head> + <title>Code coverage report for webservice-pinsis/validation/course_treatment.js</title> + <meta charset="utf-8" /> + <link rel="stylesheet" href="../../prettify.css" /> + <link rel="stylesheet" href="../../base.css" /> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <style type='text/css'> + .coverage-summary .sorter { + background-image: url(../../sort-arrow-sprite.png); + } + </style> +</head> +<body> +<div class='wrapper'> + <div class='pad1'> + <h1> + <a href="../../index.html">All files</a> / <a href="index.html">webservice-pinsis/validation</a> course_treatment.js + </h1> + <div class='clearfix'> + <div class='fl pad1y space-right2'> + <span class="strong">100% </span> + <span class="quiet">Statements</span> + <span class='fraction'>4/4</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">100% </span> + <span class="quiet">Branches</span> + <span class='fraction'>0/0</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">50% </span> + <span class="quiet">Functions</span> + <span class='fraction'>1/2</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">100% </span> + <span class="quiet">Lines</span> + <span class='fraction'>4/4</span> + </div> + </div> + </div> + <div class='status-line high'></div> +<pre><table class="coverage"> +<tr><td class="line-count quiet">1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313</td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-yes">1x</span> +<span class="cline-any cline-neutral"> </span> +<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">/* +* Copyright (C) 2012-2017 Centro de Computacao Cientifica e Software Livre +* Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR +* +* This file is part of simmc +* +* simmc is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +* USA. +*/ + + +var config = { + global: { + fromBody: false, + param: "type" + }, + filters: {}, + collect_types: { + "course_treatment": { + "courses":{ + required: false, + isArray: true, + filters: [], + inner:{ + "CourseSer" : { + required: true, + isArray: false, + filters: [] + }, + "PatientSer" : { + required: true, + isArray: false, + filters: [] + }, + "CourseId" : { + required: true, + isArray: false, + filters: [] + }, + "StartDateTime" : { + required: true, + isArray: false, + filters: [] + }, + "ClinicalStatus" : { + required: true, + isArray: false, + filters: [] + }, + "CompletedByUserName" : { + required: true, + isArray: false, + filters: [] + }, + "CompletedDateTime" : { + required: true, + isArray: false, + filters: [] + }, + "Comment" : { + required: true, + isArray: false, + filters: [] + }, + "ClinicalProtocolDir" : { + required: true, + isArray: false, + filters: [] + }, + "HstryUserName" : { + required: true, + isArray: false, + filters: [] + }, + "HstryTimeStamp" : { + required: true, + isArray: false, + filters: [] + }, + "HstryDateTime" : { + required: true, + isArray: false, + filters: [] + }, + "TransactionId" : { + required: true, + isArray: false, + filters: [] + }, + "HstryTaskName" : { + required: true, + isArray: false, + filters: [] + } + + } + }, + "sessions":{ + required: false, + isArray: true, + filters: [], + inner:{ + "sessionSer": { + required: true, + isArray: false, + filters: [] + }, + "SessionNum": { + required: true, + isArray: false, + filters: [] + }, + "Comment": { + required: true, + isArray: false, + filters: [] + }, + "HstryUserName": { + required: true, + isArray: false, + filters: [] + }, + "HstryTimeStamp": { + required: true, + isArray: false, + filters: [] + }, + "HstryDateTime": { + required: true, + isArray: false, + filters: [] + }, + "HstryTaskName": { + required: true, + isArray: false, + filters: [] + }, + "CourseSer": { + required: true, + isArray: false, + filters: [] + }, + + } + }, + "sessionProcedureParts":{//FIXME: Is it required? + required: false, + isArray: true, + filters: [], + inner:{ + "RadiationSer" : { + required: true, + isArray: false, + filters: [] + }, + "ImageType" : { + required: true, + isArray: false, + filters: [] + }, + "SequenceNumber" : { + required: true, + isArray: false, + filters: [] + }, + "SessionProcedurePartSer" : { + required: true, + isArray: false, + filters: [] + }, + "AcqAdjustment" : { + required: true, + isArray: false, + filters: [] + }, + "AutoSave" : { + required: true, + isArray: false, + filters: [] + }, + "DoseAccumulation" : { + required: true, + isArray: false, + filters: [] + }, + "Continuous" : { + required: true, + isArray: false, + filters: [] + }, + "BeamOff" : { + required: true, + isArray: false, + filters: [] + }, + "DeviationImage" : { + required: true, + isArray: false, + filters: [] + }, + "DevEnergy" : { + required: true, + isArray: false, + filters: [] + }, + "DevDoseRate" : { + required: true, + isArray: false, + filters: [] + }, + "DevGeometry" : { + required: true, + isArray: false, + filters: [] + }, + "JawState" : { + required: true, + isArray: false, + filters: [] + }, + "DevCollX1" : { + required: true, + isArray: false, + filters: [] + }, + "DevCollX2" : { + required: true, + isArray: false, + filters: [] + }, + "DevCollY1" : { + required: true, + isArray: false, + filters: [] + }, + "DevCollY2" : { + required: true, + isArray: false, + filters: [] + }, + "MUSubtraction" : { + required: true, + isArray: false, + filters: [] + }, + "AcquisitionMode" : { + required: true, + isArray: false, + filters: [] + }, + "HstryUserName" : { + required: true, + isArray: false, + filters: [] + }, + "HstryTimeStamp" : { + required: true, + isArray: false, + filters: [] + }, + "HstryDateTime" : { + required: true, + isArray: false, + filters: [] + }, + "HstryTaskName" : { + required: true, + isArray: false, + filters: [] + }, + "SessionProcedureSer" : { + required: true, + isArray: false, + filters: [] + }, + "ImageModality" : { + required: true, + isArray: false, + filters: [] + }, + "RTPlanSer" : { + required: true, + isArray: false, + filters: [] + } + } + } + } + } +}; + +var parser = <span class="fstat-no" title="function not covered" >fu</span>nction(body){//TODO: remove extra fields in the body + +}; + + +module.exports = function() { + + return config; +}; + </pre></td></tr> +</table></pre> +<div class='push'></div><!-- for sticky footer --> +</div><!-- /wrapper --> +<div class='footer quiet pad2 space-top1 center small'> + Code coverage + generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu Aug 10 2017 11:42:01 GMT-0300 (BRT) +</div> +</div> +<script src="../../prettify.js"></script> +<script> +window.onload = function () { + if (typeof prettyPrint === 'function') { + prettyPrint(); + } +}; +</script> +<script src="../../sorter.js"></script> +</body> +</html> diff --git a/coverage/webservice-pinsis/validation/index.html b/coverage/webservice-pinsis/validation/index.html new file mode 100644 index 0000000..55214e5 --- /dev/null +++ b/coverage/webservice-pinsis/validation/index.html @@ -0,0 +1,93 @@ +<!doctype html> +<html lang="en"> +<head> + <title>Code coverage report for webservice-pinsis/validation</title> + <meta charset="utf-8" /> + <link rel="stylesheet" href="../../prettify.css" /> + <link rel="stylesheet" href="../../base.css" /> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <style type='text/css'> + .coverage-summary .sorter { + background-image: url(../../sort-arrow-sprite.png); + } + </style> +</head> +<body> +<div class='wrapper'> + <div class='pad1'> + <h1> + <a href="../../index.html">All files</a> webservice-pinsis/validation + </h1> + <div class='clearfix'> + <div class='fl pad1y space-right2'> + <span class="strong">100% </span> + <span class="quiet">Statements</span> + <span class='fraction'>4/4</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">100% </span> + <span class="quiet">Branches</span> + <span class='fraction'>0/0</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">50% </span> + <span class="quiet">Functions</span> + <span class='fraction'>1/2</span> + </div> + <div class='fl pad1y space-right2'> + <span class="strong">100% </span> + <span class="quiet">Lines</span> + <span class='fraction'>4/4</span> + </div> + </div> + </div> + <div class='status-line high'></div> +<div class="pad1"> +<table class="coverage-summary"> +<thead> +<tr> + <th data-col="file" data-fmt="html" data-html="true" class="file">File</th> + <th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th> + <th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th> + <th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th> + <th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th> + <th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th> + <th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th> + <th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th> + <th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th> + <th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th> +</tr> +</thead> +<tbody><tr> + <td class="file high" data-value="course_treatment.js"><a href="course_treatment.js.html">course_treatment.js</a></td> + <td data-value="100" class="pic high"><div class="chart"><div class="cover-fill cover-full" style="width: 100%;"></div><div class="cover-empty" style="width:0%;"></div></div></td> + <td data-value="100" class="pct high">100%</td> + <td data-value="4" class="abs high">4/4</td> + <td data-value="100" class="pct high">100%</td> + <td data-value="0" class="abs high">0/0</td> + <td data-value="50" class="pct medium">50%</td> + <td data-value="2" class="abs medium">1/2</td> + <td data-value="100" class="pct high">100%</td> + <td data-value="4" class="abs high">4/4</td> + </tr> + +</tbody> +</table> +</div><div class='push'></div><!-- for sticky footer --> +</div><!-- /wrapper --> +<div class='footer quiet pad2 space-top1 center small'> + Code coverage + generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu Aug 10 2017 11:42:01 GMT-0300 (BRT) +</div> +</div> +<script src="../../prettify.js"></script> +<script> +window.onload = function () { + if (typeof prettyPrint === 'function') { + prettyPrint(); + } +}; +</script> +<script src="../../sorter.js"></script> +</body> +</html> diff --git a/database/create.sh b/database/create.sh new file mode 100755 index 0000000..ad7b98f --- /dev/null +++ b/database/create.sh @@ -0,0 +1,105 @@ +#!/bin/bash +# Copyright (C) 2007-2013 Centro de Computacao Cientifica e Software Livre +# Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR +# +# This file is part of database +# +# database is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +# USA. + + +#TODO:PASS THE USER AS ARGV +#DB_LINK_LOCATION=/usr/share/postgresql/9.1/extension/dblink.sql +#DATABASE_DIR=$(pwd) + +DATABASE_DIR="`dirname \"$0\"`" +DATABASE_DIR="`( cd \"$DATABASE_DIR\" && pwd )`" +SCHEMA_DIR="${DATABASE_DIR}/create/schema/" +DATA_DIR="${DATABASE_DIR}/create/data/" + + + +function print_help() { + echo -e "" + echo -e "usage: $0 database_name" + echo -e "" +} + +if [[ $1 != "-"* && $# != "0" ]]; then + DB_NAME=$1 + shift +else + print_help + exit 1 +fi + +function error_exit() { + dropdb $DB_NAME + # dropuser $DB_NAME + exit 1 +} + +# check if db exists3 +if psql -lqt | cut -d \| -f 1 | grep -qw "$DB_NAME"; then + echo "Database with name $DB_NAME already exists."; + read -p "Drop Database and create new one? (Warning, this will delete all existing data) [y/N]:" yn + case $yn in + y | Y | yes | YES ) + echo "Dropping database $DB_NAME" + dropdb $DB_NAME + # dropuser $DB_NAME + ;; + * ) + echo "Exiting script." + exit 0 + ;; + esac +fi + +# create user +#echo "INFO: Creating user: $DB_NAME"; +#createuser -DRS $DB_NAME || error_exit + +# create db +echo "INFO: Creating database: $DB_NAME"; +createdb $DB_NAME + +# importing extensions +#psql $DB_NAME -c 'CREATE EXTENSION IF NOT EXISTS dblink;' +#psql $DB_NAME -c 'CREATE EXTENSION IF NOT EXISTS pgcrypto;' +#psql $DB_NAME -c 'CREATE EXTENSION IF NOT EXISTS postgi s;' + +# creating database tables and structure +echo "INFO: Creating database tables and structure"; +for file in $(ls -B "${SCHEMA_DIR}"); do + echo "--- Executing: $file"; + psql -d $DB_NAME -f $SCHEMA_DIR$file || error_exit +done + +# restore database data +# echo "INFO: Restoring database data"; +# for file in $(ls -B "${DATA_DIR}"); do +# echo "--- Executing: $file"; +# psql $DB_NAME -f $file -v DATABASE_DIR="$DATABASE_DIR" || error_exit +# done + +# Create functions and views that are needed for the rest of the process +#psql $DB_NAME -f functions/db_versioning.sql || error_exit + +# upgrade schmema and create functions +#./upgrade.sh -d $DB_NAME + +# installing crontab +#./cron.sh $DB_NAME diff --git a/database/create/schema/bd.sql b/database/create/schema/bd.sql new file mode 100755 index 0000000..05d1d6d --- /dev/null +++ b/database/create/schema/bd.sql @@ -0,0 +1,69 @@ +START TRANSACTION; + + +CREATE TABLE session( + sessionSer BIGINT, + SessionNum INT, + Comment VARCHAR(11), + HstryUserName VARCHAR(11), + HstryTimeStamp TIMESTAMP, + HstryDateTime TIMESTAMP, + HstryTaskName VARCHAR(11), + CourseSer BIGINT, + CONSTRAINT pk_session primary key(sessionSer) +); + +CREATE TABLE SessionProcedurePart( + RadiationSer BIGINT, + ImageType VARCHAR(11), + SequenceNumber INT, + SessionProcedurePartSer BIGINT, + AcqAdjustment FLOAT(11), + AutoSave INT, + DoseAccumulation INT, + Continuous INT, + BeamOff INT, + DeviationImage INT, + DevEnergy INT, + DevDoseRate INT, + DevGeometry INT, + JawState FLOAT(11), + DevCollX1 FLOAT(11), + DevCollX2 FLOAT(11), + DevCollY1 FLOAT(11), + DevCollY2 FLOAT(11), + MUSubtraction INT, + AcquisitionMode VARCHAR(11), + HstryUserName VARCHAR(11), + HstryTimeStamp TIMESTAMP, + HstryDateTime TIMESTAMP, + HstryTaskName VARCHAR(11), + SessionProcedureSer BIGINT, + ImageModality VARCHAR(11), + RTPlanSer BIGINT, + CONSTRAINT pk_SessionProcedurePart primary key(SessionProcedurePartSer) +); + +CREATE TABLE Course( + CourseSer BIGINT, + PatientSer BIGINT, + CourseId VARCHAR(11), + StartDateTime TIMESTAMP, + ClinicalStatus VARCHAR(11), + CompletedByUserName VARCHAR(11), + CompletedDateTime TIMESTAMP, + Comment VARCHAR(11), + ClinicalProtocolDir VARCHAR(11), + HstryUserName VARCHAR(11) not null, + HstryTimeStamp TIMESTAMP, + HstryDateTime TIMESTAMP, + TransactionId VARCHAR(11), + HstryTaskName VARCHAR(32), + CONSTRAINT pk_Course primary key(CourseSer) +); + +ALTER TABLE session ADD CONSTRAINT fk_session_1 FOREIGN KEY(CourseSer) REFERENCES Course(CourseSer); +ALTER TABLE SessionProcedurePart ADD CONSTRAINT fk_SessionProcedurePart_2 FOREIGN KEY(SessionProcedurePartSer) REFERENCES session(sessionSer); +ALTER TABLE SessionProcedurePart ADD CONSTRAINT unique_SessionProcedurePart UNIQUE(SessionProcedurePartSer); + +COMMIT; diff --git a/database/create_user.sh b/database/create_user.sh new file mode 100755 index 0000000..d24b0e5 --- /dev/null +++ b/database/create_user.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +USERNAME= +PASSWORD= +SCHEMA_NAME= +PRIVILAGES="SELECT, INSERT, UPDATE, DELETE" + + + +function print_help() { + echo -e "" + echo -e "usage: $0 username password database_name " + echo -e "" +} + + +if [ $# -ne 3 ] + then + print_help + exit 1 +fi + +USERNAME=$1 +PASSWORD=$2 +DATABASE_NAME=$3 +SCHEMA_NAME="public" + +psql -d "$DATABASE_NAME" -tAc "SELECT 1 FROM pg_roles WHERE rolname='test'" | grep -q 1 + +HAS_USER=$? +if [[ "$HAS_USER" -eq 0 ]]; then + echo "User with name $USERNAME already exists."; + if psql -lqt | cut -d \| -f 1 | grep -qw "$DB_NAME"; then + read -p "Revoke all privilages of $USERNAME on $DATABASE_NAME? [y/N]:" yn + case $yn in + y | Y | yes | YES ) + echo "Dropping user $USERNAME" + psql -d "$DATABASE_NAME" -c "REVOKE ALL ON DATABASE \"$DATABASE_NAME\" FROM \"$USERNAME\";" + psql -d "$DATABASE_NAME" -c "REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA \"$SCHEMA_NAME\" FROM \"$USERNAME\";" + ;; + * ) + echo "Exiting script." + exit 0 + ;; + esac + fi + +else + CREATE_QUERY="CREATE USER \"$USERNAME\" WITH PASSWORD '${PASSWORD}';" + psql -c "${CREATE_QUERY}" +fi + +GRANT_QUERY="GRANT ${PRIVILAGES} ON ALL TABLES IN SCHEMA \"${SCHEMA_NAME}\" to \"${USERNAME}\";" +psql -d "${DATABASE_NAME}" -c "${GRANT_QUERY}" diff --git a/database/pg_hba.conf b/database/pg_hba.conf new file mode 100644 index 0000000..4a544e6 --- /dev/null +++ b/database/pg_hba.conf @@ -0,0 +1,100 @@ +# PostgreSQL Client Authentication Configuration File +# =================================================== +# +# Refer to the "Client Authentication" section in the PostgreSQL +# documentation for a complete description of this file. A short +# synopsis follows. +# +# This file controls: which hosts are allowed to connect, how clients +# are authenticated, which PostgreSQL user names they can use, which +# databases they can access. Records take one of these forms: +# +# local DATABASE USER METHOD [OPTIONS] +# host DATABASE USER ADDRESS METHOD [OPTIONS] +# hostssl DATABASE USER ADDRESS METHOD [OPTIONS] +# hostnossl DATABASE USER ADDRESS METHOD [OPTIONS] +# +# (The uppercase items must be replaced by actual values.) +# +# The first field is the connection type: "local" is a Unix-domain +# socket, "host" is either a plain or SSL-encrypted TCP/IP socket, +# "hostssl" is an SSL-encrypted TCP/IP socket, and "hostnossl" is a +# plain TCP/IP socket. +# +# DATABASE can be "all", "sameuser", "samerole", "replication", a +# database name, or a comma-separated list thereof. The "all" +# keyword does not match "replication". Access to replication +# must be enabled in a separate record (see example below). +# +# USER can be "all", a user name, a group name prefixed with "+", or a +# comma-separated list thereof. In both the DATABASE and USER fields +# you can also write a file name prefixed with "@" to include names +# from a separate file. +# +# ADDRESS specifies the set of hosts the record matches. It can be a +# host name, or it is made up of an IP address and a CIDR mask that is +# an integer (between 0 and 32 (IPv4) or 128 (IPv6) inclusive) that +# specifies the number of significant bits in the mask. A host name +# that starts with a dot (.) matches a suffix of the actual host name. +# Alternatively, you can write an IP address and netmask in separate +# columns to specify the set of hosts. Instead of a CIDR-address, you +# can write "samehost" to match any of the server's own IP addresses, +# or "samenet" to match any address in any subnet that the server is +# directly connected to. +# +# METHOD can be "trust", "reject", "md5", "password", "gss", "sspi", +# "ident", "peer", "pam", "ldap", "radius" or "cert". Note that +# "password" sends passwords in clear text; "md5" is preferred since +# it sends encrypted passwords. +# +# OPTIONS are a set of options for the authentication in the format +# NAME=VALUE. The available options depend on the different +# authentication methods -- refer to the "Client Authentication" +# section in the documentation for a list of which options are +# available for which authentication methods. +# +# Database and user names containing spaces, commas, quotes and other +# special characters must be quoted. Quoting one of the keywords +# "all", "sameuser", "samerole" or "replication" makes the name lose +# its special character, and just match a database or username with +# that name. +# +# This file is read on server startup and when the postmaster receives +# a SIGHUP signal. If you edit the file on a running system, you have +# to SIGHUP the postmaster for the changes to take effect. You can +# use "pg_ctl reload" to do that. + +# Put your actual configuration here +# ---------------------------------- +# +# If you want to allow non-local connections, you need to add more +# "host" records. In that case you will also need to make PostgreSQL +# listen on a non-local interface via the listen_addresses +# configuration parameter, or via the -i or -h command line switches. + + + + +# DO NOT DISABLE! +# If you change this first entry you will need to make sure that the +# database superuser can access the database using some other method. +# Noninteractive access to all databases is required during automatic +# maintenance (custom daily cronjobs, replication, and similar tasks). +# +# Database administrative login by Unix domain socket +local all postgres peer + +local all user md5 +# TYPE DATABASE USER ADDRESS METHOD + +# "local" is for Unix domain socket connections only +local all all peer +# IPv4 local connections: +host all all 127.0.0.1/32 md5 +# IPv6 local connections: +host all all ::1/128 md5 +# Allow replication connections from localhost, by a user with the +# replication privilege. +#local replication postgres peer +#host replication postgres 127.0.0.1/32 md5 +#host replication postgres ::1/128 md5 diff --git a/gulpfile.js b/gulpfile.js index 3a03d86..b385c65 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,9 +1,18 @@ var gulp = require('gulp'), jshint = require('gulp-jshint'), shell = require('gulp-shell'); + mocha = require('gulp-mocha'); var js_files = "**/*.js"; +const app_state = (process.env.NODE_ENV || 'development').trim().toLowerCase(); + +//dev config +var dev_config_file = './config.js'; + +var test_config_file = './test/config.js'; + +//var config = require(configFile); // define the default task and add the watch task to it gulp.task('default', ['run','watch']); @@ -16,10 +25,32 @@ gulp.task('jshint', function() { // configure which files to watch and what tasks to use on file changes gulp.task('watch', function() { - gulp.watch(js_files, ['jshint']); + gulp.watch(js_files/*, ['jshint']*/); }); gulp.task('run', function(){ return gulp.src("*") .pipe(shell('npm start')); -}) +}); + +//Run as a user with CREATE permission and permission to create users on postgresql +gulp.task('create_database_test', function(){ + + var config = require(test_config_file); + + return gulp.src("database") + .pipe(shell("./database/create.sh " + config.db_config.database)) + .pipe(shell("./database/create_user.sh " + config.db_config.user + " " + config.db_config.password + " " + config.db_config.database )); +}); +gulp.task('test',['create_database_test'], function(){ + return gulp.src(['test/*.js']) + .pipe(mocha({ + reporter : 'spec' + })); + +}); + +// gulp.task('test', ['create_database','mocha']) + + +module.exports = gulp; diff --git a/package.json b/package.json index 661972a..45054df 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,8 @@ "url": "git@gitlab.c3sl.ufpr.br:PInSIS/webservice-pinsis.git" }, "scripts": { - "start": "node server.js" + "start": "node server.js", + "test": "nyc --reporter=html --reporter=text mocha --timeout=3000" }, "dependencies": { "express": "^4.13.3", @@ -25,10 +26,15 @@ "collect-webservice": "git+ssh://git@gitlab.c3sl.ufpr.br:c3sl/collect-webservice.git" }, "devDependencies": { + "chai": "^4.1.0", + "chai-http": "^3.0.0", "gulp": "^3.9.1", "gulp-jshint": "^2.0.4", + "gulp-mocha": "^4.3.1", "gulp-shell": "^0.6.3", "jshint": "^2.9.5", - "jshint-stylish": "^2.2.1" + "jshint-stylish": "^2.2.1", + "mocha": "^3.5.0", + "nyc": "^11.1.0" } } diff --git a/routes/agent.js b/routes/agent.js index cad1fae..937da83 100644 --- a/routes/agent.js +++ b/routes/agent.js @@ -67,7 +67,6 @@ module.exports = function(agentVersion) { return { collect: function(req, res) { - //console.log(req.body.courses[0]); var queries = []; if(req.body.hasOwnProperty("courses")){ for(var i=0;i < req.body.courses.length; i++){ @@ -100,8 +99,7 @@ module.exports = function(agentVersion) { async.waterfall([ conn.transaction, function(callback) { - - async.everySeries(queries, async function(q){ + async.everyLimit(queries, 1, async function(q){ try{ await conn.query(q.toParam().text, q.toParam().values); return true; @@ -119,7 +117,6 @@ module.exports = function(agentVersion) { ], function (err, result) { if(err) { req.log.error(err); - console.log(err); res.status(500).json({error: 'db_query_failed'}); conn.rollback(done); return; diff --git a/server.js b/server.js index 0b19c41..4c91136 100644 --- a/server.js +++ b/server.js @@ -54,7 +54,19 @@ if (argv.help || argv.h) { return 0; } -var configFile = argv.config || argv.c || 'config.js'; +const app_mode = (process.env.NODE_ENV || 'development').trim().toLowerCase(); + + + +var configFile; + +//test config +if(app_mode === 'test'){ + configFile = argv.config || argv.c || 'test/config.js'; +}else{ + configFile = argv.config || argv.c || 'config.js'; +} + var config; try { config = require(path.resolve('.', configFile)); @@ -82,7 +94,7 @@ var numWorkers = parseInt(argv['num-workers'] || argv.n) || (os.cpus().length * var daemon = argv.daemon || argv.d || false; var pidfile = argv['pid-file'] || config.pid_file || process.env.PID_FILE || path.resolve('.', 'simmc.pid'); -if (devMode) { +if (app_mode === 'development' || app_mode === 'test') { secureCookies = false; // Limit to only 1 worker in dev mode because sessions stored @@ -100,6 +112,62 @@ var logger = require('./lib/logger.js'); var log = logger.default; +// +// Middlewares +// + +var db = require('./middleware/db.js'); +var utils = require('./lib/utils.js'); + +// +// Routes +// + +var ping = require('./routes/ping.js'); +var agent = require('./routes/agent.js')(config.agentVersion); + +//Data validation +var ct_validator = require('./validation/course_treatment.js'); + +// +// Setup express app +// +var app = express(); +app.use(logger.expressAccess); +app.use(logger.expressError); +app.use(bodyParser.json()); +app.use(bodyParser.urlencoded({extended: true})); + + + +app.use(db.pool(config.db_config)); + + + +// acquire user id and ip address +app.use(function (req, res, next) { + req.ip = req.ips[0] || req.ip || null; + next(); +}); + + + + + +// +// Setup routes +// + +app.get('/api/ping', ping.get); + + +var collect_mw = collect(ct_validator()); +app.post('/api/agent/collect/:type(course_treatment)', collect_mw, agent.collect); +app.get('/api/agent/version', agent.version); + + + + // // Fork process // @@ -138,58 +206,6 @@ if (cluster.isMaster) { process.on('SIGINT', exit); } else { - // - // Middlewares - // - - var db = require('./middleware/db.js'); - var utils = require('./lib/utils.js'); - - // - // Routes - // - - var ping = require('./routes/ping.js'); - var agent = require('./routes/agent.js')(config.agentVersion); - - //Data validation - var ct_validator = require('./validation/course_treatment.js'); - - // - // Setup express app - // - var app = express(); - app.use(logger.expressAccess); - app.use(logger.expressError); - app.use(bodyParser.json()); - app.use(bodyParser.urlencoded({extended: true})); - - - - app.use(db.pool(config.db_config)); - - - - // acquire user id and ip address - app.use(function (req, res, next) { - req.ip = req.ips[0] || req.ip || null; - next(); - }); - - - - - - // - // Setup routes - // - - app.get('/api/ping', ping.get); - - - var collect_mw = collect(ct_validator()); - app.post('/api/agent/collect/:type(course_treatment)', collect_mw, agent.collect); - app.get('/api/agent/version', agent.version); // // Listen for incoming connections @@ -206,3 +222,4 @@ else { app.listen(port); } } +module.exports = app; diff --git a/test/agent.js b/test/agent.js new file mode 100644 index 0000000..fe12e20 --- /dev/null +++ b/test/agent.js @@ -0,0 +1,40 @@ +process.env.NODE_ENV = 'test'; +let chai = require('chai'); +let chaiHttp = require('chai-http'); +const server = require('../server'); +let should = chai.should(); + +chai.use(chaiHttp); + + +//console.log("lol"); +//console.log(server); +describe('course_treatment', () => { + + let courses = [{ + "CourseSer" : "1", + "PatientSer" : "1", + "CourseId" : "1", + "StartDateTime" : "11-11-11 11:11:11", + "ClinicalStatus" : "CS1", + "CompletedByUserName" : "CByU1", + "CompletedDateTime" : "11-11-11 11:11:11", + "Comment" : "Comment1", + "ClinicalProtocolDir" : "CPD1", + "HstryUserName" : "HUN1", + "HstryTimeStamp" : "11-11-11 11:11:11", + "HstryDateTime" : "11-11-11 11:11:11", + "TransactionId" : "1", + "HstryTaskName" : "HTN1" + }]; + it('it should post courses', (done) => { + chai.request(server) + .post('/api/agent/collect/course_treatment') + .send({courses: courses}) + .end((err, res) => { + res.should.have.status(200); + done(); + }); + + }); +}); diff --git a/test/config.js.example b/test/config.js.example new file mode 100644 index 0000000..aaacd5c --- /dev/null +++ b/test/config.js.example @@ -0,0 +1,13 @@ +var config = module.exports = {}; + +config.db_config = { + user: 'user', + password: 'password', + database: 'dbname_test', + host: 'localhost', + port: 5432 +}; + +config.fqdn = 'pinsis.c3sl.ufpr.br'; + +config.agentVersion = 0.0; -- GitLab From 3336c7d35867dc5eb7a35350c85da77a5d633151 Mon Sep 17 00:00:00 2001 From: Davisson Paulino <dhp14@inf.ufpr.br> Date: Mon, 14 Aug 2017 11:17:01 -0300 Subject: [PATCH 07/30] modified collect-webservice to https --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 45054df..9a86ace 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "cuid": "^1.2.4", "bunyan": "^1.0.1", "squel": "^5.10.0", - "collect-webservice": "git+ssh://git@gitlab.c3sl.ufpr.br:c3sl/collect-webservice.git" + "collect-webservice": "git+https://gitlab.c3sl.ufpr.br/c3sl/collect-webservice.git" }, "devDependencies": { "chai": "^4.1.0", -- GitLab From 68e44364976cce9d1a9f6f5244bb006a18781eda Mon Sep 17 00:00:00 2001 From: Davisson Paulino <dhp14@inf.ufpr.br> Date: Mon, 14 Aug 2017 11:31:08 -0300 Subject: [PATCH 08/30] added POSTGRES_USER --- .gitlab-ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f9118f0..29f1735 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,6 +5,7 @@ services: - postgres variables: NODE_ENV: 'test' + POSTGRES_USER: $CI_REGISTRY_USER before_script: - npm install --global mocha gulp @@ -13,10 +14,11 @@ before_script: run_tests: stage: test script: - - mv config.json.example config.json + - mv test/config.js.example test/config.json - gulp test tags: - node + - tags cache: paths: - node_modules/ -- GitLab From 8971975e4301b545e016ed54922a08280b426575 Mon Sep 17 00:00:00 2001 From: Davisson Paulino <dhp14@inf.ufpr.br> Date: Mon, 14 Aug 2017 11:40:28 -0300 Subject: [PATCH 09/30] fixed ci tags --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 29f1735..3cdd215 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -18,7 +18,7 @@ run_tests: - gulp test tags: - node - - tags + - postgres cache: paths: - node_modules/ -- GitLab From 5c67ba2da912e4b62b38c87e5e8c9dc4f534cc92 Mon Sep 17 00:00:00 2001 From: Davisson Paulino <dhp14@inf.ufpr.br> Date: Mon, 14 Aug 2017 11:42:24 -0300 Subject: [PATCH 10/30] fixed ci --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3cdd215..cd8a6c8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -14,7 +14,7 @@ before_script: run_tests: stage: test script: - - mv test/config.js.example test/config.json + - mv test/config.js.example test/config.js - gulp test tags: - node -- GitLab From 9a744546dbedfe556b4173af52847796f8c0d6c4 Mon Sep 17 00:00:00 2001 From: Davisson Paulino <dhp14@inf.ufpr.br> Date: Mon, 14 Aug 2017 11:54:47 -0300 Subject: [PATCH 11/30] fixed ci --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cd8a6c8..8337815 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,11 +5,11 @@ services: - postgres variables: NODE_ENV: 'test' - POSTGRES_USER: $CI_REGISTRY_USER before_script: - npm install --global mocha gulp - npm install + - apt-get install postgresql-contrib run_tests: stage: test -- GitLab From 11c6bc37daa98ca70b9d38ee66ad1bf904787afc Mon Sep 17 00:00:00 2001 From: Davisson Paulino <dhp14@inf.ufpr.br> Date: Mon, 14 Aug 2017 11:56:46 -0300 Subject: [PATCH 12/30] fixed ci --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8337815..425483d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,6 +9,7 @@ variables: before_script: - npm install --global mocha gulp - npm install + - apt-get update - apt-get install postgresql-contrib run_tests: -- GitLab From 9da1faf634db56fdd757053e40536ec974522ab4 Mon Sep 17 00:00:00 2001 From: Davisson Paulino <dhp14@inf.ufpr.br> Date: Mon, 14 Aug 2017 11:58:29 -0300 Subject: [PATCH 13/30] fixed ci --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 425483d..f375614 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,7 +10,7 @@ before_script: - npm install --global mocha gulp - npm install - apt-get update - - apt-get install postgresql-contrib + - apt-get install postgresql-contrib -y run_tests: stage: test -- GitLab From 244d41192e5e2dcb477e803f30c5202da6cd497d Mon Sep 17 00:00:00 2001 From: Davisson Paulino <dhp14@inf.ufpr.br> Date: Tue, 15 Aug 2017 09:19:03 -0300 Subject: [PATCH 14/30] fixed ci --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f375614..c8bb4e4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,6 +11,7 @@ before_script: - npm install - apt-get update - apt-get install postgresql-contrib -y + - /etc/init.d/postgresql start run_tests: stage: test -- GitLab From b3f83bd8c64cb50cc3484135da6564af6aada3aa Mon Sep 17 00:00:00 2001 From: Davisson Paulino <dhp14@inf.ufpr.br> Date: Tue, 15 Aug 2017 10:27:24 -0300 Subject: [PATCH 15/30] fixed ci --- .gitlab-ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c8bb4e4..a514cef 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,7 +12,9 @@ before_script: - apt-get update - apt-get install postgresql-contrib -y - /etc/init.d/postgresql start - + - adduser tester --disabled-password --gecos "" + - su postgres -c "createuser -drS tester" + - su tester run_tests: stage: test script: -- GitLab From 8df46dec725c281a0d0cae44519c042b74ca0da4 Mon Sep 17 00:00:00 2001 From: Davisson Paulino <dhp14@inf.ufpr.br> Date: Tue, 15 Aug 2017 10:32:53 -0300 Subject: [PATCH 16/30] fixed ci --- .gitlab-ci.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a514cef..80d829f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,14 +12,13 @@ before_script: - apt-get update - apt-get install postgresql-contrib -y - /etc/init.d/postgresql start - - adduser tester --disabled-password --gecos "" - - su postgres -c "createuser -drS tester" - - su tester + - adduser tester --disabled-password --gecos "" #create system user to test + - su postgres -c "createuser -drS tester" #create posgresql user with permission to create databases and roles run_tests: stage: test script: - mv test/config.js.example test/config.js - - gulp test + - - su tester -c gulp test tags: - node - postgres -- GitLab From 5dfb049750188482dc52c9d9f9b013fcca5f1d5f Mon Sep 17 00:00:00 2001 From: Davisson Paulino <dhp14@inf.ufpr.br> Date: Tue, 15 Aug 2017 10:35:42 -0300 Subject: [PATCH 17/30] fixed ci --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 80d829f..ec7dc1b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -18,7 +18,7 @@ run_tests: stage: test script: - mv test/config.js.example test/config.js - - - su tester -c gulp test + - su tester -c gulp test tags: - node - postgres -- GitLab From 98cb32afe8e422db0de7e2bb22ba69f4bc0509bf Mon Sep 17 00:00:00 2001 From: Davisson Paulino <dhp14@inf.ufpr.br> Date: Tue, 15 Aug 2017 10:53:25 -0300 Subject: [PATCH 18/30] fixed ci --- .gitlab-ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ec7dc1b..7c67e4b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,13 +12,14 @@ before_script: - apt-get update - apt-get install postgresql-contrib -y - /etc/init.d/postgresql start - - adduser tester --disabled-password --gecos "" #create system user to test - - su postgres -c "createuser -drS tester" #create posgresql user with permission to create databases and roles + #- adduser tester --disabled-password --gecos "" #create system user to test + - su postgres -c "createuser -drS root" #create posgresql user with permission to create databases and roles run_tests: stage: test script: - mv test/config.js.example test/config.js - - su tester -c gulp test + - gulp test + #- su tester -c gulp test tags: - node - postgres -- GitLab From 9b5f7a470f794d9abdecc14e5050c9367f0e4a9d Mon Sep 17 00:00:00 2001 From: Davisson Paulino <dhp14@inf.ufpr.br> Date: Tue, 15 Aug 2017 11:05:56 -0300 Subject: [PATCH 19/30] fixed ci --- config.js.example | 2 -- database/create_user.sh | 2 +- test/config.js.example | 9 +++------ 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/config.js.example b/config.js.example index d611233..ae636fc 100644 --- a/config.js.example +++ b/config.js.example @@ -8,6 +8,4 @@ config.db_config = { port: 5432 }; -config.fqdn = 'pinsis.c3sl.ufpr.br'; - config.agentVersion = 0.0; diff --git a/database/create_user.sh b/database/create_user.sh index d24b0e5..1ed5f05 100755 --- a/database/create_user.sh +++ b/database/create_user.sh @@ -47,7 +47,7 @@ if [[ "$HAS_USER" -eq 0 ]]; then else CREATE_QUERY="CREATE USER \"$USERNAME\" WITH PASSWORD '${PASSWORD}';" - psql -c "${CREATE_QUERY}" + psql -d "$DATABASE_NAME" -c "${CREATE_QUERY}" fi GRANT_QUERY="GRANT ${PRIVILAGES} ON ALL TABLES IN SCHEMA \"${SCHEMA_NAME}\" to \"${USERNAME}\";" diff --git a/test/config.js.example b/test/config.js.example index aaacd5c..bc4bb7e 100644 --- a/test/config.js.example +++ b/test/config.js.example @@ -1,13 +1,10 @@ var config = module.exports = {}; config.db_config = { - user: 'user', - password: 'password', - database: 'dbname_test', + user: 'test', + password: 'test', + database: 'test', host: 'localhost', port: 5432 }; - -config.fqdn = 'pinsis.c3sl.ufpr.br'; - config.agentVersion = 0.0; -- GitLab From 319d892d30d975cde21089a213bee76b99081cbf Mon Sep 17 00:00:00 2001 From: Davisson Paulino <dhp14@inf.ufpr.br> Date: Tue, 15 Aug 2017 11:50:41 -0300 Subject: [PATCH 20/30] fixed ci --- .gitlab-ci.yml | 2 - database/pg_hba.conf | 100 ------------------ gulpfile.js | 8 +- .../create/schema/bd.sql | 0 .../create_database.sh | 27 ----- {database => scripts_database}/create_user.sh | 0 6 files changed, 4 insertions(+), 133 deletions(-) delete mode 100644 database/pg_hba.conf rename {database => scripts_database}/create/schema/bd.sql (100%) rename database/create.sh => scripts_database/create_database.sh (71%) rename {database => scripts_database}/create_user.sh (100%) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7c67e4b..3d36836 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,14 +12,12 @@ before_script: - apt-get update - apt-get install postgresql-contrib -y - /etc/init.d/postgresql start - #- adduser tester --disabled-password --gecos "" #create system user to test - su postgres -c "createuser -drS root" #create posgresql user with permission to create databases and roles run_tests: stage: test script: - mv test/config.js.example test/config.js - gulp test - #- su tester -c gulp test tags: - node - postgres diff --git a/database/pg_hba.conf b/database/pg_hba.conf deleted file mode 100644 index 4a544e6..0000000 --- a/database/pg_hba.conf +++ /dev/null @@ -1,100 +0,0 @@ -# PostgreSQL Client Authentication Configuration File -# =================================================== -# -# Refer to the "Client Authentication" section in the PostgreSQL -# documentation for a complete description of this file. A short -# synopsis follows. -# -# This file controls: which hosts are allowed to connect, how clients -# are authenticated, which PostgreSQL user names they can use, which -# databases they can access. Records take one of these forms: -# -# local DATABASE USER METHOD [OPTIONS] -# host DATABASE USER ADDRESS METHOD [OPTIONS] -# hostssl DATABASE USER ADDRESS METHOD [OPTIONS] -# hostnossl DATABASE USER ADDRESS METHOD [OPTIONS] -# -# (The uppercase items must be replaced by actual values.) -# -# The first field is the connection type: "local" is a Unix-domain -# socket, "host" is either a plain or SSL-encrypted TCP/IP socket, -# "hostssl" is an SSL-encrypted TCP/IP socket, and "hostnossl" is a -# plain TCP/IP socket. -# -# DATABASE can be "all", "sameuser", "samerole", "replication", a -# database name, or a comma-separated list thereof. The "all" -# keyword does not match "replication". Access to replication -# must be enabled in a separate record (see example below). -# -# USER can be "all", a user name, a group name prefixed with "+", or a -# comma-separated list thereof. In both the DATABASE and USER fields -# you can also write a file name prefixed with "@" to include names -# from a separate file. -# -# ADDRESS specifies the set of hosts the record matches. It can be a -# host name, or it is made up of an IP address and a CIDR mask that is -# an integer (between 0 and 32 (IPv4) or 128 (IPv6) inclusive) that -# specifies the number of significant bits in the mask. A host name -# that starts with a dot (.) matches a suffix of the actual host name. -# Alternatively, you can write an IP address and netmask in separate -# columns to specify the set of hosts. Instead of a CIDR-address, you -# can write "samehost" to match any of the server's own IP addresses, -# or "samenet" to match any address in any subnet that the server is -# directly connected to. -# -# METHOD can be "trust", "reject", "md5", "password", "gss", "sspi", -# "ident", "peer", "pam", "ldap", "radius" or "cert". Note that -# "password" sends passwords in clear text; "md5" is preferred since -# it sends encrypted passwords. -# -# OPTIONS are a set of options for the authentication in the format -# NAME=VALUE. The available options depend on the different -# authentication methods -- refer to the "Client Authentication" -# section in the documentation for a list of which options are -# available for which authentication methods. -# -# Database and user names containing spaces, commas, quotes and other -# special characters must be quoted. Quoting one of the keywords -# "all", "sameuser", "samerole" or "replication" makes the name lose -# its special character, and just match a database or username with -# that name. -# -# This file is read on server startup and when the postmaster receives -# a SIGHUP signal. If you edit the file on a running system, you have -# to SIGHUP the postmaster for the changes to take effect. You can -# use "pg_ctl reload" to do that. - -# Put your actual configuration here -# ---------------------------------- -# -# If you want to allow non-local connections, you need to add more -# "host" records. In that case you will also need to make PostgreSQL -# listen on a non-local interface via the listen_addresses -# configuration parameter, or via the -i or -h command line switches. - - - - -# DO NOT DISABLE! -# If you change this first entry you will need to make sure that the -# database superuser can access the database using some other method. -# Noninteractive access to all databases is required during automatic -# maintenance (custom daily cronjobs, replication, and similar tasks). -# -# Database administrative login by Unix domain socket -local all postgres peer - -local all user md5 -# TYPE DATABASE USER ADDRESS METHOD - -# "local" is for Unix domain socket connections only -local all all peer -# IPv4 local connections: -host all all 127.0.0.1/32 md5 -# IPv6 local connections: -host all all ::1/128 md5 -# Allow replication connections from localhost, by a user with the -# replication privilege. -#local replication postgres peer -#host replication postgres 127.0.0.1/32 md5 -#host replication postgres ::1/128 md5 diff --git a/gulpfile.js b/gulpfile.js index b385c65..1228d96 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -13,6 +13,7 @@ var dev_config_file = './config.js'; var test_config_file = './test/config.js'; //var config = require(configFile); + // define the default task and add the watch task to it gulp.task('default', ['run','watch']); @@ -38,9 +39,9 @@ gulp.task('create_database_test', function(){ var config = require(test_config_file); - return gulp.src("database") - .pipe(shell("./database/create.sh " + config.db_config.database)) - .pipe(shell("./database/create_user.sh " + config.db_config.user + " " + config.db_config.password + " " + config.db_config.database )); + return gulp.src("scripts_database") + .pipe(shell("./scripts_database/create_database.sh " + config.db_config.database)) + .pipe(shell("./scripts_database/create_user.sh " + config.db_config.user + " " + config.db_config.password + " " + config.db_config.database )); }); gulp.task('test',['create_database_test'], function(){ return gulp.src(['test/*.js']) @@ -50,7 +51,6 @@ gulp.task('test',['create_database_test'], function(){ }); -// gulp.task('test', ['create_database','mocha']) module.exports = gulp; diff --git a/database/create/schema/bd.sql b/scripts_database/create/schema/bd.sql similarity index 100% rename from database/create/schema/bd.sql rename to scripts_database/create/schema/bd.sql diff --git a/database/create.sh b/scripts_database/create_database.sh similarity index 71% rename from database/create.sh rename to scripts_database/create_database.sh index ad7b98f..4f48ea1 100755 --- a/database/create.sh +++ b/scripts_database/create_database.sh @@ -20,7 +20,6 @@ # USA. -#TODO:PASS THE USER AS ARGV #DB_LINK_LOCATION=/usr/share/postgresql/9.1/extension/dblink.sql #DATABASE_DIR=$(pwd) @@ -47,7 +46,6 @@ fi function error_exit() { dropdb $DB_NAME - # dropuser $DB_NAME exit 1 } @@ -59,7 +57,6 @@ if psql -lqt | cut -d \| -f 1 | grep -qw "$DB_NAME"; then y | Y | yes | YES ) echo "Dropping database $DB_NAME" dropdb $DB_NAME - # dropuser $DB_NAME ;; * ) echo "Exiting script." @@ -68,18 +65,10 @@ if psql -lqt | cut -d \| -f 1 | grep -qw "$DB_NAME"; then esac fi -# create user -#echo "INFO: Creating user: $DB_NAME"; -#createuser -DRS $DB_NAME || error_exit - # create db echo "INFO: Creating database: $DB_NAME"; createdb $DB_NAME -# importing extensions -#psql $DB_NAME -c 'CREATE EXTENSION IF NOT EXISTS dblink;' -#psql $DB_NAME -c 'CREATE EXTENSION IF NOT EXISTS pgcrypto;' -#psql $DB_NAME -c 'CREATE EXTENSION IF NOT EXISTS postgi s;' # creating database tables and structure echo "INFO: Creating database tables and structure"; @@ -87,19 +76,3 @@ for file in $(ls -B "${SCHEMA_DIR}"); do echo "--- Executing: $file"; psql -d $DB_NAME -f $SCHEMA_DIR$file || error_exit done - -# restore database data -# echo "INFO: Restoring database data"; -# for file in $(ls -B "${DATA_DIR}"); do -# echo "--- Executing: $file"; -# psql $DB_NAME -f $file -v DATABASE_DIR="$DATABASE_DIR" || error_exit -# done - -# Create functions and views that are needed for the rest of the process -#psql $DB_NAME -f functions/db_versioning.sql || error_exit - -# upgrade schmema and create functions -#./upgrade.sh -d $DB_NAME - -# installing crontab -#./cron.sh $DB_NAME diff --git a/database/create_user.sh b/scripts_database/create_user.sh similarity index 100% rename from database/create_user.sh rename to scripts_database/create_user.sh -- GitLab From af32c29712e87eae892697a537f41ced6c45c60f Mon Sep 17 00:00:00 2001 From: Davisson Paulino <dhp14@inf.ufpr.br> Date: Thu, 17 Aug 2017 10:41:39 -0300 Subject: [PATCH 21/30] fix jshint errors --- db/query_builder.js | 4 +-- gulpfile.js | 6 ++-- lib/logger.js | 7 ++-- lib/mail.js | 37 ------------------- lib/utils.js | 88 --------------------------------------------- middleware/cache.js | 2 +- middleware/db.js | 2 +- package.json | 2 +- routes/agent.js | 52 ++------------------------- server.js | 9 ++--- 10 files changed, 21 insertions(+), 188 deletions(-) delete mode 100644 lib/mail.js delete mode 100644 lib/utils.js diff --git a/db/query_builder.js b/db/query_builder.js index c2a50e8..6911888 100644 --- a/db/query_builder.js +++ b/db/query_builder.js @@ -17,5 +17,5 @@ module.exports = function(){ this.set_from_attr(q, obj); return q; } - } -} + }; +}; diff --git a/gulpfile.js b/gulpfile.js index 1228d96..cadecc7 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -19,8 +19,10 @@ gulp.task('default', ['run','watch']); // configure the jshint task gulp.task('jshint', function() { - return gulp.src([js_files, "!node_modules/**/*.js"]) - .pipe(jshint()) + return gulp.src([js_files, "!node_modules/**/*.js", "!coverage/*"]) + .pipe(jshint({ + "esversion": 6 + })) .pipe(jshint.reporter('jshint-stylish')); }); diff --git a/lib/logger.js b/lib/logger.js index cfd4c5b..fc62ffb 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -20,6 +20,7 @@ * USA. */ +/*jshint sub:true*/ var os = require('os'); var cluster = require('cluster'); @@ -69,7 +70,7 @@ function responseSerializer(res) { return { statusCode: res.statusCode, responseTime: responseTime - } + }; } // Make sure the logs dir exist @@ -125,7 +126,7 @@ exports.expressAccess = function (req, res, next) { // Log the response req.log.debug({res: res}, 'response'); -} +}; // Export the express error logger (log errors during request processing) exports.expressError = function (err, req, res, next) { @@ -134,4 +135,4 @@ exports.expressError = function (err, req, res, next) { } next(); -} +}; diff --git a/lib/mail.js b/lib/mail.js deleted file mode 100644 index 602c5cd..0000000 --- a/lib/mail.js +++ /dev/null @@ -1,37 +0,0 @@ -var nodemailer = require('nodemailer'); -var smtpTransport = require('nodemailer-smtp-transport'); -var htmlToText = require('nodemailer-html-to-text').htmlToText; - -module.exports = function(config) { - - var options = smtpTransport({ - port: config.port - , host: config.host - , ignoreTLS: config.ignoreTLS - , secure: config.secure - }); - - // create reusable transporter object using SMTP transport - var transporter = nodemailer.createTransport(options); - - // set transporter to compile html do text automagically - transporter.use('compile', htmlToText()); - - // NB! No need to recreate the transporter object. You can use - // the same transporter object for all e-mails - - // setup e-mail data with unicode symbols - var mail = { - from: config.from // sender address - }; - - return { - send: function(to, subject, html, callback) { - // send mail with defined transport object - mail.to = to; - mail.subject = subject; - mail.html = html; - transporter.sendMail(mail, callback); - } - }; -}; diff --git a/lib/utils.js b/lib/utils.js deleted file mode 100644 index 59659ae..0000000 --- a/lib/utils.js +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2012 Centro de Computacao Cientifica e Software Livre - * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR - * - * This file is part of simmc - * - * simmc is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ - -var crypto = require('crypto'); - -// Returns a filename starting with prefix (if not null) plus a md5-hash -// representing the obj given as argument, with "ext" as extension. -exports.hashFilename = function(prefix, obj, ext) { - var txt = ""; - for (i in obj) { - txt += i + obj[i] - } - var hash = crypto.createHash('md5').update(txt).digest('hex'); - return (prefix? prefix + '_' + hash : hash) + '.' + ext; -}; - -// returns a filename in the format: type project_date(day+month+year+'_'+hours+minutes).ext -exports.reportFilename = function(prefix, ext) { - var date = formatDateReport(new Date()); - return prefix+ '_'+ date + '.' + ext; -}; - -// returns the date in the format day+month+year_hours+minutes -function formatDateReport(date) { - var day = date.getUTCDate(), - month = date.getUTCMonth() + 1, //Months are zero based - year = date.getUTCFullYear(), - hours = date.getHours(), - minutes = date.getMinutes(); - - if (day < 10) day = '0' + day; - if (month < 10) month = '0' + month; - if (hours < 10) hours = '0' + hours; - if (minutes < 10) minutes = '0' + minutes; - - return day + month + year + '_' + hours + minutes; -} - - -// returns the sum of every element in a array or object -exports.sum = function(x) { - var total = 0; - if (x.constructor == Array) { - for (var i=0; i<x.length; i++) { - total += x[i]; - } - } else { - for (var i in x) { - total += x[i]; - } - } - return total; -} - -exports.checkEmail = function(email) { - if (email.length < 4) { - return "Email deve conter pelo menos 4 caracteres."; - } - - if (email.length > 255) { - return "Email deve conter no máximo 255 caracteres."; - } - - if (!email.match(/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/)) { - return "Email não está em um formato válido."; - } - - return false; -} diff --git a/middleware/cache.js b/middleware/cache.js index e880990..a9df833 100644 --- a/middleware/cache.js +++ b/middleware/cache.js @@ -27,7 +27,7 @@ module.exports = function (config) { res.cache = function (data, cb) { if (config.debug) console.log('caching '+req.url); memcached.set(req.url, data, config.lifetime || 3600, cb || function (err) {}); - } + }; next(); } diff --git a/middleware/db.js b/middleware/db.js index 5f70a27..4893254 100644 --- a/middleware/db.js +++ b/middleware/db.js @@ -165,4 +165,4 @@ function Connection(client) { }); }; }; -}; +} diff --git a/package.json b/package.json index 9a86ace..568e9a9 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "gulp-jshint": "^2.0.4", "gulp-mocha": "^4.3.1", "gulp-shell": "^0.6.3", - "jshint": "^2.9.5", + "jshint": "latest", "jshint-stylish": "^2.2.1", "mocha": "^3.5.0", "nyc": "^11.1.0" diff --git a/routes/agent.js b/routes/agent.js index 937da83..c600641 100644 --- a/routes/agent.js +++ b/routes/agent.js @@ -24,44 +24,6 @@ var async = require('async'); -var routes = { - /*"net_usage": { - validation: function(body) { - if(!body) { - return false; -} -else { -var keys = [ -'id_point', -'mac_address', -'bytes_recived', -'bytes_transmited', -'collect_time', -'packets_recived', -'packets_transmited', -]; -return isSubSet(Object.keys(body), keys); -} -}, -parser: function(body) { -return [ -dateFormat(new Date()), -body.id_point, -body.mac_address, -dateFormat(body.collect_time), -timeFormat(body.collect_time), -body.bytes_recived, -body.packets_recived, -body.bytes_transmited, -body.packets_transmited, -]; -}, -query: 'collect/net_usage.sql' -}*/ -}; - - - module.exports = function(agentVersion) { qb = require("../db/query_builder.js")(); @@ -99,18 +61,10 @@ module.exports = function(agentVersion) { async.waterfall([ conn.transaction, function(callback) { - async.everyLimit(queries, 1, async function(q){ - try{ - await conn.query(q.toParam().text, q.toParam().values); - return true; - }catch(err){ - callback(err); - return false; - } + async.everySeries(queries, function(q, cb){ + conn.query(q.toParam().text, q.toParam().values, cb); }, function(err, result){ - if(result){ - callback(null); - } + callback(err); }); }, conn.commit diff --git a/server.js b/server.js index 4c91136..5709341 100644 --- a/server.js +++ b/server.js @@ -167,6 +167,11 @@ app.get('/api/agent/version', agent.version); +var exit = function exit() { + log.info('Server exiting...'); + + process.exit(0); +}; // // Fork process @@ -195,11 +200,7 @@ if (cluster.isMaster) { } }); - function exit() { - log.info('Server exiting...'); - process.exit(0); - } process.on('SIGTERM', exit); process.on('SIGHUP', exit); -- GitLab From 6c942c64dc049c0abd7bc6b5c1dcc909de7a1e75 Mon Sep 17 00:00:00 2001 From: Davisson Paulino <dhp14@inf.ufpr.br> Date: Thu, 17 Aug 2017 10:50:50 -0300 Subject: [PATCH 22/30] fix utils.js error --- server.js | 1 - 1 file changed, 1 deletion(-) diff --git a/server.js b/server.js index 5709341..6937d5f 100644 --- a/server.js +++ b/server.js @@ -117,7 +117,6 @@ var log = logger.default; // var db = require('./middleware/db.js'); -var utils = require('./lib/utils.js'); // // Routes -- GitLab From 4f890968233d76a13f190f764e154b1b6eeec6bb Mon Sep 17 00:00:00 2001 From: Davisson Paulino <dhp14@inf.ufpr.br> Date: Fri, 18 Aug 2017 10:33:45 -0300 Subject: [PATCH 23/30] coverage running --- .gitignore | 2 + ...onfig.js.example => config_test.js.example | 0 coverage/base.css | 212 ---- coverage/index.html | 158 --- coverage/prettify.css | 1 - coverage/prettify.js | 1 - coverage/sort-arrow-sprite.png | Bin 209 -> 0 bytes coverage/sorter.js | 158 --- coverage/webservice-pinsis/config.js.html | 104 -- coverage/webservice-pinsis/db/index.html | 93 -- .../db/query_builder.js.html | 128 --- coverage/webservice-pinsis/index.html | 106 -- coverage/webservice-pinsis/lib/index.html | 106 -- coverage/webservice-pinsis/lib/logger.js.html | 476 -------- coverage/webservice-pinsis/lib/utils.js.html | 329 ------ .../webservice-pinsis/middleware/db.js.html | 569 ---------- .../webservice-pinsis/middleware/index.html | 93 -- .../webservice-pinsis/routes/agent.js.html | 464 -------- coverage/webservice-pinsis/routes/index.html | 106 -- .../webservice-pinsis/routes/ping.js.html | 164 --- coverage/webservice-pinsis/server.js.html | 743 ------------ .../validation/course_treatment.js.html | 1001 ----------------- .../webservice-pinsis/validation/index.html | 93 -- .../create/schema/bd.sql | 0 .../create_database.sh | 0 {scripts_database => database}/create_user.sh | 0 gulpfile.js | 57 +- lib/agentbuilder.js | 35 - middleware/cache.js | 37 - package.json | 4 +- Dockerfile => src/Dockerfile | 0 {db => src/db}/query_builder.js | 0 {lib => src/lib}/logger.js | 0 {middleware => src/middleware}/db.js | 0 {routes => src/routes}/agent.js | 0 {routes => src/routes}/ping.js | 0 server.js => src/server.js | 2 +- .../validation}/course_treatment.js | 0 test/agent.js | 2 +- 39 files changed, 50 insertions(+), 5194 deletions(-) rename test/config.js.example => config_test.js.example (100%) delete mode 100644 coverage/base.css delete mode 100644 coverage/index.html delete mode 100644 coverage/prettify.css delete mode 100644 coverage/prettify.js delete mode 100644 coverage/sort-arrow-sprite.png delete mode 100644 coverage/sorter.js delete mode 100644 coverage/webservice-pinsis/config.js.html delete mode 100644 coverage/webservice-pinsis/db/index.html delete mode 100644 coverage/webservice-pinsis/db/query_builder.js.html delete mode 100644 coverage/webservice-pinsis/index.html delete mode 100644 coverage/webservice-pinsis/lib/index.html delete mode 100644 coverage/webservice-pinsis/lib/logger.js.html delete mode 100644 coverage/webservice-pinsis/lib/utils.js.html delete mode 100644 coverage/webservice-pinsis/middleware/db.js.html delete mode 100644 coverage/webservice-pinsis/middleware/index.html delete mode 100644 coverage/webservice-pinsis/routes/agent.js.html delete mode 100644 coverage/webservice-pinsis/routes/index.html delete mode 100644 coverage/webservice-pinsis/routes/ping.js.html delete mode 100644 coverage/webservice-pinsis/server.js.html delete mode 100644 coverage/webservice-pinsis/validation/course_treatment.js.html delete mode 100644 coverage/webservice-pinsis/validation/index.html rename {scripts_database => database}/create/schema/bd.sql (100%) rename {scripts_database => database}/create_database.sh (100%) rename {scripts_database => database}/create_user.sh (100%) delete mode 100644 lib/agentbuilder.js delete mode 100644 middleware/cache.js rename Dockerfile => src/Dockerfile (100%) rename {db => src/db}/query_builder.js (100%) rename {lib => src/lib}/logger.js (100%) rename {middleware => src/middleware}/db.js (100%) rename {routes => src/routes}/agent.js (100%) rename {routes => src/routes}/ping.js (100%) rename server.js => src/server.js (99%) rename {validation => src/validation}/course_treatment.js (100%) diff --git a/.gitignore b/.gitignore index bbd1eea..40bc57b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,9 @@ node_modules/ config.js +config_test.js logs/ *.swp nohup.out package-lock.json +coverage/ .nyc_output/ diff --git a/test/config.js.example b/config_test.js.example similarity index 100% rename from test/config.js.example rename to config_test.js.example diff --git a/coverage/base.css b/coverage/base.css deleted file mode 100644 index 417c7ad..0000000 --- a/coverage/base.css +++ /dev/null @@ -1,212 +0,0 @@ -body, html { - margin:0; padding: 0; - height: 100%; -} -body { - font-family: Helvetica Neue, Helvetica, Arial; - font-size: 14px; - color:#333; -} -.small { font-size: 12px; } -*, *:after, *:before { - -webkit-box-sizing:border-box; - -moz-box-sizing:border-box; - box-sizing:border-box; - } -h1 { font-size: 20px; margin: 0;} -h2 { font-size: 14px; } -pre { - font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace; - margin: 0; - padding: 0; - -moz-tab-size: 2; - -o-tab-size: 2; - tab-size: 2; -} -a { color:#0074D9; text-decoration:none; } -a:hover { text-decoration:underline; } -.strong { font-weight: bold; } -.space-top1 { padding: 10px 0 0 0; } -.pad2y { padding: 20px 0; } -.pad1y { padding: 10px 0; } -.pad2x { padding: 0 20px; } -.pad2 { padding: 20px; } -.pad1 { padding: 10px; } -.space-left2 { padding-left:55px; } -.space-right2 { padding-right:20px; } -.center { text-align:center; } -.clearfix { display:block; } -.clearfix:after { - content:''; - display:block; - height:0; - clear:both; - visibility:hidden; - } -.fl { float: left; } -@media only screen and (max-width:640px) { - .col3 { width:100%; max-width:100%; } - .hide-mobile { display:none!important; } -} - -.quiet { - color: #7f7f7f; - color: rgba(0,0,0,0.5); -} -.quiet a { opacity: 0.7; } - -.fraction { - font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; - font-size: 10px; - color: #555; - background: #E8E8E8; - padding: 4px 5px; - border-radius: 3px; - vertical-align: middle; -} - -div.path a:link, div.path a:visited { color: #333; } -table.coverage { - border-collapse: collapse; - margin: 10px 0 0 0; - padding: 0; -} - -table.coverage td { - margin: 0; - padding: 0; - vertical-align: top; -} -table.coverage td.line-count { - text-align: right; - padding: 0 5px 0 20px; -} -table.coverage td.line-coverage { - text-align: right; - padding-right: 10px; - min-width:20px; -} - -table.coverage td span.cline-any { - display: inline-block; - padding: 0 5px; - width: 100%; -} -.missing-if-branch { - display: inline-block; - margin-right: 5px; - border-radius: 3px; - position: relative; - padding: 0 4px; - background: #333; - color: yellow; -} - -.skip-if-branch { - display: none; - margin-right: 10px; - position: relative; - padding: 0 4px; - background: #ccc; - color: white; -} -.missing-if-branch .typ, .skip-if-branch .typ { - color: inherit !important; -} -.coverage-summary { - border-collapse: collapse; - width: 100%; -} -.coverage-summary tr { border-bottom: 1px solid #bbb; } -.keyline-all { border: 1px solid #ddd; } -.coverage-summary td, .coverage-summary th { padding: 10px; } -.coverage-summary tbody { border: 1px solid #bbb; } -.coverage-summary td { border-right: 1px solid #bbb; } -.coverage-summary td:last-child { border-right: none; } -.coverage-summary th { - text-align: left; - font-weight: normal; - white-space: nowrap; -} -.coverage-summary th.file { border-right: none !important; } -.coverage-summary th.pct { } -.coverage-summary th.pic, -.coverage-summary th.abs, -.coverage-summary td.pct, -.coverage-summary td.abs { text-align: right; } -.coverage-summary td.file { white-space: nowrap; } -.coverage-summary td.pic { min-width: 120px !important; } -.coverage-summary tfoot td { } - -.coverage-summary .sorter { - height: 10px; - width: 7px; - display: inline-block; - margin-left: 0.5em; - background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent; -} -.coverage-summary .sorted .sorter { - background-position: 0 -20px; -} -.coverage-summary .sorted-desc .sorter { - background-position: 0 -10px; -} -.status-line { height: 10px; } -/* dark red */ -.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 } -.low .chart { border:1px solid #C21F39 } -/* medium red */ -.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE } -/* light red */ -.low, .cline-no { background:#FCE1E5 } -/* light green */ -.high, .cline-yes { background:rgb(230,245,208) } -/* medium green */ -.cstat-yes { background:rgb(161,215,106) } -/* dark green */ -.status-line.high, .high .cover-fill { background:rgb(77,146,33) } -.high .chart { border:1px solid rgb(77,146,33) } - - -.medium .chart { border:1px solid #666; } -.medium .cover-fill { background: #666; } - -.cbranch-no { background: yellow !important; color: #111; } - -.cstat-skip { background: #ddd; color: #111; } -.fstat-skip { background: #ddd; color: #111 !important; } -.cbranch-skip { background: #ddd !important; color: #111; } - -span.cline-neutral { background: #eaeaea; } -.medium { background: #eaeaea; } - -.cover-fill, .cover-empty { - display:inline-block; - height: 12px; -} -.chart { - line-height: 0; -} -.cover-empty { - background: white; -} -.cover-full { - border-right: none !important; -} -pre.prettyprint { - border: none !important; - padding: 0 !important; - margin: 0 !important; -} -.com { color: #999 !important; } -.ignore-none { color: #999; font-weight: normal; } - -.wrapper { - min-height: 100%; - height: auto !important; - height: 100%; - margin: 0 auto -48px; -} -.footer, .push { - height: 48px; -} diff --git a/coverage/index.html b/coverage/index.html deleted file mode 100644 index 91daeca..0000000 --- a/coverage/index.html +++ /dev/null @@ -1,158 +0,0 @@ -<!doctype html> -<html lang="en"> -<head> - <title>Code coverage report for All files</title> - <meta charset="utf-8" /> - <link rel="stylesheet" href="prettify.css" /> - <link rel="stylesheet" href="base.css" /> - <meta name="viewport" content="width=device-width, initial-scale=1"> - <style type='text/css'> - .coverage-summary .sorter { - background-image: url(sort-arrow-sprite.png); - } - </style> -</head> -<body> -<div class='wrapper'> - <div class='pad1'> - <h1> - All files - </h1> - <div class='clearfix'> - <div class='fl pad1y space-right2'> - <span class="strong">53.92% </span> - <span class="quiet">Statements</span> - <span class='fraction'>172/319</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">46.56% </span> - <span class="quiet">Branches</span> - <span class='fraction'>61/131</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">45% </span> - <span class="quiet">Functions</span> - <span class='fraction'>27/60</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">54.78% </span> - <span class="quiet">Lines</span> - <span class='fraction'>172/314</span> - </div> - </div> - </div> - <div class='status-line medium'></div> -<div class="pad1"> -<table class="coverage-summary"> -<thead> -<tr> - <th data-col="file" data-fmt="html" data-html="true" class="file">File</th> - <th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th> - <th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th> - <th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th> - <th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th> - <th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th> - <th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th> - <th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th> - <th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th> - <th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th> -</tr> -</thead> -<tbody><tr> - <td class="file medium" data-value="webservice-pinsis"><a href="webservice-pinsis/index.html">webservice-pinsis</a></td> - <td data-value="62.5" class="pic medium"><div class="chart"><div class="cover-fill" style="width: 62%;"></div><div class="cover-empty" style="width:38%;"></div></div></td> - <td data-value="62.5" class="pct medium">62.5%</td> - <td data-value="96" class="abs medium">60/96</td> - <td data-value="62.96" class="pct medium">62.96%</td> - <td data-value="54" class="abs medium">34/54</td> - <td data-value="33.33" class="pct low">33.33%</td> - <td data-value="3" class="abs low">1/3</td> - <td data-value="62.5" class="pct medium">62.5%</td> - <td data-value="96" class="abs medium">60/96</td> - </tr> - -<tr> - <td class="file high" data-value="webservice-pinsis/db"><a href="webservice-pinsis/db/index.html">webservice-pinsis/db</a></td> - <td data-value="100" class="pic high"><div class="chart"><div class="cover-fill cover-full" style="width: 100%;"></div><div class="cover-empty" style="width:0%;"></div></div></td> - <td data-value="100" class="pct high">100%</td> - <td data-value="10" class="abs high">10/10</td> - <td data-value="50" class="pct medium">50%</td> - <td data-value="2" class="abs medium">1/2</td> - <td data-value="100" class="pct high">100%</td> - <td data-value="3" class="abs high">3/3</td> - <td data-value="100" class="pct high">100%</td> - <td data-value="10" class="abs high">10/10</td> - </tr> - -<tr> - <td class="file low" data-value="webservice-pinsis/lib"><a href="webservice-pinsis/lib/index.html">webservice-pinsis/lib</a></td> - <td data-value="41.67" class="pic low"><div class="chart"><div class="cover-fill" style="width: 41%;"></div><div class="cover-empty" style="width:59%;"></div></div></td> - <td data-value="41.67" class="pct low">41.67%</td> - <td data-value="72" class="abs low">30/72</td> - <td data-value="30.77" class="pct low">30.77%</td> - <td data-value="39" class="abs low">12/39</td> - <td data-value="33.33" class="pct low">33.33%</td> - <td data-value="9" class="abs low">3/9</td> - <td data-value="44.12" class="pct low">44.12%</td> - <td data-value="68" class="abs low">30/68</td> - </tr> - -<tr> - <td class="file low" data-value="webservice-pinsis/middleware"><a href="webservice-pinsis/middleware/index.html">webservice-pinsis/middleware</a></td> - <td data-value="44.44" class="pic low"><div class="chart"><div class="cover-fill" style="width: 44%;"></div><div class="cover-empty" style="width:56%;"></div></div></td> - <td data-value="44.44" class="pct low">44.44%</td> - <td data-value="90" class="abs low">40/90</td> - <td data-value="36.36" class="pct low">36.36%</td> - <td data-value="22" class="abs low">8/22</td> - <td data-value="38.71" class="pct low">38.71%</td> - <td data-value="31" class="abs low">12/31</td> - <td data-value="44.94" class="pct low">44.94%</td> - <td data-value="89" class="abs low">40/89</td> - </tr> - -<tr> - <td class="file medium" data-value="webservice-pinsis/routes"><a href="webservice-pinsis/routes/index.html">webservice-pinsis/routes</a></td> - <td data-value="59.57" class="pic medium"><div class="chart"><div class="cover-fill" style="width: 59%;"></div><div class="cover-empty" style="width:41%;"></div></div></td> - <td data-value="59.57" class="pct medium">59.57%</td> - <td data-value="47" class="abs medium">28/47</td> - <td data-value="42.86" class="pct low">42.86%</td> - <td data-value="14" class="abs low">6/14</td> - <td data-value="58.33" class="pct medium">58.33%</td> - <td data-value="12" class="abs medium">7/12</td> - <td data-value="59.57" class="pct medium">59.57%</td> - <td data-value="47" class="abs medium">28/47</td> - </tr> - -<tr> - <td class="file high" data-value="webservice-pinsis/validation"><a href="webservice-pinsis/validation/index.html">webservice-pinsis/validation</a></td> - <td data-value="100" class="pic high"><div class="chart"><div class="cover-fill cover-full" style="width: 100%;"></div><div class="cover-empty" style="width:0%;"></div></div></td> - <td data-value="100" class="pct high">100%</td> - <td data-value="4" class="abs high">4/4</td> - <td data-value="100" class="pct high">100%</td> - <td data-value="0" class="abs high">0/0</td> - <td data-value="50" class="pct medium">50%</td> - <td data-value="2" class="abs medium">1/2</td> - <td data-value="100" class="pct high">100%</td> - <td data-value="4" class="abs high">4/4</td> - </tr> - -</tbody> -</table> -</div><div class='push'></div><!-- for sticky footer --> -</div><!-- /wrapper --> -<div class='footer quiet pad2 space-top1 center small'> - Code coverage - generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu Aug 10 2017 11:42:01 GMT-0300 (BRT) -</div> -</div> -<script src="prettify.js"></script> -<script> -window.onload = function () { - if (typeof prettyPrint === 'function') { - prettyPrint(); - } -}; -</script> -<script src="sorter.js"></script> -</body> -</html> diff --git a/coverage/prettify.css b/coverage/prettify.css deleted file mode 100644 index b317a7c..0000000 --- a/coverage/prettify.css +++ /dev/null @@ -1 +0,0 @@ -.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} diff --git a/coverage/prettify.js b/coverage/prettify.js deleted file mode 100644 index ef51e03..0000000 --- a/coverage/prettify.js +++ /dev/null @@ -1 +0,0 @@ -window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V<U;++V){var ae=Z[V];if(ae.ignoreCase){ac=true}else{if(/[a-z]/i.test(ae.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){S=true;ac=false;break}}}var Y={b:8,t:9,n:10,v:11,f:12,r:13};function ab(ah){var ag=ah.charCodeAt(0);if(ag!==92){return ag}var af=ah.charAt(1);ag=Y[af];if(ag){return ag}else{if("0"<=af&&af<="7"){return parseInt(ah.substring(1),8)}else{if(af==="u"||af==="x"){return parseInt(ah.substring(2),16)}else{return ah.charCodeAt(1)}}}}function T(af){if(af<32){return(af<16?"\\x0":"\\x")+af.toString(16)}var ag=String.fromCharCode(af);if(ag==="\\"||ag==="-"||ag==="["||ag==="]"){ag="\\"+ag}return ag}function X(am){var aq=am.substring(1,am.length-1).match(new RegExp("\\\\u[0-9A-Fa-f]{4}|\\\\x[0-9A-Fa-f]{2}|\\\\[0-3][0-7]{0,2}|\\\\[0-7]{1,2}|\\\\[\\s\\S]|-|[^-\\\\]","g"));var ak=[];var af=[];var ao=aq[0]==="^";for(var ar=ao?1:0,aj=aq.length;ar<aj;++ar){var ah=aq[ar];if(/\\[bdsw]/i.test(ah)){ak.push(ah)}else{var ag=ab(ah);var al;if(ar+2<aj&&"-"===aq[ar+1]){al=ab(aq[ar+2]);ar+=2}else{al=ag}af.push([ag,al]);if(!(al<65||ag>122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;ar<af.length;++ar){var at=af[ar];if(at[0]<=ap[1]+1){ap[1]=Math.max(ap[1],at[1])}else{ai.push(ap=at)}}var an=["["];if(ao){an.push("^")}an.push.apply(an,ak);for(var ar=0;ar<ai.length;++ar){var at=ai[ar];an.push(T(at[0]));if(at[1]>at[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak<ah;++ak){var ag=aj[ak];if(ag==="("){++am}else{if("\\"===ag.charAt(0)){var af=+ag.substring(1);if(af&&af<=am){an[af]=-1}}}}for(var ak=1;ak<an.length;++ak){if(-1===an[ak]){an[ak]=++ad}}for(var ak=0,am=0;ak<ah;++ak){var ag=aj[ak];if(ag==="("){++am;if(an[am]===undefined){aj[ak]="(?:"}}else{if("\\"===ag.charAt(0)){var af=+ag.substring(1);if(af&&af<=am){aj[ak]="\\"+an[am]}}}}for(var ak=0,am=0;ak<ah;++ak){if("^"===aj[ak]&&"^"!==aj[ak+1]){aj[ak]=""}}if(al.ignoreCase&&S){for(var ak=0;ak<ah;++ak){var ag=aj[ak];var ai=ag.charAt(0);if(ag.length>=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V<U;++V){var ae=Z[V];if(ae.global||ae.multiline){throw new Error(""+ae)}aa.push("(?:"+W(ae)+")")}return new RegExp(aa.join("|"),ac?"gi":"g")}function a(V){var U=/(?:^|\s)nocode(?:\s|$)/;var X=[];var T=0;var Z=[];var W=0;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=document.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Y=S&&"pre"===S.substring(0,3);function aa(ab){switch(ab.nodeType){case 1:if(U.test(ab.className)){return}for(var ae=ab.firstChild;ae;ae=ae.nextSibling){aa(ae)}var ad=ab.nodeName;if("BR"===ad||"LI"===ad){X[W]="\n";Z[W<<1]=T++;Z[(W++<<1)|1]=ab}break;case 3:case 4:var ac=ab.nodeValue;if(ac.length){if(!Y){ac=ac.replace(/[ \t\r\n]+/g," ")}else{ac=ac.replace(/\r\n?/g,"\n")}X[W]=ac;Z[W<<1]=T;T+=ac.length;Z[(W++<<1)|1]=ab}break}}aa(V);return{sourceCode:X.join("").replace(/\n$/,""),spans:Z}}function B(S,U,W,T){if(!U){return}var V={sourceCode:U,basePos:S};W(V);T.push.apply(T,V.decorations)}var v=/\S/;function o(S){var V=undefined;for(var U=S.firstChild;U;U=U.nextSibling){var T=U.nodeType;V=(T===1)?(V?S:U):(T===3)?(v.test(U.nodeValue)?S:V):V}return V===S?undefined:V}function g(U,T){var S={};var V;(function(){var ad=U.concat(T);var ah=[];var ag={};for(var ab=0,Z=ad.length;ab<Z;++ab){var Y=ad[ab];var ac=Y[3];if(ac){for(var ae=ac.length;--ae>=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae<aq;++ae){var ag=an[ae];var ap=aj[ag];var ai=void 0;var am;if(typeof ap==="string"){am=false}else{var aa=S[ag.charAt(0)];if(aa){ai=ag.match(aa[1]);ap=aa[0]}else{for(var ao=0;ao<X;++ao){aa=T[ao];ai=ag.match(aa[1]);if(ai){ap=aa[0];break}}if(!ai){ap=F}}am=ap.length>=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y<W.length;++Y){ae(W[Y])}if(ag===(ag|0)){W[0].setAttribute("value",ag)}var aa=ac.createElement("OL");aa.className="linenums";var X=Math.max(0,((ag-1))|0)||0;for(var Y=0,T=W.length;Y<T;++Y){af=W[Y];af.className="L"+((Y+X)%10);if(!af.firstChild){af.appendChild(ac.createTextNode("\xA0"))}aa.appendChild(af)}V.appendChild(aa)}function D(ac){var aj=/\bMSIE\b/.test(navigator.userAgent);var am=/\n/g;var al=ac.sourceCode;var an=al.length;var V=0;var aa=ac.spans;var T=aa.length;var ah=0;var X=ac.decorations;var Y=X.length;var Z=0;X[Y]=an;var ar,aq;for(aq=ar=0;aq<Y;){if(X[aq]!==X[aq+2]){X[ar++]=X[aq++];X[ar++]=X[aq++]}else{aq+=2}}Y=ar;for(aq=ar=0;aq<Y;){var at=X[aq];var ab=X[aq+1];var W=aq+2;while(W+2<=Y&&X[W+1]===ab){W+=2}X[ar++]=at;X[ar++]=ab;aq=W}Y=X.length=ar;var ae=null;while(ah<T){var af=aa[ah];var S=aa[ah+2]||an;var ag=X[Z];var ap=X[Z+2]||an;var W=Math.min(S,ap);var ak=aa[ah+1];var U;if(ak.nodeType!==1&&(U=al.substring(V,W))){if(aj){U=U.replace(am,"\r")}ak.nodeValue=U;var ai=ak.ownerDocument;var ao=ai.createElement("SPAN");ao.className=X[Z+1];var ad=ak.parentNode;ad.replaceChild(ao,ak);ao.appendChild(ak);if(V<S){aa[ah+1]=ak=ai.createTextNode(al.substring(W,S));ad.insertBefore(ak,ao.nextSibling)}}V=W;if(V>=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*</.test(S)?"default-markup":"default-code"}return t[T]}c(K,["default-code"]);c(g([],[[F,/^[^<?]+/],[E,/^<!\w[^>]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa<ac.length;++aa){for(var Z=0,V=ac[aa].length;Z<V;++Z){T.push(ac[aa][Z])}}ac=null;var W=Date;if(!W.now){W={now:function(){return +(new Date)}}}var X=0;var S;var ab=/\blang(?:uage)?-([\w.]+)(?!\S)/;var ae=/\bprettyprint\b/;function U(){var ag=(window.PR_SHOULD_USE_CONTINUATION?W.now()+250:Infinity);for(;X<T.length&&W.now()<ag;X++){var aj=T[X];var ai=aj.className;if(ai.indexOf("prettyprint")>=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X<T.length){setTimeout(U,250)}else{if(ad){ad()}}}U()}window.prettyPrintOne=y;window.prettyPrint=b;window.PR={createSimpleLexer:g,registerLangHandler:c,sourceDecorator:i,PR_ATTRIB_NAME:P,PR_ATTRIB_VALUE:n,PR_COMMENT:j,PR_DECLARATION:E,PR_KEYWORD:z,PR_LITERAL:G,PR_NOCODE:N,PR_PLAIN:F,PR_PUNCTUATION:L,PR_SOURCE:J,PR_STRING:C,PR_TAG:m,PR_TYPE:O}})();PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_DECLARATION,/^<!\w[^>]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^<xmp\b[^>]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^<script\b[^>]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^<script\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:<!--|-->)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); diff --git a/coverage/sort-arrow-sprite.png b/coverage/sort-arrow-sprite.png deleted file mode 100644 index 03f704a609c6fd0dbfdac63466a7d7c958b5cbf3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 209 zcmeAS@N?(olHy`uVBq!ia0vp^>_9Bd!3HEZxJ@+%Qj#UE5hcO-X(i=}MX3yqDfvmM z3ZA)%>8U}fi7AzZCsS>Jii$m5978H@?Fn+^JD|Y9yzj{W`447Gxa{7*dM7nnnD-Lb z6^}Hx2)<t4^o6Wx*F;wxHx}=5N#Su@S-w&C^o$MC9b5+$B=T4;r?cPm)%Fj&wd;}X zP9-IMj(10vstZN_m^jtm<9|ljB!x{5tE86~eE-nSz|0W&!@{XNS*HVNJ%gvKpUXO@ GgeCxf+epL! diff --git a/coverage/sorter.js b/coverage/sorter.js deleted file mode 100644 index 6c5034e..0000000 --- a/coverage/sorter.js +++ /dev/null @@ -1,158 +0,0 @@ -var addSorting = (function () { - "use strict"; - var cols, - currentSort = { - index: 0, - desc: false - }; - - // returns the summary table element - function getTable() { return document.querySelector('.coverage-summary'); } - // returns the thead element of the summary table - function getTableHeader() { return getTable().querySelector('thead tr'); } - // returns the tbody element of the summary table - function getTableBody() { return getTable().querySelector('tbody'); } - // returns the th element for nth column - function getNthColumn(n) { return getTableHeader().querySelectorAll('th')[n]; } - - // loads all columns - function loadColumns() { - var colNodes = getTableHeader().querySelectorAll('th'), - colNode, - cols = [], - col, - i; - - for (i = 0; i < colNodes.length; i += 1) { - colNode = colNodes[i]; - col = { - key: colNode.getAttribute('data-col'), - sortable: !colNode.getAttribute('data-nosort'), - type: colNode.getAttribute('data-type') || 'string' - }; - cols.push(col); - if (col.sortable) { - col.defaultDescSort = col.type === 'number'; - colNode.innerHTML = colNode.innerHTML + '<span class="sorter"></span>'; - } - } - return cols; - } - // attaches a data attribute to every tr element with an object - // of data values keyed by column name - function loadRowData(tableRow) { - var tableCols = tableRow.querySelectorAll('td'), - colNode, - col, - data = {}, - i, - val; - for (i = 0; i < tableCols.length; i += 1) { - colNode = tableCols[i]; - col = cols[i]; - val = colNode.getAttribute('data-value'); - if (col.type === 'number') { - val = Number(val); - } - data[col.key] = val; - } - return data; - } - // loads all row data - function loadData() { - var rows = getTableBody().querySelectorAll('tr'), - i; - - for (i = 0; i < rows.length; i += 1) { - rows[i].data = loadRowData(rows[i]); - } - } - // sorts the table using the data for the ith column - function sortByIndex(index, desc) { - var key = cols[index].key, - sorter = function (a, b) { - a = a.data[key]; - b = b.data[key]; - return a < b ? -1 : a > b ? 1 : 0; - }, - finalSorter = sorter, - tableBody = document.querySelector('.coverage-summary tbody'), - rowNodes = tableBody.querySelectorAll('tr'), - rows = [], - i; - - if (desc) { - finalSorter = function (a, b) { - return -1 * sorter(a, b); - }; - } - - for (i = 0; i < rowNodes.length; i += 1) { - rows.push(rowNodes[i]); - tableBody.removeChild(rowNodes[i]); - } - - rows.sort(finalSorter); - - for (i = 0; i < rows.length; i += 1) { - tableBody.appendChild(rows[i]); - } - } - // removes sort indicators for current column being sorted - function removeSortIndicators() { - var col = getNthColumn(currentSort.index), - cls = col.className; - - cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); - col.className = cls; - } - // adds sort indicators for current column being sorted - function addSortIndicators() { - getNthColumn(currentSort.index).className += currentSort.desc ? ' sorted-desc' : ' sorted'; - } - // adds event listeners for all sorter widgets - function enableUI() { - var i, - el, - ithSorter = function ithSorter(i) { - var col = cols[i]; - - return function () { - var desc = col.defaultDescSort; - - if (currentSort.index === i) { - desc = !currentSort.desc; - } - sortByIndex(i, desc); - removeSortIndicators(); - currentSort.index = i; - currentSort.desc = desc; - addSortIndicators(); - }; - }; - for (i =0 ; i < cols.length; i += 1) { - if (cols[i].sortable) { - // add the click event handler on the th so users - // dont have to click on those tiny arrows - el = getNthColumn(i).querySelector('.sorter').parentElement; - if (el.addEventListener) { - el.addEventListener('click', ithSorter(i)); - } else { - el.attachEvent('onclick', ithSorter(i)); - } - } - } - } - // adds sorting functionality to the UI - return function () { - if (!getTable()) { - return; - } - cols = loadColumns(); - loadData(cols); - addSortIndicators(); - enableUI(); - }; -})(); - -window.addEventListener('load', addSorting); diff --git a/coverage/webservice-pinsis/config.js.html b/coverage/webservice-pinsis/config.js.html deleted file mode 100644 index a1d5a97..0000000 --- a/coverage/webservice-pinsis/config.js.html +++ /dev/null @@ -1,104 +0,0 @@ -<!doctype html> -<html lang="en"> -<head> - <title>Code coverage report for webservice-pinsis/config.js</title> - <meta charset="utf-8" /> - <link rel="stylesheet" href="../prettify.css" /> - <link rel="stylesheet" href="../base.css" /> - <meta name="viewport" content="width=device-width, initial-scale=1"> - <style type='text/css'> - .coverage-summary .sorter { - background-image: url(../sort-arrow-sprite.png); - } - </style> -</head> -<body> -<div class='wrapper'> - <div class='pad1'> - <h1> - <a href="../index.html">All files</a> / <a href="index.html">webservice-pinsis</a> config.js - </h1> - <div class='clearfix'> - <div class='fl pad1y space-right2'> - <span class="strong">100% </span> - <span class="quiet">Statements</span> - <span class='fraction'>4/4</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">100% </span> - <span class="quiet">Branches</span> - <span class='fraction'>0/0</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">100% </span> - <span class="quiet">Functions</span> - <span class='fraction'>0/0</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">100% </span> - <span class="quiet">Lines</span> - <span class='fraction'>4/4</span> - </div> - </div> - </div> - <div class='status-line high'></div> -<pre><table class="coverage"> -<tr><td class="line-count quiet">1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14</td><td class="line-coverage quiet"><span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">var config = module.exports = {}; - -config.db_config = { - user: 'user', - password: 'password', - database: 'dbname', - host: 'localhost', - port: 5432 -}; - -config.fqdn = 'pinsis.c3sl.ufpr.br'; - -config.agentVersion = 0.0; - </pre></td></tr> -</table></pre> -<div class='push'></div><!-- for sticky footer --> -</div><!-- /wrapper --> -<div class='footer quiet pad2 space-top1 center small'> - Code coverage - generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu Aug 10 2017 11:42:01 GMT-0300 (BRT) -</div> -</div> -<script src="../prettify.js"></script> -<script> -window.onload = function () { - if (typeof prettyPrint === 'function') { - prettyPrint(); - } -}; -</script> -<script src="../sorter.js"></script> -</body> -</html> diff --git a/coverage/webservice-pinsis/db/index.html b/coverage/webservice-pinsis/db/index.html deleted file mode 100644 index 5958eca..0000000 --- a/coverage/webservice-pinsis/db/index.html +++ /dev/null @@ -1,93 +0,0 @@ -<!doctype html> -<html lang="en"> -<head> - <title>Code coverage report for webservice-pinsis/db</title> - <meta charset="utf-8" /> - <link rel="stylesheet" href="../../prettify.css" /> - <link rel="stylesheet" href="../../base.css" /> - <meta name="viewport" content="width=device-width, initial-scale=1"> - <style type='text/css'> - .coverage-summary .sorter { - background-image: url(../../sort-arrow-sprite.png); - } - </style> -</head> -<body> -<div class='wrapper'> - <div class='pad1'> - <h1> - <a href="../../index.html">All files</a> webservice-pinsis/db - </h1> - <div class='clearfix'> - <div class='fl pad1y space-right2'> - <span class="strong">100% </span> - <span class="quiet">Statements</span> - <span class='fraction'>10/10</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">50% </span> - <span class="quiet">Branches</span> - <span class='fraction'>1/2</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">100% </span> - <span class="quiet">Functions</span> - <span class='fraction'>3/3</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">100% </span> - <span class="quiet">Lines</span> - <span class='fraction'>10/10</span> - </div> - </div> - </div> - <div class='status-line high'></div> -<div class="pad1"> -<table class="coverage-summary"> -<thead> -<tr> - <th data-col="file" data-fmt="html" data-html="true" class="file">File</th> - <th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th> - <th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th> - <th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th> - <th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th> - <th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th> - <th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th> - <th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th> - <th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th> - <th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th> -</tr> -</thead> -<tbody><tr> - <td class="file high" data-value="query_builder.js"><a href="query_builder.js.html">query_builder.js</a></td> - <td data-value="100" class="pic high"><div class="chart"><div class="cover-fill cover-full" style="width: 100%;"></div><div class="cover-empty" style="width:0%;"></div></div></td> - <td data-value="100" class="pct high">100%</td> - <td data-value="10" class="abs high">10/10</td> - <td data-value="50" class="pct medium">50%</td> - <td data-value="2" class="abs medium">1/2</td> - <td data-value="100" class="pct high">100%</td> - <td data-value="3" class="abs high">3/3</td> - <td data-value="100" class="pct high">100%</td> - <td data-value="10" class="abs high">10/10</td> - </tr> - -</tbody> -</table> -</div><div class='push'></div><!-- for sticky footer --> -</div><!-- /wrapper --> -<div class='footer quiet pad2 space-top1 center small'> - Code coverage - generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu Aug 10 2017 11:42:01 GMT-0300 (BRT) -</div> -</div> -<script src="../../prettify.js"></script> -<script> -window.onload = function () { - if (typeof prettyPrint === 'function') { - prettyPrint(); - } -}; -</script> -<script src="../../sorter.js"></script> -</body> -</html> diff --git a/coverage/webservice-pinsis/db/query_builder.js.html b/coverage/webservice-pinsis/db/query_builder.js.html deleted file mode 100644 index 7f94df1..0000000 --- a/coverage/webservice-pinsis/db/query_builder.js.html +++ /dev/null @@ -1,128 +0,0 @@ -<!doctype html> -<html lang="en"> -<head> - <title>Code coverage report for webservice-pinsis/db/query_builder.js</title> - <meta charset="utf-8" /> - <link rel="stylesheet" href="../../prettify.css" /> - <link rel="stylesheet" href="../../base.css" /> - <meta name="viewport" content="width=device-width, initial-scale=1"> - <style type='text/css'> - .coverage-summary .sorter { - background-image: url(../../sort-arrow-sprite.png); - } - </style> -</head> -<body> -<div class='wrapper'> - <div class='pad1'> - <h1> - <a href="../../index.html">All files</a> / <a href="index.html">webservice-pinsis/db</a> query_builder.js - </h1> - <div class='clearfix'> - <div class='fl pad1y space-right2'> - <span class="strong">100% </span> - <span class="quiet">Statements</span> - <span class='fraction'>10/10</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">50% </span> - <span class="quiet">Branches</span> - <span class='fraction'>1/2</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">100% </span> - <span class="quiet">Functions</span> - <span class='fraction'>3/3</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">100% </span> - <span class="quiet">Lines</span> - <span class='fraction'>10/10</span> - </div> - </div> - </div> - <div class='status-line high'></div> -<pre><table class="coverage"> -<tr><td class="line-count quiet">1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22</td><td class="line-coverage quiet"><span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">14x</span> -<span class="cline-any cline-yes">14x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">module.exports = function(){ - - squel = require("squel").useFlavour('postgres'); - - - return { - set_from_attr : function (query, obj){ - for (var property in obj) { - <span class="missing-if-branch" title="else path not taken" >E</span>if (obj.hasOwnProperty(property)) { - query.set(property, obj[property]); - } - } - return query; - }, - insert: function (table, obj){ - var q = squel.insert().into(table); - this.set_from_attr(q, obj); - return q; - } - } -} - </pre></td></tr> -</table></pre> -<div class='push'></div><!-- for sticky footer --> -</div><!-- /wrapper --> -<div class='footer quiet pad2 space-top1 center small'> - Code coverage - generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu Aug 10 2017 11:42:01 GMT-0300 (BRT) -</div> -</div> -<script src="../../prettify.js"></script> -<script> -window.onload = function () { - if (typeof prettyPrint === 'function') { - prettyPrint(); - } -}; -</script> -<script src="../../sorter.js"></script> -</body> -</html> diff --git a/coverage/webservice-pinsis/index.html b/coverage/webservice-pinsis/index.html deleted file mode 100644 index 4ca13fb..0000000 --- a/coverage/webservice-pinsis/index.html +++ /dev/null @@ -1,106 +0,0 @@ -<!doctype html> -<html lang="en"> -<head> - <title>Code coverage report for webservice-pinsis</title> - <meta charset="utf-8" /> - <link rel="stylesheet" href="../prettify.css" /> - <link rel="stylesheet" href="../base.css" /> - <meta name="viewport" content="width=device-width, initial-scale=1"> - <style type='text/css'> - .coverage-summary .sorter { - background-image: url(../sort-arrow-sprite.png); - } - </style> -</head> -<body> -<div class='wrapper'> - <div class='pad1'> - <h1> - <a href="../index.html">All files</a> webservice-pinsis - </h1> - <div class='clearfix'> - <div class='fl pad1y space-right2'> - <span class="strong">62.5% </span> - <span class="quiet">Statements</span> - <span class='fraction'>60/96</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">62.96% </span> - <span class="quiet">Branches</span> - <span class='fraction'>34/54</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">33.33% </span> - <span class="quiet">Functions</span> - <span class='fraction'>1/3</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">62.5% </span> - <span class="quiet">Lines</span> - <span class='fraction'>60/96</span> - </div> - </div> - </div> - <div class='status-line medium'></div> -<div class="pad1"> -<table class="coverage-summary"> -<thead> -<tr> - <th data-col="file" data-fmt="html" data-html="true" class="file">File</th> - <th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th> - <th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th> - <th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th> - <th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th> - <th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th> - <th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th> - <th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th> - <th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th> - <th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th> -</tr> -</thead> -<tbody><tr> - <td class="file high" data-value="config.js"><a href="config.js.html">config.js</a></td> - <td data-value="100" class="pic high"><div class="chart"><div class="cover-fill cover-full" style="width: 100%;"></div><div class="cover-empty" style="width:0%;"></div></div></td> - <td data-value="100" class="pct high">100%</td> - <td data-value="4" class="abs high">4/4</td> - <td data-value="100" class="pct high">100%</td> - <td data-value="0" class="abs high">0/0</td> - <td data-value="100" class="pct high">100%</td> - <td data-value="0" class="abs high">0/0</td> - <td data-value="100" class="pct high">100%</td> - <td data-value="4" class="abs high">4/4</td> - </tr> - -<tr> - <td class="file medium" data-value="server.js"><a href="server.js.html">server.js</a></td> - <td data-value="60.87" class="pic medium"><div class="chart"><div class="cover-fill" style="width: 60%;"></div><div class="cover-empty" style="width:40%;"></div></div></td> - <td data-value="60.87" class="pct medium">60.87%</td> - <td data-value="92" class="abs medium">56/92</td> - <td data-value="62.96" class="pct medium">62.96%</td> - <td data-value="54" class="abs medium">34/54</td> - <td data-value="33.33" class="pct low">33.33%</td> - <td data-value="3" class="abs low">1/3</td> - <td data-value="60.87" class="pct medium">60.87%</td> - <td data-value="92" class="abs medium">56/92</td> - </tr> - -</tbody> -</table> -</div><div class='push'></div><!-- for sticky footer --> -</div><!-- /wrapper --> -<div class='footer quiet pad2 space-top1 center small'> - Code coverage - generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu Aug 10 2017 11:42:01 GMT-0300 (BRT) -</div> -</div> -<script src="../prettify.js"></script> -<script> -window.onload = function () { - if (typeof prettyPrint === 'function') { - prettyPrint(); - } -}; -</script> -<script src="../sorter.js"></script> -</body> -</html> diff --git a/coverage/webservice-pinsis/lib/index.html b/coverage/webservice-pinsis/lib/index.html deleted file mode 100644 index 287459f..0000000 --- a/coverage/webservice-pinsis/lib/index.html +++ /dev/null @@ -1,106 +0,0 @@ -<!doctype html> -<html lang="en"> -<head> - <title>Code coverage report for webservice-pinsis/lib</title> - <meta charset="utf-8" /> - <link rel="stylesheet" href="../../prettify.css" /> - <link rel="stylesheet" href="../../base.css" /> - <meta name="viewport" content="width=device-width, initial-scale=1"> - <style type='text/css'> - .coverage-summary .sorter { - background-image: url(../../sort-arrow-sprite.png); - } - </style> -</head> -<body> -<div class='wrapper'> - <div class='pad1'> - <h1> - <a href="../../index.html">All files</a> webservice-pinsis/lib - </h1> - <div class='clearfix'> - <div class='fl pad1y space-right2'> - <span class="strong">41.67% </span> - <span class="quiet">Statements</span> - <span class='fraction'>30/72</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">30.77% </span> - <span class="quiet">Branches</span> - <span class='fraction'>12/39</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">33.33% </span> - <span class="quiet">Functions</span> - <span class='fraction'>3/9</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">44.12% </span> - <span class="quiet">Lines</span> - <span class='fraction'>30/68</span> - </div> - </div> - </div> - <div class='status-line low'></div> -<div class="pad1"> -<table class="coverage-summary"> -<thead> -<tr> - <th data-col="file" data-fmt="html" data-html="true" class="file">File</th> - <th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th> - <th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th> - <th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th> - <th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th> - <th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th> - <th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th> - <th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th> - <th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th> - <th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th> -</tr> -</thead> -<tbody><tr> - <td class="file medium" data-value="logger.js"><a href="logger.js.html">logger.js</a></td> - <td data-value="78.13" class="pic medium"><div class="chart"><div class="cover-fill" style="width: 78%;"></div><div class="cover-empty" style="width:22%;"></div></div></td> - <td data-value="78.13" class="pct medium">78.13%</td> - <td data-value="32" class="abs medium">25/32</td> - <td data-value="57.14" class="pct medium">57.14%</td> - <td data-value="21" class="abs medium">12/21</td> - <td data-value="75" class="pct medium">75%</td> - <td data-value="4" class="abs medium">3/4</td> - <td data-value="78.13" class="pct medium">78.13%</td> - <td data-value="32" class="abs medium">25/32</td> - </tr> - -<tr> - <td class="file low" data-value="utils.js"><a href="utils.js.html">utils.js</a></td> - <td data-value="12.5" class="pic low"><div class="chart"><div class="cover-fill" style="width: 12%;"></div><div class="cover-empty" style="width:88%;"></div></div></td> - <td data-value="12.5" class="pct low">12.5%</td> - <td data-value="40" class="abs low">5/40</td> - <td data-value="0" class="pct low">0%</td> - <td data-value="18" class="abs low">0/18</td> - <td data-value="0" class="pct low">0%</td> - <td data-value="5" class="abs low">0/5</td> - <td data-value="13.89" class="pct low">13.89%</td> - <td data-value="36" class="abs low">5/36</td> - </tr> - -</tbody> -</table> -</div><div class='push'></div><!-- for sticky footer --> -</div><!-- /wrapper --> -<div class='footer quiet pad2 space-top1 center small'> - Code coverage - generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu Aug 10 2017 11:42:01 GMT-0300 (BRT) -</div> -</div> -<script src="../../prettify.js"></script> -<script> -window.onload = function () { - if (typeof prettyPrint === 'function') { - prettyPrint(); - } -}; -</script> -<script src="../../sorter.js"></script> -</body> -</html> diff --git a/coverage/webservice-pinsis/lib/logger.js.html b/coverage/webservice-pinsis/lib/logger.js.html deleted file mode 100644 index c1fbb67..0000000 --- a/coverage/webservice-pinsis/lib/logger.js.html +++ /dev/null @@ -1,476 +0,0 @@ -<!doctype html> -<html lang="en"> -<head> - <title>Code coverage report for webservice-pinsis/lib/logger.js</title> - <meta charset="utf-8" /> - <link rel="stylesheet" href="../../prettify.css" /> - <link rel="stylesheet" href="../../base.css" /> - <meta name="viewport" content="width=device-width, initial-scale=1"> - <style type='text/css'> - .coverage-summary .sorter { - background-image: url(../../sort-arrow-sprite.png); - } - </style> -</head> -<body> -<div class='wrapper'> - <div class='pad1'> - <h1> - <a href="../../index.html">All files</a> / <a href="index.html">webservice-pinsis/lib</a> logger.js - </h1> - <div class='clearfix'> - <div class='fl pad1y space-right2'> - <span class="strong">78.13% </span> - <span class="quiet">Statements</span> - <span class='fraction'>25/32</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">57.14% </span> - <span class="quiet">Branches</span> - <span class='fraction'>12/21</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">75% </span> - <span class="quiet">Functions</span> - <span class='fraction'>3/4</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">78.13% </span> - <span class="quiet">Lines</span> - <span class='fraction'>25/32</span> - </div> - </div> - </div> - <div class='status-line medium'></div> -<pre><table class="coverage"> -<tr><td class="line-count quiet">1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138</td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">/* - * Copyright (C) 2012 Centro de Computacao Cientifica e Software Livre - * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR - * - * This file is part of simmc - * - * simmc is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ - - -var os = require('os'); -var cluster = require('cluster'); -var bunyan = require('bunyan'); -var cuid = require('cuid'); -var fs = require('fs'); - -// Serialize a request (remove unuseful information from requests, -// log only the necessary). -function requestSerializer(req) { - <span class="missing-if-branch" title="if path not taken" >I</span>if ((typeof(req) !== 'object') || (req === null)) { -<span class="cstat-no" title="statement not covered" > return req;</span> - } - - var headers = req.headers || <span class="branch-1 cbranch-no" title="branch not covered" >{};</span> - - return { - method: req.method, - url: req.url, - headers: { // selective choice of headers (no cookies) - "host": headers["host"], - "connection": headers["connection"], - "cache-control": headers["cache-control"], - "accept": headers["accept"], - "user-agent": headers["user-agent"], - "referer": headers["referer"], - "accept-encoding": headers["accept-encoding"], - "accept-language": headers["accept-language"] - }, - remoteAddress: req.ips[0] || req.ip || <span class="branch-2 cbranch-no" title="branch not covered" >null</span> - }; -} - -// Serialize a reponse (remove unuseful information from responses -// and calculate the reponse time). -function responseSerializer(res) { - <span class="missing-if-branch" title="if path not taken" >I</span>if ((typeof(res) !== 'object') || (res === null)) { -<span class="cstat-no" title="statement not covered" > return res;</span> - } - - // Calculate the response time - var responseTime; - <span class="missing-if-branch" title="else path not taken" >E</span>if (res.start) { - responseTime = (new Date() - res.start).toString() + " ms"; - } - - return { - statusCode: res.statusCode, - responseTime: responseTime - } -} - -// Make sure the logs dir exist -try { - fs.mkdirSync('logs'); -} -catch (e) { - <span class="missing-if-branch" title="if path not taken" >I</span>if ( e.code != 'EEXIST' ) -<span class="cstat-no" title="statement not covered" > throw e;</span> -} - -// Create the default logger -var defaultLogger = bunyan.createLogger({ - name: 'default', - streams: [{ - level: "info", - type: 'file', - path: 'logs/default.log', - }, - { - level: "debug", - type: 'file', - path: 'logs/debug.log', - }], - serializers: { - req: requestSerializer, - res: responseSerializer - } -}); -<span class="missing-if-branch" title="if path not taken" >I</span>if (!cluster.isMaster) { -<span class="cstat-no" title="statement not covered" > defaultLogger = defaultLogger.child({ worker: cluster.worker.id });</span> -} - -// Export the default logger -exports.default = defaultLogger; - -// Export the access logger (log express requests) -exports.expressAccess = function (req, res, next) { - // insert the current time into the response - // (for later calculation of reponse time). - res.start = new Date(); - - // Insert a log object into the request. - // The routes can use this object to log messages and all - // of them can be traced to the request (by req_id). - req.log = defaultLogger.child({ req_id: cuid.slug() }); - - // Log the request - req.log.debug({req: req}, 'request'); - - // Continue to the next handler - next(); - - // Log the response - req.log.debug({res: res}, 'response'); -} - -// Export the express error logger (log errors during request processing) -exports.expressError = <span class="fstat-no" title="function not covered" >fu</span>nction (err, req, res, next) { -<span class="cstat-no" title="statement not covered" > if (err) {</span> -<span class="cstat-no" title="statement not covered" > defaultLogger.error({err: err}, 'Error while processing request');</span> - } - -<span class="cstat-no" title="statement not covered" > next();</span> -} - </pre></td></tr> -</table></pre> -<div class='push'></div><!-- for sticky footer --> -</div><!-- /wrapper --> -<div class='footer quiet pad2 space-top1 center small'> - Code coverage - generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu Aug 10 2017 11:42:01 GMT-0300 (BRT) -</div> -</div> -<script src="../../prettify.js"></script> -<script> -window.onload = function () { - if (typeof prettyPrint === 'function') { - prettyPrint(); - } -}; -</script> -<script src="../../sorter.js"></script> -</body> -</html> diff --git a/coverage/webservice-pinsis/lib/utils.js.html b/coverage/webservice-pinsis/lib/utils.js.html deleted file mode 100644 index 3d7757d..0000000 --- a/coverage/webservice-pinsis/lib/utils.js.html +++ /dev/null @@ -1,329 +0,0 @@ -<!doctype html> -<html lang="en"> -<head> - <title>Code coverage report for webservice-pinsis/lib/utils.js</title> - <meta charset="utf-8" /> - <link rel="stylesheet" href="../../prettify.css" /> - <link rel="stylesheet" href="../../base.css" /> - <meta name="viewport" content="width=device-width, initial-scale=1"> - <style type='text/css'> - .coverage-summary .sorter { - background-image: url(../../sort-arrow-sprite.png); - } - </style> -</head> -<body> -<div class='wrapper'> - <div class='pad1'> - <h1> - <a href="../../index.html">All files</a> / <a href="index.html">webservice-pinsis/lib</a> utils.js - </h1> - <div class='clearfix'> - <div class='fl pad1y space-right2'> - <span class="strong">12.5% </span> - <span class="quiet">Statements</span> - <span class='fraction'>5/40</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">0% </span> - <span class="quiet">Branches</span> - <span class='fraction'>0/18</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">0% </span> - <span class="quiet">Functions</span> - <span class='fraction'>0/5</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">13.89% </span> - <span class="quiet">Lines</span> - <span class='fraction'>5/36</span> - </div> - </div> - </div> - <div class='status-line low'></div> -<pre><table class="coverage"> -<tr><td class="line-count quiet">1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89</td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">/* - * Copyright (C) 2012 Centro de Computacao Cientifica e Software Livre - * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR - * - * This file is part of simmc - * - * simmc is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ - -var crypto = require('crypto'); - -// Returns a filename starting with prefix (if not null) plus a md5-hash -// representing the obj given as argument, with "ext" as extension. -exports.hashFilename = <span class="fstat-no" title="function not covered" >fu</span>nction(prefix, obj, ext) { - var txt = <span class="cstat-no" title="statement not covered" >"";</span> -<span class="cstat-no" title="statement not covered" > for (i in obj) {</span> -<span class="cstat-no" title="statement not covered" > txt += i + obj[i]</span> - } - var hash = <span class="cstat-no" title="statement not covered" >crypto.createHash('md5').update(txt).digest('hex');</span> -<span class="cstat-no" title="statement not covered" > return (prefix? prefix + '_' + hash : hash) + '.' + ext;</span> -}; - -// returns a filename in the format: type project_date(day+month+year+'_'+hours+minutes).ext -exports.reportFilename = <span class="fstat-no" title="function not covered" >fu</span>nction(prefix, ext) { - var date = <span class="cstat-no" title="statement not covered" >formatDateReport(new Date());</span> -<span class="cstat-no" title="statement not covered" > return prefix+ '_'+ date + '.' + ext;</span> -}; - -// returns the date in the format day+month+year_hours+minutes -function <span class="fstat-no" title="function not covered" >formatDateReport(</span>date) { - var day = <span class="cstat-no" title="statement not covered" >date.getUTCDate(),</span> - month = <span class="cstat-no" title="statement not covered" >date.getUTCMonth() + 1,</span> //Months are zero based - year = <span class="cstat-no" title="statement not covered" >date.getUTCFullYear(),</span> - hours = <span class="cstat-no" title="statement not covered" >date.getHours(),</span> - minutes = <span class="cstat-no" title="statement not covered" >date.getMinutes();</span> - -<span class="cstat-no" title="statement not covered" > if (day < 10) <span class="cstat-no" title="statement not covered" >day = '0' + day;</span></span> -<span class="cstat-no" title="statement not covered" > if (month < 10) <span class="cstat-no" title="statement not covered" >month = '0' + month;</span></span> -<span class="cstat-no" title="statement not covered" > if (hours < 10) <span class="cstat-no" title="statement not covered" >hours = '0' + hours;</span></span> -<span class="cstat-no" title="statement not covered" > if (minutes < 10) <span class="cstat-no" title="statement not covered" >minutes = '0' + minutes;</span></span> - -<span class="cstat-no" title="statement not covered" > return day + month + year + '_' + hours + minutes;</span> -} - - -// returns the sum of every element in a array or object -exports.sum = <span class="fstat-no" title="function not covered" >fu</span>nction(x) { - var total = <span class="cstat-no" title="statement not covered" >0;</span> -<span class="cstat-no" title="statement not covered" > if (x.constructor == Array) {</span> -<span class="cstat-no" title="statement not covered" > for (var i=0; i<x.length; i++) {</span> -<span class="cstat-no" title="statement not covered" > total += x[i];</span> - } - } else { -<span class="cstat-no" title="statement not covered" > for (var i in x) {</span> -<span class="cstat-no" title="statement not covered" > total += x[i];</span> - } - } -<span class="cstat-no" title="statement not covered" > return total;</span> -} - -exports.checkEmail = <span class="fstat-no" title="function not covered" >fu</span>nction(email) { -<span class="cstat-no" title="statement not covered" > if (email.length < 4) {</span> -<span class="cstat-no" title="statement not covered" > return "Email deve conter pelo menos 4 caracteres.";</span> - } - -<span class="cstat-no" title="statement not covered" > if (email.length > 255) {</span> -<span class="cstat-no" title="statement not covered" > return "Email deve conter no máximo 255 caracteres.";</span> - } - -<span class="cstat-no" title="statement not covered" > if (!email.match(/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/)) {</span> -<span class="cstat-no" title="statement not covered" > return "Email não está em um formato válido.";</span> - } - -<span class="cstat-no" title="statement not covered" > return false;</span> -} - </pre></td></tr> -</table></pre> -<div class='push'></div><!-- for sticky footer --> -</div><!-- /wrapper --> -<div class='footer quiet pad2 space-top1 center small'> - Code coverage - generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu Aug 10 2017 11:42:01 GMT-0300 (BRT) -</div> -</div> -<script src="../../prettify.js"></script> -<script> -window.onload = function () { - if (typeof prettyPrint === 'function') { - prettyPrint(); - } -}; -</script> -<script src="../../sorter.js"></script> -</body> -</html> diff --git a/coverage/webservice-pinsis/middleware/db.js.html b/coverage/webservice-pinsis/middleware/db.js.html deleted file mode 100644 index 87c99d4..0000000 --- a/coverage/webservice-pinsis/middleware/db.js.html +++ /dev/null @@ -1,569 +0,0 @@ -<!doctype html> -<html lang="en"> -<head> - <title>Code coverage report for webservice-pinsis/middleware/db.js</title> - <meta charset="utf-8" /> - <link rel="stylesheet" href="../../prettify.css" /> - <link rel="stylesheet" href="../../base.css" /> - <meta name="viewport" content="width=device-width, initial-scale=1"> - <style type='text/css'> - .coverage-summary .sorter { - background-image: url(../../sort-arrow-sprite.png); - } - </style> -</head> -<body> -<div class='wrapper'> - <div class='pad1'> - <h1> - <a href="../../index.html">All files</a> / <a href="index.html">webservice-pinsis/middleware</a> db.js - </h1> - <div class='clearfix'> - <div class='fl pad1y space-right2'> - <span class="strong">44.44% </span> - <span class="quiet">Statements</span> - <span class='fraction'>40/90</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">36.36% </span> - <span class="quiet">Branches</span> - <span class='fraction'>8/22</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">38.71% </span> - <span class="quiet">Functions</span> - <span class='fraction'>12/31</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">44.94% </span> - <span class="quiet">Lines</span> - <span class='fraction'>40/89</span> - </div> - </div> - </div> - <div class='status-line low'></div> -<pre><table class="coverage"> -<tr><td class="line-count quiet">1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 -165 -166 -167 -168 -169</td><td class="line-coverage quiet"><span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">3x</span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">3x</span> -<span class="cline-any cline-yes">2x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">var pg = require('pg'), - copyFrom = require('pg-copy-streams').from, - fs = require('fs'), - _ = require('lodash'); - -var tokenPattern = /\$[a-zA-Z]([a-zA-Z0-9_]*)\b/g; - -function <span class="fstat-no" title="function not covered" >numericFromNamed(</span>sql, parameters) { - var fillableTokens = <span class="cstat-no" title="statement not covered" >Object.keys(parameters);</span> - - var matchedTokens = <span class="cstat-no" title="statement not covered" >_.uniq(_.map(sql.match(tokenPattern), <span class="fstat-no" title="function not covered" >fu</span>nction (token) {</span> -<span class="cstat-no" title="statement not covered" > return token.substring(1); </span>// Remove leading dollar sign - })); - - var fillTokens = <span class="cstat-no" title="statement not covered" >_.intersection(fillableTokens, matchedTokens).sort();</span> - var fillValues = <span class="cstat-no" title="statement not covered" >_.map(fillTokens, <span class="fstat-no" title="function not covered" >fu</span>nction (token) {</span> -<span class="cstat-no" title="statement not covered" > return parameters[token];</span> - }); - - var unmatchedTokens = <span class="cstat-no" title="statement not covered" >_.difference(matchedTokens, fillableTokens);</span> - -<span class="cstat-no" title="statement not covered" > if (unmatchedTokens.length) {</span> - var missing = <span class="cstat-no" title="statement not covered" >unmatchedTokens.join(", ");</span> -<span class="cstat-no" title="statement not covered" > throw new Error("Missing Parameters: " + missing);</span> - } - - var interpolatedSql = <span class="cstat-no" title="statement not covered" >_.reduce(fillTokens, <span class="fstat-no" title="function not covered" >fu</span>nction (partiallyInterpolated, token, index) {</span> - var replaceAllPattern = <span class="cstat-no" title="statement not covered" >new RegExp('\\$' + fillTokens[index] + '\\b', "g");</span> -<span class="cstat-no" title="statement not covered" > return partiallyInterpolated.replace(replaceAllPattern, '$' + (index+1));</span> - }, sql); - - var out = <span class="cstat-no" title="statement not covered" >{};</span> -<span class="cstat-no" title="statement not covered" > out.sql = interpolatedSql;</span> -<span class="cstat-no" title="statement not covered" > out.values = fillValues;</span> - -<span class="cstat-no" title="statement not covered" > return out;</span> -} - -function namedPatch(client) { - var originalQuery = client.query; - - <span class="missing-if-branch" title="if path not taken" >I</span>if (originalQuery.patched) <span class="cstat-no" title="statement not covered" >return client;</span> - - originalQuery = originalQuery.bind(client); - - var patchedQuery = function(config, values, callback) { - <span class="missing-if-branch" title="if path not taken" >I</span>if (arguments.length === 1) { -<span class="cstat-no" title="statement not covered" > return originalQuery(config);</span> - } - else if (arguments.length === 2 && _.isFunction(values)) { - return originalQuery(config, values); - } - else <span class="missing-if-branch" title="else path not taken" >E</span>if (_.isArray(values)) { - return originalQuery(config, values, callback); - } else { - var reparameterized = <span class="cstat-no" title="statement not covered" >numericFromNamed(config, values);</span> -<span class="cstat-no" title="statement not covered" > return originalQuery(reparameterized.sql, reparameterized.values, callback);</span> - } - }; - - client.query = patchedQuery; - client.query.patched = true; - - return client; -} - -exports.pool = function (config) { - return function (req, res, next) { - req.db = { - connect: function (callback) { - pg.on('error', <span class="fstat-no" title="function not covered" >fu</span>nction(err) { -<span class="cstat-no" title="statement not covered" > return;</span> - }); - pg.connect(config, function (err, client, done) { - <span class="missing-if-branch" title="if path not taken" >I</span>if (err) { -<span class="cstat-no" title="statement not covered" > setTimeout(req.db.connect, 5000, callback);</span> -<span class="cstat-no" title="statement not covered" > return;</span> - } - - namedPatch(client); - callback(null, new Connection(client), done); - }); - } - }; - - next(); - }; -}; - -function Connection(client) { - this.query = function (query, params, callback) { - return client.query(query, params, callback); - }; - - this.execute = <span class="fstat-no" title="function not covered" >fu</span>nction (query, params) { - var $this = <span class="cstat-no" title="statement not covered" >this;</span> - -<span class="cstat-no" title="statement not covered" > return <span class="fstat-no" title="function not covered" >fu</span>nction (callback) {</span> -<span class="cstat-no" title="statement not covered" > $this.query(query, params, <span class="fstat-no" title="function not covered" >fu</span>nction (err) {</span> -<span class="cstat-no" title="statement not covered" > callback(err);</span> - }); - }; - }; - - this.queryFromFile = <span class="fstat-no" title="function not covered" >fu</span>nction(file, params, callback) { - var queries_dir = <span class="cstat-no" title="statement not covered" >__dirname + "/../queries/";</span> - -<span class="cstat-no" title="statement not covered" > fs.readFile(queries_dir + file, 'utf8', <span class="fstat-no" title="function not covered" >fu</span>nction (err, data) {</span> -<span class="cstat-no" title="statement not covered" > if (err) {</span> -<span class="cstat-no" title="statement not covered" > return callback(err);</span> - } - -<span class="cstat-no" title="statement not covered" > if (typeof params === 'undefined') {</span> -<span class="cstat-no" title="statement not covered" > params = [];</span> - } - -<span class="cstat-no" title="statement not covered" > client.query(data, params, callback);</span> - }); - }; - - this.executeFromFile = <span class="fstat-no" title="function not covered" >fu</span>nction(file, params) { - var $this = <span class="cstat-no" title="statement not covered" >this;</span> - -<span class="cstat-no" title="statement not covered" > return <span class="fstat-no" title="function not covered" >fu</span>nction (callback) {</span> -<span class="cstat-no" title="statement not covered" > $this.queryFromFile(file, params, <span class="fstat-no" title="function not covered" >fu</span>nction (err) {</span> -<span class="cstat-no" title="statement not covered" > callback(err);</span> - }); - }; - }; - - this.copyFrom = <span class="fstat-no" title="function not covered" >fu</span>nction (query, callback) { - var stream = <span class="cstat-no" title="statement not covered" >client.query(copyFrom(query));</span> -<span class="cstat-no" title="statement not covered" > stream.on('end', callback);</span> -<span class="cstat-no" title="statement not covered" > stream.on('error', callback);</span> -<span class="cstat-no" title="statement not covered" > return stream;</span> - }; - - this.transaction = function (callback) { - client.query('BEGIN;', function (err) { - callback(err); - }); - }; - - this.commit = <span class="fstat-no" title="function not covered" >fu</span>nction (callback) { -<span class="cstat-no" title="statement not covered" > client.query('COMMIT;', <span class="fstat-no" title="function not covered" >fu</span>nction (err) {</span> -<span class="cstat-no" title="statement not covered" > callback(err);</span> - }); - }; - - this.rollback = function (callback) { - client.query('ROLLBACK;', function (err) { - callback(err); - }); - }; - - this.auth = <span class="fstat-no" title="function not covered" >fu</span>nction (user, ip, action, comment) { -<span class="cstat-no" title="statement not covered" > return <span class="fstat-no" title="function not covered" >fu</span>nction (callback) {</span> -<span class="cstat-no" title="statement not covered" > if (!(user && user.id))</span> -<span class="cstat-no" title="statement not covered" > return callback('not_logged_in');</span> - -<span class="cstat-no" title="statement not covered" > client.query('SELECT auth.user_action($1, $2, $3, $4);',</span> - [user.id, ip, action, comment], -<span class="fstat-no" title="function not covered" > fu</span>nction (err) { -<span class="cstat-no" title="statement not covered" > callback(err);</span> - }); - }; - }; -}; - </pre></td></tr> -</table></pre> -<div class='push'></div><!-- for sticky footer --> -</div><!-- /wrapper --> -<div class='footer quiet pad2 space-top1 center small'> - Code coverage - generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu Aug 10 2017 11:42:01 GMT-0300 (BRT) -</div> -</div> -<script src="../../prettify.js"></script> -<script> -window.onload = function () { - if (typeof prettyPrint === 'function') { - prettyPrint(); - } -}; -</script> -<script src="../../sorter.js"></script> -</body> -</html> diff --git a/coverage/webservice-pinsis/middleware/index.html b/coverage/webservice-pinsis/middleware/index.html deleted file mode 100644 index 288814c..0000000 --- a/coverage/webservice-pinsis/middleware/index.html +++ /dev/null @@ -1,93 +0,0 @@ -<!doctype html> -<html lang="en"> -<head> - <title>Code coverage report for webservice-pinsis/middleware</title> - <meta charset="utf-8" /> - <link rel="stylesheet" href="../../prettify.css" /> - <link rel="stylesheet" href="../../base.css" /> - <meta name="viewport" content="width=device-width, initial-scale=1"> - <style type='text/css'> - .coverage-summary .sorter { - background-image: url(../../sort-arrow-sprite.png); - } - </style> -</head> -<body> -<div class='wrapper'> - <div class='pad1'> - <h1> - <a href="../../index.html">All files</a> webservice-pinsis/middleware - </h1> - <div class='clearfix'> - <div class='fl pad1y space-right2'> - <span class="strong">44.44% </span> - <span class="quiet">Statements</span> - <span class='fraction'>40/90</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">36.36% </span> - <span class="quiet">Branches</span> - <span class='fraction'>8/22</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">38.71% </span> - <span class="quiet">Functions</span> - <span class='fraction'>12/31</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">44.94% </span> - <span class="quiet">Lines</span> - <span class='fraction'>40/89</span> - </div> - </div> - </div> - <div class='status-line low'></div> -<div class="pad1"> -<table class="coverage-summary"> -<thead> -<tr> - <th data-col="file" data-fmt="html" data-html="true" class="file">File</th> - <th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th> - <th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th> - <th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th> - <th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th> - <th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th> - <th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th> - <th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th> - <th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th> - <th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th> -</tr> -</thead> -<tbody><tr> - <td class="file low" data-value="db.js"><a href="db.js.html">db.js</a></td> - <td data-value="44.44" class="pic low"><div class="chart"><div class="cover-fill" style="width: 44%;"></div><div class="cover-empty" style="width:56%;"></div></div></td> - <td data-value="44.44" class="pct low">44.44%</td> - <td data-value="90" class="abs low">40/90</td> - <td data-value="36.36" class="pct low">36.36%</td> - <td data-value="22" class="abs low">8/22</td> - <td data-value="38.71" class="pct low">38.71%</td> - <td data-value="31" class="abs low">12/31</td> - <td data-value="44.94" class="pct low">44.94%</td> - <td data-value="89" class="abs low">40/89</td> - </tr> - -</tbody> -</table> -</div><div class='push'></div><!-- for sticky footer --> -</div><!-- /wrapper --> -<div class='footer quiet pad2 space-top1 center small'> - Code coverage - generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu Aug 10 2017 11:42:01 GMT-0300 (BRT) -</div> -</div> -<script src="../../prettify.js"></script> -<script> -window.onload = function () { - if (typeof prettyPrint === 'function') { - prettyPrint(); - } -}; -</script> -<script src="../../sorter.js"></script> -</body> -</html> diff --git a/coverage/webservice-pinsis/routes/agent.js.html b/coverage/webservice-pinsis/routes/agent.js.html deleted file mode 100644 index 4477377..0000000 --- a/coverage/webservice-pinsis/routes/agent.js.html +++ /dev/null @@ -1,464 +0,0 @@ -<!doctype html> -<html lang="en"> -<head> - <title>Code coverage report for webservice-pinsis/routes/agent.js</title> - <meta charset="utf-8" /> - <link rel="stylesheet" href="../../prettify.css" /> - <link rel="stylesheet" href="../../base.css" /> - <meta name="viewport" content="width=device-width, initial-scale=1"> - <style type='text/css'> - .coverage-summary .sorter { - background-image: url(../../sort-arrow-sprite.png); - } - </style> -</head> -<body> -<div class='wrapper'> - <div class='pad1'> - <h1> - <a href="../../index.html">All files</a> / <a href="index.html">webservice-pinsis/routes</a> agent.js - </h1> - <div class='clearfix'> - <div class='fl pad1y space-right2'> - <span class="strong">69.23% </span> - <span class="quiet">Statements</span> - <span class='fraction'>27/39</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">50% </span> - <span class="quiet">Branches</span> - <span class='fraction'>6/12</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">70% </span> - <span class="quiet">Functions</span> - <span class='fraction'>7/10</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">69.23% </span> - <span class="quiet">Lines</span> - <span class='fraction'>27/39</span> - </div> - </div> - </div> - <div class='status-line medium'></div> -<pre><table class="coverage"> -<tr><td class="line-count quiet">1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134</td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">/* -* Copyright (C) 2012-2017 Centro de Computacao Cientifica e Software Livre -* Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR -* -* This file is part of simmc -* -* simmc is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, -* USA. -*/ - -var async = require('async'); - - - -var routes = { - /*"net_usage": { - validation: function(body) { - if(!body) { - return false; -} -else { -var keys = [ -'id_point', -'mac_address', -'bytes_recived', -'bytes_transmited', -'collect_time', -'packets_recived', -'packets_transmited', -]; -return isSubSet(Object.keys(body), keys); -} -}, -parser: function(body) { -return [ -dateFormat(new Date()), -body.id_point, -body.mac_address, -dateFormat(body.collect_time), -timeFormat(body.collect_time), -body.bytes_recived, -body.packets_recived, -body.bytes_transmited, -body.packets_transmited, -]; -}, -query: 'collect/net_usage.sql' -}*/ -}; - - - -module.exports = function(agentVersion) { - qb = require("../db/query_builder.js")(); - - return { - collect: function(req, res) { - var queries = []; - <span class="missing-if-branch" title="else path not taken" >E</span>if(req.body.hasOwnProperty("courses")){ - for(var i=0;i < req.body.courses.length; i++){ - var course = req.body.courses[i]; - var q = qb.insert('Course', course); - queries.push(q); - } - - } - - <span class="missing-if-branch" title="if path not taken" >I</span>if(req.body.hasOwnProperty("sessions")){ -<span class="cstat-no" title="statement not covered" > req.body.sessions.forEach(<span class="fstat-no" title="function not covered" >fu</span>nction(session){</span> -<span class="cstat-no" title="statement not covered" > queries.push(qb.insert('Session', session));</span> - }); - - } - - <span class="missing-if-branch" title="if path not taken" >I</span>if(req.body.hasOwnProperty("sessionProcedureParts")){ -<span class="cstat-no" title="statement not covered" > req.body.sessionProcedureParts.forEach(<span class="fstat-no" title="function not covered" >fu</span>nction(spp){</span> -<span class="cstat-no" title="statement not covered" > queries.push(qb.insert('sessionProcedureParts', spp));</span> - }); - - } - req.db.connect(function(err, conn, done) { - <span class="missing-if-branch" title="if path not taken" >I</span>if (err) { -<span class="cstat-no" title="statement not covered" > req.log.error(err);</span> -<span class="cstat-no" title="statement not covered" > res.status(500).json({error: 'db_connection_failed'});</span> -<span class="cstat-no" title="statement not covered" > return;</span> - } - async.waterfall([ - conn.transaction, - function(callback) { - async.everyLimit(queries, 1, async function(q){ - try{ - await conn.query(q.toParam().text, q.toParam().values); -<span class="cstat-no" title="statement not covered" > return true;</span> - }catch(err){ - callback(err); - return false; - } - }, function(err, result){ - <span class="missing-if-branch" title="if path not taken" >I</span>if(result){ -<span class="cstat-no" title="statement not covered" > callback(null);</span> - } - }); - }, - conn.commit - ], function (err, result) { - <span class="missing-if-branch" title="else path not taken" >E</span>if(err) { - req.log.error(err); - res.status(500).json({error: 'db_query_failed'}); - conn.rollback(done); - return; - } -<span class="cstat-no" title="statement not covered" > res.status(200).json({});</span> -<span class="cstat-no" title="statement not covered" > done();</span> - }); - }); - }, - version : <span class="fstat-no" title="function not covered" >fu</span>nction (req, res) { -<span class="cstat-no" title="statement not covered" > return res.status(200).json({version: agentVersion});</span> - } - }; -}; - </pre></td></tr> -</table></pre> -<div class='push'></div><!-- for sticky footer --> -</div><!-- /wrapper --> -<div class='footer quiet pad2 space-top1 center small'> - Code coverage - generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu Aug 10 2017 11:42:01 GMT-0300 (BRT) -</div> -</div> -<script src="../../prettify.js"></script> -<script> -window.onload = function () { - if (typeof prettyPrint === 'function') { - prettyPrint(); - } -}; -</script> -<script src="../../sorter.js"></script> -</body> -</html> diff --git a/coverage/webservice-pinsis/routes/index.html b/coverage/webservice-pinsis/routes/index.html deleted file mode 100644 index 2bf4bde..0000000 --- a/coverage/webservice-pinsis/routes/index.html +++ /dev/null @@ -1,106 +0,0 @@ -<!doctype html> -<html lang="en"> -<head> - <title>Code coverage report for webservice-pinsis/routes</title> - <meta charset="utf-8" /> - <link rel="stylesheet" href="../../prettify.css" /> - <link rel="stylesheet" href="../../base.css" /> - <meta name="viewport" content="width=device-width, initial-scale=1"> - <style type='text/css'> - .coverage-summary .sorter { - background-image: url(../../sort-arrow-sprite.png); - } - </style> -</head> -<body> -<div class='wrapper'> - <div class='pad1'> - <h1> - <a href="../../index.html">All files</a> webservice-pinsis/routes - </h1> - <div class='clearfix'> - <div class='fl pad1y space-right2'> - <span class="strong">59.57% </span> - <span class="quiet">Statements</span> - <span class='fraction'>28/47</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">42.86% </span> - <span class="quiet">Branches</span> - <span class='fraction'>6/14</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">58.33% </span> - <span class="quiet">Functions</span> - <span class='fraction'>7/12</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">59.57% </span> - <span class="quiet">Lines</span> - <span class='fraction'>28/47</span> - </div> - </div> - </div> - <div class='status-line medium'></div> -<div class="pad1"> -<table class="coverage-summary"> -<thead> -<tr> - <th data-col="file" data-fmt="html" data-html="true" class="file">File</th> - <th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th> - <th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th> - <th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th> - <th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th> - <th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th> - <th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th> - <th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th> - <th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th> - <th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th> -</tr> -</thead> -<tbody><tr> - <td class="file medium" data-value="agent.js"><a href="agent.js.html">agent.js</a></td> - <td data-value="69.23" class="pic medium"><div class="chart"><div class="cover-fill" style="width: 69%;"></div><div class="cover-empty" style="width:31%;"></div></div></td> - <td data-value="69.23" class="pct medium">69.23%</td> - <td data-value="39" class="abs medium">27/39</td> - <td data-value="50" class="pct medium">50%</td> - <td data-value="12" class="abs medium">6/12</td> - <td data-value="70" class="pct medium">70%</td> - <td data-value="10" class="abs medium">7/10</td> - <td data-value="69.23" class="pct medium">69.23%</td> - <td data-value="39" class="abs medium">27/39</td> - </tr> - -<tr> - <td class="file low" data-value="ping.js"><a href="ping.js.html">ping.js</a></td> - <td data-value="12.5" class="pic low"><div class="chart"><div class="cover-fill" style="width: 12%;"></div><div class="cover-empty" style="width:88%;"></div></div></td> - <td data-value="12.5" class="pct low">12.5%</td> - <td data-value="8" class="abs low">1/8</td> - <td data-value="0" class="pct low">0%</td> - <td data-value="2" class="abs low">0/2</td> - <td data-value="0" class="pct low">0%</td> - <td data-value="2" class="abs low">0/2</td> - <td data-value="12.5" class="pct low">12.5%</td> - <td data-value="8" class="abs low">1/8</td> - </tr> - -</tbody> -</table> -</div><div class='push'></div><!-- for sticky footer --> -</div><!-- /wrapper --> -<div class='footer quiet pad2 space-top1 center small'> - Code coverage - generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu Aug 10 2017 11:42:01 GMT-0300 (BRT) -</div> -</div> -<script src="../../prettify.js"></script> -<script> -window.onload = function () { - if (typeof prettyPrint === 'function') { - prettyPrint(); - } -}; -</script> -<script src="../../sorter.js"></script> -</body> -</html> diff --git a/coverage/webservice-pinsis/routes/ping.js.html b/coverage/webservice-pinsis/routes/ping.js.html deleted file mode 100644 index d7e57e2..0000000 --- a/coverage/webservice-pinsis/routes/ping.js.html +++ /dev/null @@ -1,164 +0,0 @@ -<!doctype html> -<html lang="en"> -<head> - <title>Code coverage report for webservice-pinsis/routes/ping.js</title> - <meta charset="utf-8" /> - <link rel="stylesheet" href="../../prettify.css" /> - <link rel="stylesheet" href="../../base.css" /> - <meta name="viewport" content="width=device-width, initial-scale=1"> - <style type='text/css'> - .coverage-summary .sorter { - background-image: url(../../sort-arrow-sprite.png); - } - </style> -</head> -<body> -<div class='wrapper'> - <div class='pad1'> - <h1> - <a href="../../index.html">All files</a> / <a href="index.html">webservice-pinsis/routes</a> ping.js - </h1> - <div class='clearfix'> - <div class='fl pad1y space-right2'> - <span class="strong">12.5% </span> - <span class="quiet">Statements</span> - <span class='fraction'>1/8</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">0% </span> - <span class="quiet">Branches</span> - <span class='fraction'>0/2</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">0% </span> - <span class="quiet">Functions</span> - <span class='fraction'>0/2</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">12.5% </span> - <span class="quiet">Lines</span> - <span class='fraction'>1/8</span> - </div> - </div> - </div> - <div class='status-line low'></div> -<pre><table class="coverage"> -<tr><td class="line-count quiet">1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34</td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">/* - * Copyright (C) 2012 Centro de Computacao Cientifica e Software Livre - * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR - * - * This file is part of simmc - * - * simmc is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ - -exports.get = <span class="fstat-no" title="function not covered" >fu</span>nction (req, res) { -<span class="cstat-no" title="statement not covered" > req.db.connect(<span class="fstat-no" title="function not covered" >fu</span>nction (err, conn, done) {</span> -<span class="cstat-no" title="statement not covered" > done(err);</span> -<span class="cstat-no" title="statement not covered" > if (err) {</span> -<span class="cstat-no" title="statement not covered" > res.status(200).json({ message: 'db_connection_failed' });</span> -<span class="cstat-no" title="statement not covered" > return;</span> - } -<span class="cstat-no" title="statement not covered" > res.status(200).json({ message: 'Pong' });</span> -<span class="cstat-no" title="statement not covered" > return;</span> - }); -}; - </pre></td></tr> -</table></pre> -<div class='push'></div><!-- for sticky footer --> -</div><!-- /wrapper --> -<div class='footer quiet pad2 space-top1 center small'> - Code coverage - generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu Aug 10 2017 11:42:01 GMT-0300 (BRT) -</div> -</div> -<script src="../../prettify.js"></script> -<script> -window.onload = function () { - if (typeof prettyPrint === 'function') { - prettyPrint(); - } -}; -</script> -<script src="../../sorter.js"></script> -</body> -</html> diff --git a/coverage/webservice-pinsis/server.js.html b/coverage/webservice-pinsis/server.js.html deleted file mode 100644 index a1b9032..0000000 --- a/coverage/webservice-pinsis/server.js.html +++ /dev/null @@ -1,743 +0,0 @@ -<!doctype html> -<html lang="en"> -<head> - <title>Code coverage report for webservice-pinsis/server.js</title> - <meta charset="utf-8" /> - <link rel="stylesheet" href="../prettify.css" /> - <link rel="stylesheet" href="../base.css" /> - <meta name="viewport" content="width=device-width, initial-scale=1"> - <style type='text/css'> - .coverage-summary .sorter { - background-image: url(../sort-arrow-sprite.png); - } - </style> -</head> -<body> -<div class='wrapper'> - <div class='pad1'> - <h1> - <a href="../index.html">All files</a> / <a href="index.html">webservice-pinsis</a> server.js - </h1> - <div class='clearfix'> - <div class='fl pad1y space-right2'> - <span class="strong">60.87% </span> - <span class="quiet">Statements</span> - <span class='fraction'>56/92</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">62.96% </span> - <span class="quiet">Branches</span> - <span class='fraction'>34/54</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">33.33% </span> - <span class="quiet">Functions</span> - <span class='fraction'>1/3</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">60.87% </span> - <span class="quiet">Lines</span> - <span class='fraction'>56/92</span> - </div> - </div> - </div> - <div class='status-line medium'></div> -<pre><table class="coverage"> -<tr><td class="line-count quiet">1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 -165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 -180 -181 -182 -183 -184 -185 -186 -187 -188 -189 -190 -191 -192 -193 -194 -195 -196 -197 -198 -199 -200 -201 -202 -203 -204 -205 -206 -207 -208 -209 -210 -211 -212 -213 -214 -215 -216 -217 -218 -219 -220 -221 -222 -223 -224 -225 -226 -227</td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-no"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">#!/usr/bin/env node -/* - * Copyright (C) 2012 Centro de Computacao Cientifica e Software Livre - * Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR - * - * This file is part of simmc - * - * simmc is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ - -// -// Libraries -// -var os = require('os'); -var fs = require('fs'); -var cluster = require('cluster'); -var bodyParser = require('body-parser'); -var express = require('express'); -var minimist = require('minimist'); -var path = require('path'); -var exec = require('child_process').execFile; -var collect = require('collect-webservice'); - -// -// Parse command line arguments -// -var argv = minimist(process.argv.slice(2)); -<span class="missing-if-branch" title="if path not taken" >I</span>if (argv.help || argv.h) { -<span class="cstat-no" title="statement not covered" > console.log('Usage: server.js [OPTION]...');</span> -<span class="cstat-no" title="statement not covered" > console.log('');</span> -<span class="cstat-no" title="statement not covered" > console.log('Where OPTION can be:');</span> -<span class="cstat-no" title="statement not covered" > console.log(' -c, --config alternative configuration file (default: config.js)');</span> -<span class="cstat-no" title="statement not covered" > console.log(' -p, --port port where the server will listen to');</span> -<span class="cstat-no" title="statement not covered" > console.log(' --insecure allows session cookies to be passed around in');</span> -<span class="cstat-no" title="statement not covered" > console.log(' in insecure connections');</span> -<span class="cstat-no" title="statement not covered" > console.log(' --dev force development mode');</span> -<span class="cstat-no" title="statement not covered" > console.log(' -n, --num-workers number of worker processes to spawn');</span> -<span class="cstat-no" title="statement not covered" > console.log(' -d, --daemon start the server as a daemon');</span> -<span class="cstat-no" title="statement not covered" > console.log(' --pid-file path for the pid file when running as a daemon');</span> -<span class="cstat-no" title="statement not covered" > console.log(' -h, --help show this help and exit');</span> -<span class="cstat-no" title="statement not covered" > return 0;</span> -} - -const app_mode = (process.env.NODE_ENV || <span class="branch-1 cbranch-no" title="branch not covered" >'development')</span>.trim().toLowerCase(); - -console.log(app_mode); - - -var configFile; - -//test config -<span class="missing-if-branch" title="if path not taken" >I</span>if(app_mode === 'test'){ -<span class="cstat-no" title="statement not covered" > configFile = argv.config || argv.c || 'test/config.js';</span> -}else{ - configFile = argv.config || argv.c || 'config.js'; -} - -var config; -try { - config = require(path.resolve('.', configFile)); -} -catch (e) { -<span class="cstat-no" title="statement not covered" > if (e.code === 'MODULE_NOT_FOUND') {</span> -<span class="cstat-no" title="statement not covered" > console.error('Missing configuration file ('+configFile+')!');</span> -<span class="cstat-no" title="statement not covered" > console.error('Perhaps you need to create it using:');</span> -<span class="cstat-no" title="statement not covered" > console.error(' $ cp config.example.js '+configFile);</span> -<span class="cstat-no" title="statement not covered" > console.error('');</span> -<span class="cstat-no" title="statement not covered" > return 1;</span> - } - else { -<span class="cstat-no" title="statement not covered" > console.error('Error while parsing configuration file ('+configFile+')!');</span> -<span class="cstat-no" title="statement not covered" > console.error('');</span> -<span class="cstat-no" title="statement not covered" > console.error(e.stack);</span> -<span class="cstat-no" title="statement not covered" > return 2;</span> - } -} - -var devMode = argv.dev || (process.env.NODE_ENV && (process.env.NODE_ENV.slice(0,3) === 'dev')); -var port = parseInt(argv.port || argv.p || process.env.PORT) || 3000; -var secureCookies = !argv.insecure; -var numWorkers = parseInt(argv['num-workers'] || argv.n) || (os.cpus().length * 2); -var daemon = argv.daemon || argv.d || false; -var pidfile = argv['pid-file'] || config.pid_file || process.env.PID_FILE || path.resolve('.', 'simmc.pid'); - -<span class="missing-if-branch" title="else path not taken" >E</span>if (app_mode === 'development' || <span class="branch-1 cbranch-no" title="branch not covered" >app_mode === 'test')</span> { - secureCookies = false; - - // Limit to only 1 worker in dev mode because sessions stored - // in memory are not shared between processes. - // In dev mode memcached is probably not configure therefore - // session storage falls back to memory resulting in sessions - // not persisting. - numWorkers = 1; -} - -// -// Setup logger -// -var logger = require('./lib/logger.js'); -var log = logger.default; - - -// -// Middlewares -// - -var db = require('./middleware/db.js'); -var utils = require('./lib/utils.js'); - -// -// Routes -// - -var ping = require('./routes/ping.js'); -var agent = require('./routes/agent.js')(config.agentVersion); - -//Data validation -var ct_validator = require('./validation/course_treatment.js'); - -// -// Setup express app -// -var app = express(); -app.use(logger.expressAccess); -app.use(logger.expressError); -app.use(bodyParser.json()); -app.use(bodyParser.urlencoded({extended: true})); - - - -app.use(db.pool(config.db_config)); - - - -// acquire user id and ip address -app.use(function (req, res, next) { - req.ip = req.ips[0] || req.ip || <span class="branch-2 cbranch-no" title="branch not covered" >null;</span> - next(); -}); - - - - - -// -// Setup routes -// - -app.get('/api/ping', ping.get); - - -var collect_mw = collect(ct_validator()); -app.post('/api/agent/collect/:type(course_treatment)', collect_mw, agent.collect); -app.get('/api/agent/version', agent.version); - - - - -// -// Fork process -// -<span class="missing-if-branch" title="else path not taken" >E</span>if (cluster.isMaster) { - // daemonize the process (useful for init.d scripts and similar) - <span class="missing-if-branch" title="if path not taken" >I</span>if (argv.daemon) { -<span class="cstat-no" title="statement not covered" > require('daemon')();</span> -<span class="cstat-no" title="statement not covered" > fs.writeFileSync(pidfile, process.pid+"\n");</span> - } - - log.info('Starting server in '+ (devMode ? 'development' : <span class="branch-1 cbranch-no" title="branch not covered" >'production')</span> + - ' mode, spawning ' + numWorkers + ' workers'); - - for (var i = 0; i < numWorkers; i++) { - cluster.fork(); - } - - - cluster.on('exit', <span class="fstat-no" title="function not covered" >fu</span>nction(worker, code, signal) { -<span class="cstat-no" title="statement not covered" > if (code || signal) {</span> -<span class="cstat-no" title="statement not covered" > log.error('Worker %d has ended (%s,%s).', worker.id, code, signal);</span> - } else { -<span class="cstat-no" title="statement not covered" > log.fatal('Worker %d has died. Restarting it...', worker.id);</span> -<span class="cstat-no" title="statement not covered" > cluster.fork();</span> - } - }); - - function <span class="fstat-no" title="function not covered" >exit(</span>) { -<span class="cstat-no" title="statement not covered" > log.info('Server exiting...');</span> - -<span class="cstat-no" title="statement not covered" > process.exit(0);</span> - } - - process.on('SIGTERM', exit); - process.on('SIGHUP', exit); - process.on('SIGINT', exit); -} -else { - - // - // Listen for incoming connections - // -<span class="cstat-no" title="statement not covered" > if (!module.parent) {</span> - // Only enter the listen loop if the script is executed directly - // (like: node server.js, not imported by another script). This check - // is useful for running automated tests which don't work if this - // module is "stuck" on listen loop. - -<span class="cstat-no" title="statement not covered" > log.info('Ready');</span> -<span class="cstat-no" title="statement not covered" > console.log('Worker '+cluster.worker.id+' listening...');</span> - -<span class="cstat-no" title="statement not covered" > app.listen(port);</span> - } -} -module.exports = app; - </pre></td></tr> -</table></pre> -<div class='push'></div><!-- for sticky footer --> -</div><!-- /wrapper --> -<div class='footer quiet pad2 space-top1 center small'> - Code coverage - generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu Aug 10 2017 11:42:01 GMT-0300 (BRT) -</div> -</div> -<script src="../prettify.js"></script> -<script> -window.onload = function () { - if (typeof prettyPrint === 'function') { - prettyPrint(); - } -}; -</script> -<script src="../sorter.js"></script> -</body> -</html> diff --git a/coverage/webservice-pinsis/validation/course_treatment.js.html b/coverage/webservice-pinsis/validation/course_treatment.js.html deleted file mode 100644 index 013d5f1..0000000 --- a/coverage/webservice-pinsis/validation/course_treatment.js.html +++ /dev/null @@ -1,1001 +0,0 @@ -<!doctype html> -<html lang="en"> -<head> - <title>Code coverage report for webservice-pinsis/validation/course_treatment.js</title> - <meta charset="utf-8" /> - <link rel="stylesheet" href="../../prettify.css" /> - <link rel="stylesheet" href="../../base.css" /> - <meta name="viewport" content="width=device-width, initial-scale=1"> - <style type='text/css'> - .coverage-summary .sorter { - background-image: url(../../sort-arrow-sprite.png); - } - </style> -</head> -<body> -<div class='wrapper'> - <div class='pad1'> - <h1> - <a href="../../index.html">All files</a> / <a href="index.html">webservice-pinsis/validation</a> course_treatment.js - </h1> - <div class='clearfix'> - <div class='fl pad1y space-right2'> - <span class="strong">100% </span> - <span class="quiet">Statements</span> - <span class='fraction'>4/4</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">100% </span> - <span class="quiet">Branches</span> - <span class='fraction'>0/0</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">50% </span> - <span class="quiet">Functions</span> - <span class='fraction'>1/2</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">100% </span> - <span class="quiet">Lines</span> - <span class='fraction'>4/4</span> - </div> - </div> - </div> - <div class='status-line high'></div> -<pre><table class="coverage"> -<tr><td class="line-count quiet">1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 -165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 -180 -181 -182 -183 -184 -185 -186 -187 -188 -189 -190 -191 -192 -193 -194 -195 -196 -197 -198 -199 -200 -201 -202 -203 -204 -205 -206 -207 -208 -209 -210 -211 -212 -213 -214 -215 -216 -217 -218 -219 -220 -221 -222 -223 -224 -225 -226 -227 -228 -229 -230 -231 -232 -233 -234 -235 -236 -237 -238 -239 -240 -241 -242 -243 -244 -245 -246 -247 -248 -249 -250 -251 -252 -253 -254 -255 -256 -257 -258 -259 -260 -261 -262 -263 -264 -265 -266 -267 -268 -269 -270 -271 -272 -273 -274 -275 -276 -277 -278 -279 -280 -281 -282 -283 -284 -285 -286 -287 -288 -289 -290 -291 -292 -293 -294 -295 -296 -297 -298 -299 -300 -301 -302 -303 -304 -305 -306 -307 -308 -309 -310 -311 -312 -313</td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-yes">1x</span> -<span class="cline-any cline-neutral"> </span> -<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">/* -* Copyright (C) 2012-2017 Centro de Computacao Cientifica e Software Livre -* Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR -* -* This file is part of simmc -* -* simmc is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, -* USA. -*/ - - -var config = { - global: { - fromBody: false, - param: "type" - }, - filters: {}, - collect_types: { - "course_treatment": { - "courses":{ - required: false, - isArray: true, - filters: [], - inner:{ - "CourseSer" : { - required: true, - isArray: false, - filters: [] - }, - "PatientSer" : { - required: true, - isArray: false, - filters: [] - }, - "CourseId" : { - required: true, - isArray: false, - filters: [] - }, - "StartDateTime" : { - required: true, - isArray: false, - filters: [] - }, - "ClinicalStatus" : { - required: true, - isArray: false, - filters: [] - }, - "CompletedByUserName" : { - required: true, - isArray: false, - filters: [] - }, - "CompletedDateTime" : { - required: true, - isArray: false, - filters: [] - }, - "Comment" : { - required: true, - isArray: false, - filters: [] - }, - "ClinicalProtocolDir" : { - required: true, - isArray: false, - filters: [] - }, - "HstryUserName" : { - required: true, - isArray: false, - filters: [] - }, - "HstryTimeStamp" : { - required: true, - isArray: false, - filters: [] - }, - "HstryDateTime" : { - required: true, - isArray: false, - filters: [] - }, - "TransactionId" : { - required: true, - isArray: false, - filters: [] - }, - "HstryTaskName" : { - required: true, - isArray: false, - filters: [] - } - - } - }, - "sessions":{ - required: false, - isArray: true, - filters: [], - inner:{ - "sessionSer": { - required: true, - isArray: false, - filters: [] - }, - "SessionNum": { - required: true, - isArray: false, - filters: [] - }, - "Comment": { - required: true, - isArray: false, - filters: [] - }, - "HstryUserName": { - required: true, - isArray: false, - filters: [] - }, - "HstryTimeStamp": { - required: true, - isArray: false, - filters: [] - }, - "HstryDateTime": { - required: true, - isArray: false, - filters: [] - }, - "HstryTaskName": { - required: true, - isArray: false, - filters: [] - }, - "CourseSer": { - required: true, - isArray: false, - filters: [] - }, - - } - }, - "sessionProcedureParts":{//FIXME: Is it required? - required: false, - isArray: true, - filters: [], - inner:{ - "RadiationSer" : { - required: true, - isArray: false, - filters: [] - }, - "ImageType" : { - required: true, - isArray: false, - filters: [] - }, - "SequenceNumber" : { - required: true, - isArray: false, - filters: [] - }, - "SessionProcedurePartSer" : { - required: true, - isArray: false, - filters: [] - }, - "AcqAdjustment" : { - required: true, - isArray: false, - filters: [] - }, - "AutoSave" : { - required: true, - isArray: false, - filters: [] - }, - "DoseAccumulation" : { - required: true, - isArray: false, - filters: [] - }, - "Continuous" : { - required: true, - isArray: false, - filters: [] - }, - "BeamOff" : { - required: true, - isArray: false, - filters: [] - }, - "DeviationImage" : { - required: true, - isArray: false, - filters: [] - }, - "DevEnergy" : { - required: true, - isArray: false, - filters: [] - }, - "DevDoseRate" : { - required: true, - isArray: false, - filters: [] - }, - "DevGeometry" : { - required: true, - isArray: false, - filters: [] - }, - "JawState" : { - required: true, - isArray: false, - filters: [] - }, - "DevCollX1" : { - required: true, - isArray: false, - filters: [] - }, - "DevCollX2" : { - required: true, - isArray: false, - filters: [] - }, - "DevCollY1" : { - required: true, - isArray: false, - filters: [] - }, - "DevCollY2" : { - required: true, - isArray: false, - filters: [] - }, - "MUSubtraction" : { - required: true, - isArray: false, - filters: [] - }, - "AcquisitionMode" : { - required: true, - isArray: false, - filters: [] - }, - "HstryUserName" : { - required: true, - isArray: false, - filters: [] - }, - "HstryTimeStamp" : { - required: true, - isArray: false, - filters: [] - }, - "HstryDateTime" : { - required: true, - isArray: false, - filters: [] - }, - "HstryTaskName" : { - required: true, - isArray: false, - filters: [] - }, - "SessionProcedureSer" : { - required: true, - isArray: false, - filters: [] - }, - "ImageModality" : { - required: true, - isArray: false, - filters: [] - }, - "RTPlanSer" : { - required: true, - isArray: false, - filters: [] - } - } - } - } - } -}; - -var parser = <span class="fstat-no" title="function not covered" >fu</span>nction(body){//TODO: remove extra fields in the body - -}; - - -module.exports = function() { - - return config; -}; - </pre></td></tr> -</table></pre> -<div class='push'></div><!-- for sticky footer --> -</div><!-- /wrapper --> -<div class='footer quiet pad2 space-top1 center small'> - Code coverage - generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu Aug 10 2017 11:42:01 GMT-0300 (BRT) -</div> -</div> -<script src="../../prettify.js"></script> -<script> -window.onload = function () { - if (typeof prettyPrint === 'function') { - prettyPrint(); - } -}; -</script> -<script src="../../sorter.js"></script> -</body> -</html> diff --git a/coverage/webservice-pinsis/validation/index.html b/coverage/webservice-pinsis/validation/index.html deleted file mode 100644 index 55214e5..0000000 --- a/coverage/webservice-pinsis/validation/index.html +++ /dev/null @@ -1,93 +0,0 @@ -<!doctype html> -<html lang="en"> -<head> - <title>Code coverage report for webservice-pinsis/validation</title> - <meta charset="utf-8" /> - <link rel="stylesheet" href="../../prettify.css" /> - <link rel="stylesheet" href="../../base.css" /> - <meta name="viewport" content="width=device-width, initial-scale=1"> - <style type='text/css'> - .coverage-summary .sorter { - background-image: url(../../sort-arrow-sprite.png); - } - </style> -</head> -<body> -<div class='wrapper'> - <div class='pad1'> - <h1> - <a href="../../index.html">All files</a> webservice-pinsis/validation - </h1> - <div class='clearfix'> - <div class='fl pad1y space-right2'> - <span class="strong">100% </span> - <span class="quiet">Statements</span> - <span class='fraction'>4/4</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">100% </span> - <span class="quiet">Branches</span> - <span class='fraction'>0/0</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">50% </span> - <span class="quiet">Functions</span> - <span class='fraction'>1/2</span> - </div> - <div class='fl pad1y space-right2'> - <span class="strong">100% </span> - <span class="quiet">Lines</span> - <span class='fraction'>4/4</span> - </div> - </div> - </div> - <div class='status-line high'></div> -<div class="pad1"> -<table class="coverage-summary"> -<thead> -<tr> - <th data-col="file" data-fmt="html" data-html="true" class="file">File</th> - <th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th> - <th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th> - <th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th> - <th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th> - <th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th> - <th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th> - <th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th> - <th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th> - <th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th> -</tr> -</thead> -<tbody><tr> - <td class="file high" data-value="course_treatment.js"><a href="course_treatment.js.html">course_treatment.js</a></td> - <td data-value="100" class="pic high"><div class="chart"><div class="cover-fill cover-full" style="width: 100%;"></div><div class="cover-empty" style="width:0%;"></div></div></td> - <td data-value="100" class="pct high">100%</td> - <td data-value="4" class="abs high">4/4</td> - <td data-value="100" class="pct high">100%</td> - <td data-value="0" class="abs high">0/0</td> - <td data-value="50" class="pct medium">50%</td> - <td data-value="2" class="abs medium">1/2</td> - <td data-value="100" class="pct high">100%</td> - <td data-value="4" class="abs high">4/4</td> - </tr> - -</tbody> -</table> -</div><div class='push'></div><!-- for sticky footer --> -</div><!-- /wrapper --> -<div class='footer quiet pad2 space-top1 center small'> - Code coverage - generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu Aug 10 2017 11:42:01 GMT-0300 (BRT) -</div> -</div> -<script src="../../prettify.js"></script> -<script> -window.onload = function () { - if (typeof prettyPrint === 'function') { - prettyPrint(); - } -}; -</script> -<script src="../../sorter.js"></script> -</body> -</html> diff --git a/scripts_database/create/schema/bd.sql b/database/create/schema/bd.sql similarity index 100% rename from scripts_database/create/schema/bd.sql rename to database/create/schema/bd.sql diff --git a/scripts_database/create_database.sh b/database/create_database.sh similarity index 100% rename from scripts_database/create_database.sh rename to database/create_database.sh diff --git a/scripts_database/create_user.sh b/database/create_user.sh similarity index 100% rename from scripts_database/create_user.sh rename to database/create_user.sh diff --git a/gulpfile.js b/gulpfile.js index cadecc7..94ef921 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,7 +1,8 @@ -var gulp = require('gulp'), - jshint = require('gulp-jshint'), - shell = require('gulp-shell'); - mocha = require('gulp-mocha'); +const gulp = require('gulp'); +const jshint = require('gulp-jshint'); +const shell = require('gulp-shell'); +const mocha = require('gulp-mocha'); +const istanbul = require('gulp-istanbul'); var js_files = "**/*.js"; @@ -10,7 +11,7 @@ const app_state = (process.env.NODE_ENV || 'development').trim().toLowerCase(); //dev config var dev_config_file = './config.js'; -var test_config_file = './test/config.js'; +var test_config_file = './config_test.js'; //var config = require(configFile); @@ -41,15 +42,45 @@ gulp.task('create_database_test', function(){ var config = require(test_config_file); - return gulp.src("scripts_database") - .pipe(shell("./scripts_database/create_database.sh " + config.db_config.database)) - .pipe(shell("./scripts_database/create_user.sh " + config.db_config.user + " " + config.db_config.password + " " + config.db_config.database )); + return gulp.src("database") + .pipe(shell("./database/create_database.sh " + config.db_config.database)) + .pipe(shell("./database/create_user.sh " + config.db_config.user + " " + config.db_config.password + " " + config.db_config.database )); }); -gulp.task('test',['create_database_test'], function(){ - return gulp.src(['test/*.js']) - .pipe(mocha({ - reporter : 'spec' - })); + + +gulp.task('pre-test', () => { + return gulp.src(['src/**/*.js']) + .pipe(istanbul({includeUntested: true})) + .pipe(istanbul.hookRequire()); +}); + +gulp.task('test',['create_database_test','pre-test'], function(){ + + gulp.src(['test/**/*.js'], {read: false}) + .pipe(mocha({timeout: 60000})) + .pipe(istanbul.writeReports()) + .pipe(istanbul.enforceThresholds({ + thresholds: { + global: { + statements: 80, + branches: 70, + lines: 80, + functions: 80 + } + } + })) + .on('error', () => { + process.exit(1); + }) + .on('end', () => { + process.exit(); + }); + + + // return gulp.src(['test/*.js']) + // .pipe(mocha({ + // reporter : 'spec' + // })); }); diff --git a/lib/agentbuilder.js b/lib/agentbuilder.js deleted file mode 100644 index 24cb61e..0000000 --- a/lib/agentbuilder.js +++ /dev/null @@ -1,35 +0,0 @@ -var exec = require('child_process').exec; - -exports.build = function(id_point, os, proxy, callback) { - var buildScript, - proxyParams = ""; - - if (isNaN(id_point)) { - return callback({error: 'invalid_id_point'}); - } - - if (os === 'windows') - buildScript = __dirname + '/../scripts/build-windows-installer.sh'; - else - buildScript = __dirname + '/../scripts/build-linux-installer.sh'; - - if (proxy) { - // the replace method removes whitespaces that are not allowed in this fields - var host = (proxy.host || '').replace(/ /g, ''), - port = (proxy.port || '').replace(/ /g, ''), - user = (proxy.user || '').replace(/ /g, ''), - pass = (proxy.pass || '').replace(/ /g, ''); - - // check if the port number is actually a number or an empty string - if ( (port !== '') && (isNaN(parseInt(port),10)) ) { - return callback({error: 'invalid_proxy_port'}); - } - - proxyParams = '"'+host+'" "'+port+'" "'+user+'" "'+pass+'"'; - } - - var cmdline = buildScript + ' ' + id_point + ' ' + proxyParams; - exec(cmdline, function (err, stdout, stderr) { - callback(err, stdout); - }); -}; \ No newline at end of file diff --git a/middleware/cache.js b/middleware/cache.js deleted file mode 100644 index a9df833..0000000 --- a/middleware/cache.js +++ /dev/null @@ -1,37 +0,0 @@ -module.exports = function (config) { - var memcached = null; - if (config) { // require memcached module only if configured - var Memcached = require('memcached'); - memcached = new Memcached(config.server || 'localhost:11211', config.options || {}); - } - - return { - try: function (req, res, next) { - if (!memcached) { // memcached not configured - next(); - return; - } - - memcached.get(req.url, function (err, data) { - if (err) { - console.log('Memcached error:\n'); - console.log(err); - next(); - } - else if (data) { - if (config.debug) console.log('cached response to '+req.url); - res.status(200).send(data); - } - else { - // provide a method for the route to cache its response - res.cache = function (data, cb) { - if (config.debug) console.log('caching '+req.url); - memcached.set(req.url, data, config.lifetime || 3600, cb || function (err) {}); - }; - - next(); - } - }); - } - }; -}; diff --git a/package.json b/package.json index 568e9a9..7d64b2e 100644 --- a/package.json +++ b/package.json @@ -10,8 +10,7 @@ "url": "git@gitlab.c3sl.ufpr.br:PInSIS/webservice-pinsis.git" }, "scripts": { - "start": "node server.js", - "test": "nyc --reporter=html --reporter=text mocha --timeout=3000" + "start": "node src/server.js" }, "dependencies": { "express": "^4.13.3", @@ -29,6 +28,7 @@ "chai": "^4.1.0", "chai-http": "^3.0.0", "gulp": "^3.9.1", + "gulp-istanbul": "^1.1.2", "gulp-jshint": "^2.0.4", "gulp-mocha": "^4.3.1", "gulp-shell": "^0.6.3", diff --git a/Dockerfile b/src/Dockerfile similarity index 100% rename from Dockerfile rename to src/Dockerfile diff --git a/db/query_builder.js b/src/db/query_builder.js similarity index 100% rename from db/query_builder.js rename to src/db/query_builder.js diff --git a/lib/logger.js b/src/lib/logger.js similarity index 100% rename from lib/logger.js rename to src/lib/logger.js diff --git a/middleware/db.js b/src/middleware/db.js similarity index 100% rename from middleware/db.js rename to src/middleware/db.js diff --git a/routes/agent.js b/src/routes/agent.js similarity index 100% rename from routes/agent.js rename to src/routes/agent.js diff --git a/routes/ping.js b/src/routes/ping.js similarity index 100% rename from routes/ping.js rename to src/routes/ping.js diff --git a/server.js b/src/server.js similarity index 99% rename from server.js rename to src/server.js index 6937d5f..0ceb0ff 100644 --- a/server.js +++ b/src/server.js @@ -62,7 +62,7 @@ var configFile; //test config if(app_mode === 'test'){ - configFile = argv.config || argv.c || 'test/config.js'; + configFile = argv.config || argv.c || 'config_test.js'; }else{ configFile = argv.config || argv.c || 'config.js'; } diff --git a/validation/course_treatment.js b/src/validation/course_treatment.js similarity index 100% rename from validation/course_treatment.js rename to src/validation/course_treatment.js diff --git a/test/agent.js b/test/agent.js index fe12e20..24d51d1 100644 --- a/test/agent.js +++ b/test/agent.js @@ -1,7 +1,7 @@ process.env.NODE_ENV = 'test'; let chai = require('chai'); let chaiHttp = require('chai-http'); -const server = require('../server'); +const server = require('../src/server.js'); let should = chai.should(); chai.use(chaiHttp); -- GitLab From 66a1015b8338b7688d5260bc9346f51cbc5a2b2f Mon Sep 17 00:00:00 2001 From: Davisson Paulino <dhp14@inf.ufpr.br> Date: Mon, 21 Aug 2017 12:02:20 -0300 Subject: [PATCH 24/30] fix gulp-mocha and added ping, agent query_builder tests --- .gitlab-ci.yml | 2 +- gulpfile.js | 5 +++-- package.json | 2 +- src/db/query_builder.js | 30 +++++++++++++----------------- src/routes/agent.js | 2 +- test/db/query_builder.js | 37 +++++++++++++++++++++++++++++++++++++ test/{ => routes}/agent.js | 18 ++++++++++++++++-- test/routes/ping.js | 28 ++++++++++++++++++++++++++++ 8 files changed, 100 insertions(+), 24 deletions(-) create mode 100644 test/db/query_builder.js rename test/{ => routes}/agent.js (63%) create mode 100644 test/routes/ping.js diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3d36836..d50a056 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,7 +16,7 @@ before_script: run_tests: stage: test script: - - mv test/config.js.example test/config.js + - mv config_test.js.example config_test.js - gulp test tags: - node diff --git a/gulpfile.js b/gulpfile.js index 94ef921..8ac6a94 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,3 +1,4 @@ +/*jshint esversion:6*/ const gulp = require('gulp'); const jshint = require('gulp-jshint'); const shell = require('gulp-shell'); @@ -43,8 +44,8 @@ gulp.task('create_database_test', function(){ var config = require(test_config_file); return gulp.src("database") - .pipe(shell("./database/create_database.sh " + config.db_config.database)) - .pipe(shell("./database/create_user.sh " + config.db_config.user + " " + config.db_config.password + " " + config.db_config.database )); + .pipe(shell("yes | ./database/create_database.sh " + config.db_config.database)) + .pipe(shell("yes | ./database/create_user.sh " + config.db_config.user + " " + config.db_config.password + " " + config.db_config.database )); }); diff --git a/package.json b/package.json index 7d64b2e..4e52e6f 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "gulp": "^3.9.1", "gulp-istanbul": "^1.1.2", "gulp-jshint": "^2.0.4", - "gulp-mocha": "^4.3.1", + "gulp-mocha": "^v3.0.1", "gulp-shell": "^0.6.3", "jshint": "latest", "jshint-stylish": "^2.2.1", diff --git a/src/db/query_builder.js b/src/db/query_builder.js index 6911888..7ebc445 100644 --- a/src/db/query_builder.js +++ b/src/db/query_builder.js @@ -1,21 +1,17 @@ -module.exports = function(){ +squel = require("squel").useFlavour('postgres'); - squel = require("squel").useFlavour('postgres'); - - - return { - set_from_attr : function (query, obj){ - for (var property in obj) { - if (obj.hasOwnProperty(property)) { - query.set(property, obj[property]); - } +module.exports = { + set_from_attr : function (query, obj){ + for (var property in obj) { + if (obj.hasOwnProperty(property)) { + query.set(property, obj[property]); } - return query; - }, - insert: function (table, obj){ - var q = squel.insert().into(table); - this.set_from_attr(q, obj); - return q; } - }; + return query; + }, + insert: function (table, obj){ + var q = squel.insert().into(table); + this.set_from_attr(q, obj); + return q; + } }; diff --git a/src/routes/agent.js b/src/routes/agent.js index c600641..0bd2f8b 100644 --- a/src/routes/agent.js +++ b/src/routes/agent.js @@ -25,7 +25,7 @@ var async = require('async'); module.exports = function(agentVersion) { - qb = require("../db/query_builder.js")(); + qb = require("../db/query_builder.js"); return { collect: function(req, res) { diff --git a/test/db/query_builder.js b/test/db/query_builder.js new file mode 100644 index 0000000..a6e86ec --- /dev/null +++ b/test/db/query_builder.js @@ -0,0 +1,37 @@ +/*jshint esversion: 6*/ +process.env.NODE_ENV = 'test'; +let chai = require('chai'); +let should = chai.should(); + + + +var toType = function(obj) { + return ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase(); +}; + +describe('Query builder',() => { + const qb = require('../../src/db/query_builder.js'); + var squel = require("squel").useFlavour('postgres'); + + it('insert return a valid query ', (done) => { + const table = 'tb'; + const obj = { + attr1: "v1", + attr2: 2 + }; + var trueq = squel.insert() + .into(table) + .set('attr1', obj.attr1) + .set('attr2', obj.attr2); + + var resultq = qb.insert(table, obj); + + resultq.should.be.an('object'); + resultq.toString().should.equal(trueq.toString()); + + done(); + }); + + + +}); diff --git a/test/agent.js b/test/routes/agent.js similarity index 63% rename from test/agent.js rename to test/routes/agent.js index 24d51d1..cf2598e 100644 --- a/test/agent.js +++ b/test/routes/agent.js @@ -1,7 +1,10 @@ +/*jshint esversion: 6*/ + process.env.NODE_ENV = 'test'; let chai = require('chai'); let chaiHttp = require('chai-http'); -const server = require('../src/server.js'); +const src_dir='../../src/'; +const server = require(src_dir + 'server.js'); let should = chai.should(); chai.use(chaiHttp); @@ -27,7 +30,7 @@ describe('course_treatment', () => { "TransactionId" : "1", "HstryTaskName" : "HTN1" }]; - it('it should post courses', (done) => { + it('it should post courses', (done) => { chai.request(server) .post('/api/agent/collect/course_treatment') .send({courses: courses}) @@ -37,4 +40,15 @@ describe('course_treatment', () => { }); }); + it('it should give a error for save duplicate courses', (done) =>{ + chai.request(server) + .post('/api/agent/collect/course_treatment') + .send({courses: courses}) + .end((err, res) => { + res.should.have.status(500); + res.body.should.be.a('object'); + res.body.should.have.property('error').eql('db_query_failed'); + done(); + }); + }); }); diff --git a/test/routes/ping.js b/test/routes/ping.js new file mode 100644 index 0000000..c1b8d06 --- /dev/null +++ b/test/routes/ping.js @@ -0,0 +1,28 @@ +/*jshint esversion: 6*/ + +process.env.NODE_ENV = 'test'; +let chai = require('chai'); +let chaiHttp = require('chai-http'); +const src_dir='../../src/'; +const server = require(src_dir + 'server.js'); +let should = chai.should(); + +chai.use(chaiHttp); + + +//console.log("lol"); +//console.log(server); +describe('ping', () => { + + + it('it should pong', (done) => { + chai.request(server) + .get('/api/ping') + .end((err, res) => { + res.should.have.status(200); + res.body.should.have.property('message').eql('Pong'); + done(); + }); + + }); +}); -- GitLab From 640a28d3bd73d34d6952bf21cd7ad7115f136dc6 Mon Sep 17 00:00:00 2001 From: Davisson Paulino <dhp14@inf.ufpr.br> Date: Tue, 22 Aug 2017 10:39:27 -0300 Subject: [PATCH 25/30] fix size of attributes --- database/create/schema/bd.sql | 42 +++++++++++++++++------------------ 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/database/create/schema/bd.sql b/database/create/schema/bd.sql index 05d1d6d..bdfe032 100755 --- a/database/create/schema/bd.sql +++ b/database/create/schema/bd.sql @@ -4,21 +4,21 @@ START TRANSACTION; CREATE TABLE session( sessionSer BIGINT, SessionNum INT, - Comment VARCHAR(11), - HstryUserName VARCHAR(11), + Comment VARCHAR(254), + HstryUserName VARCHAR(32), HstryTimeStamp TIMESTAMP, HstryDateTime TIMESTAMP, - HstryTaskName VARCHAR(11), + HstryTaskName VARCHAR(32), CourseSer BIGINT, CONSTRAINT pk_session primary key(sessionSer) ); CREATE TABLE SessionProcedurePart( RadiationSer BIGINT, - ImageType VARCHAR(11), + ImageType VARCHAR(32), SequenceNumber INT, SessionProcedurePartSer BIGINT, - AcqAdjustment FLOAT(11), + AcqAdjustment FLOAT, AutoSave INT, DoseAccumulation INT, Continuous INT, @@ -27,19 +27,19 @@ CREATE TABLE SessionProcedurePart( DevEnergy INT, DevDoseRate INT, DevGeometry INT, - JawState FLOAT(11), - DevCollX1 FLOAT(11), - DevCollX2 FLOAT(11), - DevCollY1 FLOAT(11), - DevCollY2 FLOAT(11), + JawState FLOAT, + DevCollX1 FLOAT, + DevCollX2 FLOAT, + DevCollY1 FLOAT, + DevCollY2 FLOAT, MUSubtraction INT, - AcquisitionMode VARCHAR(11), - HstryUserName VARCHAR(11), + AcquisitionMode VARCHAR(64), + HstryUserName VARCHAR(32), HstryTimeStamp TIMESTAMP, HstryDateTime TIMESTAMP, - HstryTaskName VARCHAR(11), + HstryTaskName VARCHAR(32), SessionProcedureSer BIGINT, - ImageModality VARCHAR(11), + ImageModality VARCHAR(16), RTPlanSer BIGINT, CONSTRAINT pk_SessionProcedurePart primary key(SessionProcedurePartSer) ); @@ -47,18 +47,18 @@ CREATE TABLE SessionProcedurePart( CREATE TABLE Course( CourseSer BIGINT, PatientSer BIGINT, - CourseId VARCHAR(11), + CourseId VARCHAR(16), StartDateTime TIMESTAMP, - ClinicalStatus VARCHAR(11), - CompletedByUserName VARCHAR(11), + ClinicalStatus VARCHAR(16), + CompletedByUserName VARCHAR(32), CompletedDateTime TIMESTAMP, - Comment VARCHAR(11), - ClinicalProtocolDir VARCHAR(11), - HstryUserName VARCHAR(11) not null, + Comment VARCHAR(254), + ClinicalProtocolDir VARCHAR(254), + HstryUserName VARCHAR(32) not null, HstryTimeStamp TIMESTAMP, HstryDateTime TIMESTAMP, - TransactionId VARCHAR(11), HstryTaskName VARCHAR(32), + TransactionId VARCHAR(255), CONSTRAINT pk_Course primary key(CourseSer) ); -- GitLab From 5c1941ae2499d2eaa56c06bfe0d192fc8ce8b41d Mon Sep 17 00:00:00 2001 From: Davisson Paulino <dhp14@inf.ufpr.br> Date: Tue, 22 Aug 2017 11:59:34 -0300 Subject: [PATCH 26/30] fix sessionProcedurePart and added more tests --- src/middleware/db.js | 88 ++++++++++++++++++++++---------------------- src/routes/agent.js | 2 +- src/server.js | 7 ++-- test/routes/agent.js | 63 ++++++++++++++++++++++++++++++- 4 files changed, 110 insertions(+), 50 deletions(-) diff --git a/src/middleware/db.js b/src/middleware/db.js index 4893254..55b72f6 100644 --- a/src/middleware/db.js +++ b/src/middleware/db.js @@ -102,38 +102,38 @@ function Connection(client) { }; }; - this.queryFromFile = function(file, params, callback) { - var queries_dir = __dirname + "/../queries/"; - - fs.readFile(queries_dir + file, 'utf8', function (err, data) { - if (err) { - return callback(err); - } - - if (typeof params === 'undefined') { - params = []; - } - - client.query(data, params, callback); - }); - }; - - this.executeFromFile = function(file, params) { - var $this = this; - - return function (callback) { - $this.queryFromFile(file, params, function (err) { - callback(err); - }); - }; - }; - - this.copyFrom = function (query, callback) { - var stream = client.query(copyFrom(query)); - stream.on('end', callback); - stream.on('error', callback); - return stream; - }; + // this.queryFromFile = function(file, params, callback) { + // var queries_dir = __dirname + "/../queries/"; + // + // fs.readFile(queries_dir + file, 'utf8', function (err, data) { + // if (err) { + // return callback(err); + // } + // + // if (typeof params === 'undefined') { + // params = []; + // } + // + // client.query(data, params, callback); + // }); + // }; + + // this.executeFromFile = function(file, params) { + // var $this = this; + // + // return function (callback) { + // $this.queryFromFile(file, params, function (err) { + // callback(err); + // }); + // }; + // }; + // + // this.copyFrom = function (query, callback) { + // var stream = client.query(copyFrom(query)); + // stream.on('end', callback); + // stream.on('error', callback); + // return stream; + // }; this.transaction = function (callback) { client.query('BEGIN;', function (err) { @@ -153,16 +153,16 @@ function Connection(client) { }); }; - this.auth = function (user, ip, action, comment) { - return function (callback) { - if (!(user && user.id)) - return callback('not_logged_in'); - - client.query('SELECT auth.user_action($1, $2, $3, $4);', - [user.id, ip, action, comment], - function (err) { - callback(err); - }); - }; - }; + // this.auth = function (user, ip, action, comment) { + // return function (callback) { + // if (!(user && user.id)) + // return callback('not_logged_in'); + // + // client.query('SELECT auth.user_action($1, $2, $3, $4);', + // [user.id, ip, action, comment], + // function (err) { + // callback(err); + // }); + // }; + // }; } diff --git a/src/routes/agent.js b/src/routes/agent.js index 0bd2f8b..4359b7f 100644 --- a/src/routes/agent.js +++ b/src/routes/agent.js @@ -48,7 +48,7 @@ module.exports = function(agentVersion) { if(req.body.hasOwnProperty("sessionProcedureParts")){ req.body.sessionProcedureParts.forEach(function(spp){ - queries.push(qb.insert('sessionProcedureParts', spp)); + queries.push(qb.insert('sessionProcedurePart', spp)); }); } diff --git a/src/server.js b/src/server.js index 0ceb0ff..e561d17 100644 --- a/src/server.js +++ b/src/server.js @@ -24,6 +24,7 @@ // // Libraries // +/*jshint esversion: 6*/ var os = require('os'); var fs = require('fs'); var cluster = require('cluster'); @@ -92,9 +93,9 @@ var port = parseInt(argv.port || argv.p || process.env.PORT) || 3000; var secureCookies = !argv.insecure; var numWorkers = parseInt(argv['num-workers'] || argv.n) || (os.cpus().length * 2); var daemon = argv.daemon || argv.d || false; -var pidfile = argv['pid-file'] || config.pid_file || process.env.PID_FILE || path.resolve('.', 'simmc.pid'); +var pidfile = argv['pid-file'] || config.pid_file || process.env.PID_FILE || path.resolve('.', 'pinsis.pid'); -if (app_mode === 'development' || app_mode === 'test') { +if (app_mode === 'development' ) { secureCookies = false; // Limit to only 1 worker in dev mode because sessions stored @@ -182,7 +183,7 @@ if (cluster.isMaster) { fs.writeFileSync(pidfile, process.pid+"\n"); } - log.info('Starting server in '+ (devMode ? 'development' : 'production') + + log.info('Starting server in '+ app_mode + ' mode, spawning ' + numWorkers + ' workers'); for (var i = 0; i < numWorkers; i++) { diff --git a/test/routes/agent.js b/test/routes/agent.js index cf2598e..ae61c9a 100644 --- a/test/routes/agent.js +++ b/test/routes/agent.js @@ -30,10 +30,53 @@ describe('course_treatment', () => { "TransactionId" : "1", "HstryTaskName" : "HTN1" }]; - it('it should post courses', (done) => { + + let sessions = [{ + "sessionSer": "1", + "SessionNum": "1", + "Comment": "C1", + "HstryUserName": "HUN1", + "HstryTimeStamp": "1111-11-11 11:11:11", + "HstryDateTime": "1111-11-11 11:11:11", + "HstryTaskName": "HTN1", + "CourseSer": "1" + }]; + + let sessionProcedureParts = [{ + "RadiationSer" : "1", + "ImageType" : "IT1", + "SequenceNumber" : "1", + "SessionProcedurePartSer" : "1", + "AcqAdjustment" : "1", + "AutoSave" : "1", + "DoseAccumulation" : "1", + "Continuous" : "1", + "BeamOff" : "1", + "DeviationImage" : "1", + "DevEnergy" : "1", + "DevDoseRate" : "1", + "DevGeometry" : "1", + "JawState" : "1", + "DevCollX1" : "1", + "DevCollX2" : "1", + "DevCollY1" : "1", + "DevCollY2" : "1", + "MUSubtraction" : "1", + "AcquisitionMode" : "AM1", + "HstryUserName" : "HUN1", + "HstryTimeStamp" : "1111-11-11 11:11:11", + "HstryDateTime" : "1111-11-11 11:11:11", + "HstryTaskName" : "1111-11-11 11:11:11", + "SessionProcedureSer" : "1", + "ImageModality" : "IM1", + "RTPlanSer" : "1" + }]; + + + it('it should post courses, sessions and sessionProcedureParts', (done) => { chai.request(server) .post('/api/agent/collect/course_treatment') - .send({courses: courses}) + .send({courses: courses, sessions: sessions, sessionProcedureParts: sessionProcedureParts}) .end((err, res) => { res.should.have.status(200); done(); @@ -52,3 +95,19 @@ describe('course_treatment', () => { }); }); }); + +describe('agent version', () => { + + it('it should get version of the agent', (done) => { + + const config = require('../../config_test.js'); + + chai.request(server) + .get('/api/agent/version') + .end((err, res) => { + res.should.have.status(200); + res.body.should.have.property('version').eql(config.agentVersion); + done(); + }); + }); +}); -- GitLab From f9a93362ef8ee9771e265710158fb41fbac4d9f5 Mon Sep 17 00:00:00 2001 From: Davisson Paulino <dhp14@inf.ufpr.br> Date: Wed, 7 Feb 2018 13:23:23 -0200 Subject: [PATCH 27/30] =?UTF-8?q?N=C3=A3o=20sei=20o=20que=20fiz=20nesse=20?= =?UTF-8?q?commit,=20s=C3=B3=20salvando=20hist=C3=B3rico?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config_test_error.js | 12 ++++++++++++ src/server.js | 2 +- src/validation/course_treatment.js | 5 ----- test/routes/ping.js | 18 +++++++++++++++++- test/server.js | 18 ++++++++++++++++++ 5 files changed, 48 insertions(+), 7 deletions(-) create mode 100644 config_test_error.js create mode 100644 test/server.js diff --git a/config_test_error.js b/config_test_error.js new file mode 100644 index 0000000..5a00d0e --- /dev/null +++ b/config_test_error.js @@ -0,0 +1,12 @@ +var config = module.exports = {}; + +config.db_config = { + user: 'error', + password: 'error', + database: 'error', + host: 'localhost', + port: 5432 +}; + + +config.agentVersion = 0.0; diff --git a/src/server.js b/src/server.js index e561d17..ddcf6ec 100644 --- a/src/server.js +++ b/src/server.js @@ -95,7 +95,7 @@ var numWorkers = parseInt(argv['num-workers'] || argv.n) || (os.cpus().length * var daemon = argv.daemon || argv.d || false; var pidfile = argv['pid-file'] || config.pid_file || process.env.PID_FILE || path.resolve('.', 'pinsis.pid'); -if (app_mode === 'development' ) { +if (app_mode === 'development' || app_mode === 'test') { secureCookies = false; // Limit to only 1 worker in dev mode because sessions stored diff --git a/src/validation/course_treatment.js b/src/validation/course_treatment.js index f97d032..72b00c6 100644 --- a/src/validation/course_treatment.js +++ b/src/validation/course_treatment.js @@ -301,11 +301,6 @@ var config = { } }; -var parser = function(body){//TODO: remove extra fields in the body - -}; - - module.exports = function() { return config; diff --git a/test/routes/ping.js b/test/routes/ping.js index c1b8d06..4c9cf2c 100644 --- a/test/routes/ping.js +++ b/test/routes/ping.js @@ -4,7 +4,7 @@ process.env.NODE_ENV = 'test'; let chai = require('chai'); let chaiHttp = require('chai-http'); const src_dir='../../src/'; -const server = require(src_dir + 'server.js'); + let should = chai.should(); chai.use(chaiHttp); @@ -16,6 +16,7 @@ describe('ping', () => { it('it should pong', (done) => { + const server = require(src_dir + 'server.js'); chai.request(server) .get('/api/ping') .end((err, res) => { @@ -25,4 +26,19 @@ describe('ping', () => { }); }); + + it('it shouldn\'t pong', (done) =>{ + process.argv.push("--config"); + process.argv.push("config_test_error.js"); + + const server = require(src_dir + 'server.js'); + chai.request(server) + .get('/api/ping') + .end((err, res) => { + res.should.have.status(200); + res.body.should.have.property('message').eql('db_connection_failed'); + done(); + }); + + }); }); diff --git a/test/server.js b/test/server.js new file mode 100644 index 0000000..04d18ae --- /dev/null +++ b/test/server.js @@ -0,0 +1,18 @@ +// /*jshint esversion: 6*/ +// +// process.env.NODE_ENV = 'test'; +// let chai = require('chai'); +// let chaiHttp = require('chai-http'); +// const src_dir='../../src/'; +// const server = require(src_dir + 'server.js'); +// let should = chai.should(); +// +// chai.use(chaiHttp); +// +// +// //console.log("lol"); +// //console.log(server); +// describe('Server', () => { +// +// it('it should have') +// }); -- GitLab From 07043c4194eb1778aa68414d74b74f6422b12d18 Mon Sep 17 00:00:00 2001 From: bhm15 <bruno.meyer@ufpr.br> Date: Mon, 19 Feb 2018 11:40:02 -0300 Subject: [PATCH 28/30] ISSUE#9:Add DB create and populate functions --- database/create/schema/bd.sql | 131 ++++++++++++-------- src/db/query_builder.js | 5 + src/middleware/db.js | 6 +- src/middleware/populate.js | 222 ++++++++++++++++++++++++++++++++++ src/routes/data.js | 53 ++++++++ src/server.js | 28 ++++- src/static/exemplo.html | 159 ++++++++++++++++++++++++ src/static/pinsis.ejs | 35 ++++++ 8 files changed, 584 insertions(+), 55 deletions(-) create mode 100644 src/middleware/populate.js create mode 100644 src/routes/data.js create mode 100644 src/static/exemplo.html create mode 100644 src/static/pinsis.ejs diff --git a/database/create/schema/bd.sql b/database/create/schema/bd.sql index bdfe032..4dcdcd1 100755 --- a/database/create/schema/bd.sql +++ b/database/create/schema/bd.sql @@ -2,68 +2,95 @@ START TRANSACTION; CREATE TABLE session( - sessionSer BIGINT, - SessionNum INT, - Comment VARCHAR(254), - HstryUserName VARCHAR(32), - HstryTimeStamp TIMESTAMP, - HstryDateTime TIMESTAMP, - HstryTaskName VARCHAR(32), - CourseSer BIGINT, - CONSTRAINT pk_session primary key(sessionSer) + sessionSer BIGINT, + SessionNum INT, + Comment VARCHAR(254), + HstryUserName VARCHAR(32), + HstryTimeStamp TIMESTAMP, + HstryDateTime TIMESTAMP, + HstryTaskName VARCHAR(32), + CourseSer BIGINT, + CONSTRAINT pk_session primary key(sessionSer) ); CREATE TABLE SessionProcedurePart( - RadiationSer BIGINT, - ImageType VARCHAR(32), - SequenceNumber INT, - SessionProcedurePartSer BIGINT, - AcqAdjustment FLOAT, - AutoSave INT, - DoseAccumulation INT, - Continuous INT, - BeamOff INT, - DeviationImage INT, - DevEnergy INT, - DevDoseRate INT, - DevGeometry INT, - JawState FLOAT, - DevCollX1 FLOAT, - DevCollX2 FLOAT, - DevCollY1 FLOAT, - DevCollY2 FLOAT, - MUSubtraction INT, - AcquisitionMode VARCHAR(64), - HstryUserName VARCHAR(32), - HstryTimeStamp TIMESTAMP, - HstryDateTime TIMESTAMP, - HstryTaskName VARCHAR(32), - SessionProcedureSer BIGINT, - ImageModality VARCHAR(16), - RTPlanSer BIGINT, - CONSTRAINT pk_SessionProcedurePart primary key(SessionProcedurePartSer) + RadiationSer BIGINT, + ImageType VARCHAR(32), + SequenceNumber INT, + SessionProcedurePartSer BIGINT, + AcqAdjustment FLOAT, + AutoSave INT, + DoseAccumulation INT, + Continuous INT, + BeamOff INT, + DeviationImage INT, + DevEnergy INT, + DevDoseRate INT, + DevGeometry INT, + JawState FLOAT, + DevCollX1 FLOAT, + DevCollX2 FLOAT, + DevCollY1 FLOAT, + DevCollY2 FLOAT, + MUSubtraction INT, + AcquisitionMode VARCHAR(64), + HstryUserName VARCHAR(32), + HstryTimeStamp TIMESTAMP, + HstryDateTime TIMESTAMP, + HstryTaskName VARCHAR(32), + SessionProcedureSer BIGINT, + ImageModality VARCHAR(16), + RTPlanSer BIGINT, + CONSTRAINT pk_SessionProcedurePart primary key(SessionProcedurePartSer) ); CREATE TABLE Course( - CourseSer BIGINT, - PatientSer BIGINT, - CourseId VARCHAR(16), - StartDateTime TIMESTAMP, - ClinicalStatus VARCHAR(16), - CompletedByUserName VARCHAR(32), - CompletedDateTime TIMESTAMP, - Comment VARCHAR(254), - ClinicalProtocolDir VARCHAR(254), - HstryUserName VARCHAR(32) not null, - HstryTimeStamp TIMESTAMP, - HstryDateTime TIMESTAMP, - HstryTaskName VARCHAR(32), - TransactionId VARCHAR(255), - CONSTRAINT pk_Course primary key(CourseSer) + CourseSer BIGINT, + PatientSer BIGINT, + CourseId VARCHAR(16), + StartDateTime TIMESTAMP, + ClinicalStatus VARCHAR(16), + CompletedByUserName VARCHAR(32), + CompletedDateTime TIMESTAMP, + Comment VARCHAR(254), + ClinicalProtocolDir VARCHAR(254), + HstryUserName VARCHAR(32) not null, + HstryTimeStamp TIMESTAMP, + HstryDateTime TIMESTAMP, + HstryTaskName VARCHAR(32), + TransactionId VARCHAR(255), + CONSTRAINT pk_Course primary key(CourseSer) +); + +CREATE TABLE MachineUse( + -- ~ Triagem DATE, + -- ~ Consulta DATE, + -- ~ Simulador DATE, + -- ~ Tratamento DATE, + -- ~ Tri_Cons int, -- DIAS + -- ~ Cons_Simulador int, -- DIAS + -- ~ Simulador_Trat int, -- DIAS + -- ~ CID VARCHAR(4), + Pacient_id VARCHAR(254), + Pacient_name VARCHAR(254), + Energy VARCHAR(254), + Use_date TIMESTAMP, + Field_name VARCHAR(254), + Machine_id VARCHAR(254), + Fk_Agent int +); + +CREATE TABLE Agent ( + Id BIGSERIAL primary key, + Hospital VARCHAR(16), + Geo_long FLOAT, + Geo_lat FLOAT ); ALTER TABLE session ADD CONSTRAINT fk_session_1 FOREIGN KEY(CourseSer) REFERENCES Course(CourseSer); ALTER TABLE SessionProcedurePart ADD CONSTRAINT fk_SessionProcedurePart_2 FOREIGN KEY(SessionProcedurePartSer) REFERENCES session(sessionSer); ALTER TABLE SessionProcedurePart ADD CONSTRAINT unique_SessionProcedurePart UNIQUE(SessionProcedurePartSer); +ALTER TABLE MachineUse ADD CONSTRAINT Fk_Agent FOREIGN KEY(Fk_Agent) REFERENCES Agent(Id); + COMMIT; diff --git a/src/db/query_builder.js b/src/db/query_builder.js index 7ebc445..c997202 100644 --- a/src/db/query_builder.js +++ b/src/db/query_builder.js @@ -13,5 +13,10 @@ module.exports = { var q = squel.insert().into(table); this.set_from_attr(q, obj); return q; + }, + + select: function(table, conditions){ + var q = squel.select().from(table); + return q; } }; diff --git a/src/middleware/db.js b/src/middleware/db.js index 55b72f6..308c4db 100644 --- a/src/middleware/db.js +++ b/src/middleware/db.js @@ -69,6 +69,8 @@ exports.pool = function (config) { req.db = { connect: function (callback) { pg.on('error', function(err) { + pg.end(); + throw(err); return; }); pg.connect(config, function (err, client, done) { @@ -80,9 +82,11 @@ exports.pool = function (config) { namedPatch(client); callback(null, new Connection(client), done); }); + + pg.end(); } }; - + next(); }; }; diff --git a/src/middleware/populate.js b/src/middleware/populate.js new file mode 100644 index 0000000..e8d7403 --- /dev/null +++ b/src/middleware/populate.js @@ -0,0 +1,222 @@ +var _ = require('lodash'); +var pg = require('pg'), + copyFrom = require('pg-copy-streams').from, + fs = require('fs'); + +var async = require('async'); + +var XLSX = require('xlsx'); + + +function namedPatch(client) { + + + var originalQuery = client.query; + + if (originalQuery.patched) return client; + + originalQuery = originalQuery.bind(client); + + var patchedQuery = function(config, values, callback) { + if (arguments.length === 1) { + return originalQuery(config); + } + else if (arguments.length === 2 && _.isFunction(values)) { + return originalQuery(config, values); + } + else if (_.isArray(values)) { + return originalQuery(config, values, callback); + } else { + var reparameterized = numericFromNamed(config, values); + return originalQuery(reparameterized.sql, reparameterized.values, callback); + } + }; + + client.query = patchedQuery; + client.query.patched = true; + + return client; +} + + +function Connection(client) { + this.query = function (query, params, callback) { + return client.query(query, params, callback); + }; + + this.execute = function (query, params) { + var $this = this; + + return function (callback) { + $this.query(query, params, function (err) { + callback(err); + }); + }; + }; + + this.transaction = function (callback) { + client.query('BEGIN;', function (err) { + callback(err); + }); + }; + + this.commit = function (callback) { + client.query('COMMIT;', function (err) { + callback(err); + }); + }; + + this.rollback = function (callback) { + client.query('ROLLBACK;', function (err) { + callback(err); + }); + }; + +} + +var sheet2arr = function(sheet){ + var i = 5; + var rows = []; + while(true){ + + if(!sheet["A"+(i+1)] && !sheet["A"+i]){ + return rows; + } + if(sheet["A"+(i+1)] && !sheet["A"+i]){ + i+=1; + } + + if(sheet["A"+i]["v"] == "ID do paciente"){ + + var paciente_id = sheet["D"+i]["w"]; + var paciente_nome = sheet["L"+i]["w"]; + + + if(!sheet["A"+(i+1)]){ + i+=1; + } + + i+=4; + } + + + if(sheet["G"+i]){ + var field_name = sheet["J"+i] ? sheet["J"+i]["w"] : ""; + var use_date = sheet["B"+i]["w"].split(" "); + use_date = new Date( + use_date[0].split("/")[2], + parseInt(use_date[0].split("/")[1])-1, + use_date[0].split("/")[0], + use_date[1].split(":")[0], + use_date[1].split(":")[1] + ); + rows.push({ + Pacient_id: paciente_id, + Pacient_name: paciente_nome, + Energy: sheet["G"+i]["w"], + Use_date: use_date.toISOString(), + Field_name: field_name, + Machine_id: sheet["M"+i]["w"], + Fk_agent: 1, + }); + } + i+=1; + + } + +}; + +function waterfall_queries(queries, config, cb_w){ + var temp_db = { + connect: function (callback) { + pg.on('error', function(err) { + throw(err); + cb_w(); + return; + }); + pg.connect(config, function (err, client, done) { + if (err) { + setTimeout(temp_db.connect, 5000, callback); + cb_w(); + throw(err); + return; + } + + namedPatch(client); + callback(null, new Connection(client), done); + }); + + pg.end(); + } + }; + + temp_db.connect(function(err, conn, done) { + if (err) { + throw(err); + cb_w(); + return; + } + + async.waterfall([ + conn.transaction, + function(callback) { + async.everySeries(queries, function(q, cb){ + conn.query(q.toParam().text, q.toParam().values, cb); + }, function(err, result){ + callback(err); + }); + }, + conn.commit + ], function (err, result) { + if(err) { + throw(err); + conn.rollback(done); + cb_w(); + return; + } + done(); + cb_w(); + }); + }); +} + + +exports.populateAgent = function(file, config, callback = function(){}){ + var workbook = XLSX.readFile(file); + var sheet_name_list = workbook.SheetNames; + var sheetName = Object.keys(workbook.Sheets)[0]; + var s = workbook.Sheets[sheetName]; + + var consultas = sheet2arr(s); + + var queries = []; + + var q = qb.insert("agent",{ + Hospital: "Erasto Gaertner", + Geo_lat: -25.4696528, + Geo_long: -49.261403 + }); + + queries.push(q); + waterfall_queries(queries, config, callback); + +} + +exports.populeMachineuse = function (file,config, callback = function(){}){ + var workbook = XLSX.readFile(file); + var sheet_name_list = workbook.SheetNames; + var sheetName = Object.keys(workbook.Sheets)[0]; + var s = workbook.Sheets[sheetName]; + + var consultas = sheet2arr(s); + + var queries = []; + + for(var x in consultas){ + var q = qb.insert("machineuse",consultas[x]); + queries.push(q); + } + + waterfall_queries(queries, config, callback); +} + diff --git a/src/routes/data.js b/src/routes/data.js new file mode 100644 index 0000000..0ced3c0 --- /dev/null +++ b/src/routes/data.js @@ -0,0 +1,53 @@ +/* +* Copyright (C) 2012-2017 Centro de Computacao Cientifica e Software Livre +* Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR +* +* This file is part of simmc +* +* simmc is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +* USA. +*/ + +var async = require('async'); + +module.exports = function(agentVersion) { + qb = require("../db/query_builder.js"); + + return { + listTable : function (req, res, table) { + + req.db.connect(function(err, conn, done) { + if (err) { + req.log.error(err); + res.status(500).json({error: 'db_connection_failed'}); + return; + } + + var q = qb.select(table,{}); + + conn.query(q.toParam().text,q.toParam().values, function(err,data,fields){ + if (err) throw err; + res.setHeader('Access-Control-Allow-Origin', 'file:///home/bhm15/c3sl/webservice/src/static/exemplo.html'); + res.header("Access-Control-Allow-Origin", "*"); + res.header("Access-Control-Allow-Headers", "X-Requested-With"); + + return res.status(200).json(data.rows); + }); + + }); + + } + }; +}; diff --git a/src/server.js b/src/server.js index ddcf6ec..3664857 100644 --- a/src/server.js +++ b/src/server.js @@ -25,7 +25,9 @@ // Libraries // /*jshint esversion: 6*/ + var os = require('os'); +var ip = require("ip"); var fs = require('fs'); var cluster = require('cluster'); var bodyParser = require('body-parser'); @@ -58,7 +60,6 @@ if (argv.help || argv.h) { const app_mode = (process.env.NODE_ENV || 'development').trim().toLowerCase(); - var configFile; //test config @@ -95,6 +96,7 @@ var numWorkers = parseInt(argv['num-workers'] || argv.n) || (os.cpus().length * var daemon = argv.daemon || argv.d || false; var pidfile = argv['pid-file'] || config.pid_file || process.env.PID_FILE || path.resolve('.', 'pinsis.pid'); + if (app_mode === 'development' || app_mode === 'test') { secureCookies = false; @@ -125,6 +127,7 @@ var db = require('./middleware/db.js'); var ping = require('./routes/ping.js'); var agent = require('./routes/agent.js')(config.agentVersion); +var data = require('./routes/data.js')(config.agentVersion); //Data validation var ct_validator = require('./validation/course_treatment.js'); @@ -150,8 +153,10 @@ app.use(function (req, res, next) { next(); }); +app.engine('html', require('ejs').renderFile); +app.set('view engine', 'html'); - +var populate = require("./middleware/populate.js"); // @@ -167,6 +172,24 @@ app.get('/api/agent/version', agent.version); +app.get('/api/data/listAgents', function(req, res) { + data.listTable(req,res,"agent"); +}); + +app.get('/api/data/listMachineUses', function(req, res) { + data.listTable(req,res,"machineuse"); +}); + +app.get('/pinsis.js', function(req, res) { + res.render(path.join(__dirname + '/static/pinsis.ejs'),{ip:ip.address()}); +}); + +app.get('/exemplo.html', function(req, res) { + res.render(path.join(__dirname + '/static/exemplo.html'),{ip:ip.address()}); +}); + + + var exit = function exit() { log.info('Server exiting...'); @@ -177,6 +200,7 @@ var exit = function exit() { // Fork process // if (cluster.isMaster) { + // daemonize the process (useful for init.d scripts and similar) if (argv.daemon) { require('daemon')(); diff --git a/src/static/exemplo.html b/src/static/exemplo.html new file mode 100644 index 0000000..279e296 --- /dev/null +++ b/src/static/exemplo.html @@ -0,0 +1,159 @@ +<html> + <header> + <meta charset="utf-8"> + + <style> + .SEPARADOR{ + margin-top:20px; + margin-bottom:20px; + width:100%; + outline-width:1px; + outline-style:solid; + outline-color:rgba(0,0,0,0.3); + text-align:center; + background-color:rgba(0,0,0,0.3); + } + </style> + + + <script src="http://<%= ip %>:3000/pinsis.js"></script> + <script src="https://cdn.plot.ly/plotly-latest.min.js"></script> + <script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore.js"></script> + <script src="https://momentjs.com/downloads/moment.js"></script> + <script> + + function plot_uses_by(uses,groupby, divname){ + var dates = uses.map(function(x){ + return x["use_date"]; + }); + + var occurrenceDay = function(occurrence){ + return moment(occurrence).startOf(groupby).format(); + }; + + var groupToDay = function(group, day){ + return { + day: day, + times: group + } + }; + + var result = _.chain(dates) + .groupBy(occurrenceDay) + .map(groupToDay) + .sortBy('day') + .value(); + + + var plot1_data_x = []; + var plot1_data_y = []; + + var plot2_data_x = []; + var plot2_data_y = []; + + + for(x in result){ + if(Math.round(Math.random()) == 1){ + plot1_data_x.push(result[x].day); + plot1_data_y.push(result[x].times.length); + } + else{ + plot2_data_x.push(result[x].day); + plot2_data_y.push(result[x].times.length); + } + } + + var plot_data = [ + { + x: plot1_data_x, + y: plot1_data_y, + type: 'scatter', + name: 'Outros' + }, + { + x: plot2_data_x, + y: plot2_data_y, + type: 'scatter', + name: 'SUS' + } + ]; + + Plotly.newPlot(divname, plot_data); + + + var data = [{ + values: [plot1_data_x.length,plot2_data_x.length], + labels: ['Outros', 'SUS'], + type: 'pie' + }]; + + var layout = { + height: 400, + width: 500 + }; + + Plotly.newPlot(divname+"_pizza", data, layout); + + } + + function plot(groupby){ + Pinsis.lastUses(function(err, data){ + console.log(err); + //~ console.log(data); + plot_uses_by(data,groupby,"myDiv"); + + data_m = data.filter(function(x){ + return x["machine_id"].indexOf("CX") !== -1 + }); + + data_h = data.filter(function(x){ + return x["machine_id"].indexOf("CX") === -1 + }); + + + plot_uses_by(data_m, groupby,"myDiv2"); + plot_uses_by(data_h, groupby,"myDiv3"); + }); + } + + Pinsis.agents(function(err, data){ + console.log(err); + }); + + plot("day"); + </script> + </header> + <body> + <center> + <button onClick="plot('years')" > ANOS </button> + <button onClick="plot('months')" > MESES </button> + <button onClick="plot('days')" > DIAS </button> + <button onClick="plot('hours')" > HORAS </button> + <button onClick="plot('minutes')" > MINUTOS </button> + </center> + + <center><h1>Todas as máquinas</h1> + <div id="myDiv"></div> + <div id="myDiv_pizza"></div> + <div class="SEPARADOR"></div> + </center> + + <br><br> + + <center><h1>Máquinas do Ministério</h1> + <div id="myDiv2"></div> + <div id="myDiv2_pizza"></div> + <div class="SEPARADOR"></div> + </center> + + <br><br> + + <center><h1>Máquinas do Hospital</h1> + <div id="myDiv3"></div> + <div id="myDiv3_pizza"></div> + <div class="SEPARADOR"></div> + </center> + </body> + + +</html> diff --git a/src/static/pinsis.ejs b/src/static/pinsis.ejs new file mode 100644 index 0000000..23974fb --- /dev/null +++ b/src/static/pinsis.ejs @@ -0,0 +1,35 @@ +var Pinsis = { + + getJson: function(callback, url){ + var xmlhttp = new XMLHttpRequest(); + + xmlhttp.onreadystatechange = function() { + if (this.readyState == 4 && this.status == 200) { + var myArr = JSON.parse(this.responseText); + callback(null, myArr); + } + + if (this.readyState == 4 && this.status != 200) { + callback({status: this.status}, null) + } + }; + xmlhttp.open("GET", url, true); + xmlhttp.send(); + }, + + lastUses: function(callback){ + this.getJson( + callback, + "http://<%= ip %>:3000/api/data/listMachineUses" + ); + }, + + agents: function(callback){ + this.getJson( + callback, + "http://<%= ip %>:3000/api/data/listAgents" + ); + }, + + +} -- GitLab From be4945c8d5fc09db9c3d5a94ff8afdd64ce53471 Mon Sep 17 00:00:00 2001 From: bhm15 <bruno.meyer@ufpr.br> Date: Thu, 22 Feb 2018 11:51:10 -0300 Subject: [PATCH 29/30] ISSUE#9: Data access optimization --- config.js.example | 4 + config_test.js.example | 5 ++ config_test_error.js | 4 + database/create/schema/bd.sql | 24 +++--- src/db/query_builder.js | 7 +- src/middleware/db.js | 12 +-- src/middleware/populate.js | 34 ++++++--- src/routes/data.js | 20 +++-- src/server.js | 16 ++-- src/static/exemplo.html | 140 ++++++++++++++-------------------- src/static/pinsis.ejs | 18 ++++- 11 files changed, 158 insertions(+), 126 deletions(-) diff --git a/config.js.example b/config.js.example index ae636fc..1846bae 100644 --- a/config.js.example +++ b/config.js.example @@ -8,4 +8,8 @@ config.db_config = { port: 5432 }; +config.webservice_config = { + ip: "127.0.0.1" +} + config.agentVersion = 0.0; diff --git a/config_test.js.example b/config_test.js.example index bc4bb7e..3a80276 100644 --- a/config_test.js.example +++ b/config_test.js.example @@ -7,4 +7,9 @@ config.db_config = { host: 'localhost', port: 5432 }; + +config.webservice_config = { + ip: "127.0.0.1" +} + config.agentVersion = 0.0; diff --git a/config_test_error.js b/config_test_error.js index 5a00d0e..7e9c26e 100644 --- a/config_test_error.js +++ b/config_test_error.js @@ -8,5 +8,9 @@ config.db_config = { port: 5432 }; +config.webservice_config = { + ip: "127.0.0.1" +} + config.agentVersion = 0.0; diff --git a/database/create/schema/bd.sql b/database/create/schema/bd.sql index 4dcdcd1..f3cfd94 100755 --- a/database/create/schema/bd.sql +++ b/database/create/schema/bd.sql @@ -63,30 +63,34 @@ CREATE TABLE Course( ); CREATE TABLE MachineUse( - -- ~ Triagem DATE, - -- ~ Consulta DATE, - -- ~ Simulador DATE, - -- ~ Tratamento DATE, - -- ~ Tri_Cons int, -- DIAS - -- ~ Cons_Simulador int, -- DIAS - -- ~ Simulador_Trat int, -- DIAS - -- ~ CID VARCHAR(4), Pacient_id VARCHAR(254), Pacient_name VARCHAR(254), Energy VARCHAR(254), Use_date TIMESTAMP, Field_name VARCHAR(254), Machine_id VARCHAR(254), - Fk_Agent int + Fk_agent int ); CREATE TABLE Agent ( Id BIGSERIAL primary key, - Hospital VARCHAR(16), + Hospital_name VARCHAR(16), Geo_long FLOAT, Geo_lat FLOAT ); + +CREATE MATERIALIZED VIEW ResumeUsesMonth AS + SELECT date_trunc('month', use_date) AS date, count(*) as uses, fk_agent + FROM machineuse + GROUP BY date, fk_agent; + +CREATE MATERIALIZED VIEW ResumeUsesDay AS + SELECT date_trunc('day', use_date) AS date, count(*) as uses, fk_agent + FROM machineuse + GROUP BY date, fk_agent; + + ALTER TABLE session ADD CONSTRAINT fk_session_1 FOREIGN KEY(CourseSer) REFERENCES Course(CourseSer); ALTER TABLE SessionProcedurePart ADD CONSTRAINT fk_SessionProcedurePart_2 FOREIGN KEY(SessionProcedurePartSer) REFERENCES session(sessionSer); ALTER TABLE SessionProcedurePart ADD CONSTRAINT unique_SessionProcedurePart UNIQUE(SessionProcedurePartSer); diff --git a/src/db/query_builder.js b/src/db/query_builder.js index c997202..57a5697 100644 --- a/src/db/query_builder.js +++ b/src/db/query_builder.js @@ -16,7 +16,10 @@ module.exports = { }, select: function(table, conditions){ - var q = squel.select().from(table); - return q; + var q = squel.select().from(table); + for(c in conditions){ + q = q.where(c+" = "+"'"+conditions[c]+"'"); + } + return q; } }; diff --git a/src/middleware/db.js b/src/middleware/db.js index 308c4db..c506f7b 100644 --- a/src/middleware/db.js +++ b/src/middleware/db.js @@ -66,16 +66,16 @@ function namedPatch(client) { exports.pool = function (config) { return function (req, res, next) { + var pool = new pg.Pool(config); req.db = { connect: function (callback) { - pg.on('error', function(err) { - pg.end(); - throw(err); + pool.on('error', function(err) { + pool.end(); return; }); - pg.connect(config, function (err, client, done) { + pool.connect(function (err, client, done) { if (err) { - setTimeout(req.db.connect, 5000, callback); + callback(err, null, done); return; } @@ -83,7 +83,7 @@ exports.pool = function (config) { callback(null, new Connection(client), done); }); - pg.end(); + pool.end(); } }; diff --git a/src/middleware/populate.js b/src/middleware/populate.js index e8d7403..44f23f6 100644 --- a/src/middleware/populate.js +++ b/src/middleware/populate.js @@ -8,9 +8,7 @@ var async = require('async'); var XLSX = require('xlsx'); -function namedPatch(client) { - - +function namedPatch(client) { var originalQuery = client.query; if (originalQuery.patched) return client; @@ -127,18 +125,17 @@ var sheet2arr = function(sheet){ }; function waterfall_queries(queries, config, cb_w){ + var pool = new pg.Pool(config); var temp_db = { connect: function (callback) { - pg.on('error', function(err) { + pool.on('error', function(err) { throw(err); cb_w(); - return; }); - pg.connect(config, function (err, client, done) { + pool.connect(function (err, client, done) { if (err) { setTimeout(temp_db.connect, 5000, callback); - cb_w(); - throw(err); + done(); return; } @@ -146,15 +143,13 @@ function waterfall_queries(queries, config, cb_w){ callback(null, new Connection(client), done); }); - pg.end(); + pool.end(); } }; temp_db.connect(function(err, conn, done) { if (err) { throw(err); - cb_w(); - return; } async.waterfall([ @@ -191,8 +186,9 @@ exports.populateAgent = function(file, config, callback = function(){}){ var queries = []; + //TODO: Create a config file that will be used to populate this table var q = qb.insert("agent",{ - Hospital: "Erasto Gaertner", + Hospital_name: "Erasto Gaertner", Geo_lat: -25.4696528, Geo_long: -49.261403 }); @@ -217,6 +213,20 @@ exports.populeMachineuse = function (file,config, callback = function(){}){ queries.push(q); } + var refresh_views_query = { + toParam: function refresh_views(){ + return { + values: [], + text: + "REFRESH materialized view ResumeUsesMonth;"+ + "REFRESH materialized view ResumeUsesDay;" + } + } + } + + queries.push(refresh_views_query); waterfall_queries(queries, config, callback); + + } diff --git a/src/routes/data.js b/src/routes/data.js index 0ced3c0..f405333 100644 --- a/src/routes/data.js +++ b/src/routes/data.js @@ -27,22 +27,32 @@ module.exports = function(agentVersion) { return { listTable : function (req, res, table) { - req.db.connect(function(err, conn, done) { + if (err) { req.log.error(err); res.status(500).json({error: 'db_connection_failed'}); + done(); return; } + + var parameters = {}; + + switch(table){ + case 'ResumeUsesMonth': + case 'ResumeUsesDay': + if(req.query['hospital_id']) parameters["fk_agent"] = parseInt(req.query['hospital_id']); + break; + } - var q = qb.select(table,{}); + var q = qb.select(table,parameters); + conn.query(q.toParam().text,q.toParam().values, function(err,data,fields){ - if (err) throw err; - res.setHeader('Access-Control-Allow-Origin', 'file:///home/bhm15/c3sl/webservice/src/static/exemplo.html'); + if (err) req.log.error(err); res.header("Access-Control-Allow-Origin", "*"); res.header("Access-Control-Allow-Headers", "X-Requested-With"); - + done(); return res.status(200).json(data.rows); }); diff --git a/src/server.js b/src/server.js index 3664857..c236018 100644 --- a/src/server.js +++ b/src/server.js @@ -27,7 +27,6 @@ /*jshint esversion: 6*/ var os = require('os'); -var ip = require("ip"); var fs = require('fs'); var cluster = require('cluster'); var bodyParser = require('body-parser'); @@ -176,16 +175,21 @@ app.get('/api/data/listAgents', function(req, res) { data.listTable(req,res,"agent"); }); -app.get('/api/data/listMachineUses', function(req, res) { - data.listTable(req,res,"machineuse"); +app.get('/api/data/ResumeUsesDay', function(req, res) { + data.listTable(req,res,"ResumeUsesDay"); }); +app.get('/api/data/ResumeUsesMonth', function(req, res) { + data.listTable(req,res,"ResumeUsesMonth"); +}); + + app.get('/pinsis.js', function(req, res) { - res.render(path.join(__dirname + '/static/pinsis.ejs'),{ip:ip.address()}); + res.render(path.join(__dirname + '/static/pinsis.ejs'),{ip:config.webservice_config.ip}); }); app.get('/exemplo.html', function(req, res) { - res.render(path.join(__dirname + '/static/exemplo.html'),{ip:ip.address()}); + res.render(path.join(__dirname + '/static/exemplo.html'),{ip:config.webservice_config.ip}); }); @@ -200,6 +204,8 @@ var exit = function exit() { // Fork process // if (cluster.isMaster) { + //Here is where should be populated the tables + // daemonize the process (useful for init.d scripts and similar) if (argv.daemon) { diff --git a/src/static/exemplo.html b/src/static/exemplo.html index 279e296..7c78735 100644 --- a/src/static/exemplo.html +++ b/src/static/exemplo.html @@ -18,73 +18,57 @@ <script src="http://<%= ip %>:3000/pinsis.js"></script> <script src="https://cdn.plot.ly/plotly-latest.min.js"></script> - <script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore.js"></script> - <script src="https://momentjs.com/downloads/moment.js"></script> <script> + + function get_attribute_list(object_list, key){ + return object_list.map(function(x){return x[key];}); + } function plot_uses_by(uses,groupby, divname){ - var dates = uses.map(function(x){ - return x["use_date"]; - }); - - var occurrenceDay = function(occurrence){ - return moment(occurrence).startOf(groupby).format(); - }; - - var groupToDay = function(group, day){ - return { - day: day, - times: group - } - }; - - var result = _.chain(dates) - .groupBy(occurrenceDay) - .map(groupToDay) - .sortBy('day') - .value(); - + var plot1_data_x = get_attribute_list(uses,"date"); + var plot2_data_x = plot1_data_x; - var plot1_data_x = []; - var plot1_data_y = []; - var plot2_data_x = []; + var plot1_data_y = get_attribute_list(uses,"uses"); var plot2_data_y = []; - for(x in result){ - if(Math.round(Math.random()) == 1){ - plot1_data_x.push(result[x].day); - plot1_data_y.push(result[x].times.length); - } - else{ - plot2_data_x.push(result[x].day); - plot2_data_y.push(result[x].times.length); - } + for(i in plot1_data_x){ + plot2_data_y[i] = plot1_data_y[i] - parseInt(plot1_data_y[i]*Math.random()); + plot1_data_y[i] -= plot2_data_y[i]; } + + var susColor = 'green'; + var othersColor = 'blue'; + var plot_data = [ { x: plot1_data_x, y: plot1_data_y, - type: 'scatter', - name: 'Outros' + type: 'bar', + name: 'Outros', + marker: {color: othersColor}, }, { x: plot2_data_x, y: plot2_data_y, - type: 'scatter', - name: 'SUS' + type: 'bar', + name: 'SUS', + marker: {color: susColor}, } ]; - Plotly.newPlot(divname, plot_data); + Plotly.newPlot(divname, plot_data, {barmode: 'group'}); + var sum = function(x,y){return x+y;} + var data = [{ - values: [plot1_data_x.length,plot2_data_x.length], - labels: ['Outros', 'SUS'], - type: 'pie' + values: [plot2_data_y.reduce(sum),plot1_data_y.reduce(sum)], + labels: ['SUS', 'Outros'], + type: 'pie', + marker:{colors:[susColor, othersColor]}, }]; var layout = { @@ -96,43 +80,46 @@ } - function plot(groupby){ - Pinsis.lastUses(function(err, data){ - console.log(err); - //~ console.log(data); - plot_uses_by(data,groupby,"myDiv"); - - data_m = data.filter(function(x){ - return x["machine_id"].indexOf("CX") !== -1 - }); - - data_h = data.filter(function(x){ - return x["machine_id"].indexOf("CX") === -1 - }); - - - plot_uses_by(data_m, groupby,"myDiv2"); - plot_uses_by(data_h, groupby,"myDiv3"); - }); + var hospitals; + + function plot(groupby, hospital){ + switch(groupby){ + case "days": + Pinsis.lastUsesByDay(function(err, data){ + if(err) console.log(err); + plot_uses_by(data,groupby,"myDiv"); + }, hospital.id); + break; + case "months": + Pinsis.lastUsesByMonth(function(err, data){ + if(err) console.log(err); + plot_uses_by(data,groupby,"myDiv"); + },hospital.id); + break; + } + + document.getElementById("hospital_name").innerHTML = hospital.hospital_name; } - Pinsis.agents(function(err, data){ - console.log(err); + + Pinsis.hospitals(function(err, data){ + if(err) console.log(err); + hospitals = data; + console.log(data); + plot("days",hospitals[0]); }); - plot("day"); + </script> </header> <body> <center> - <button onClick="plot('years')" > ANOS </button> - <button onClick="plot('months')" > MESES </button> - <button onClick="plot('days')" > DIAS </button> - <button onClick="plot('hours')" > HORAS </button> - <button onClick="plot('minutes')" > MINUTOS </button> + <button onClick="plot('months', hospitals[0])" > MESES </button> + <button onClick="plot('days', hospitals[0])" > DIAS </button> </center> - <center><h1>Todas as máquinas</h1> + <center><h1>Monitoramento: <span id="hospital_name"></span></h1> + <div class="SEPARADOR"></div> <div id="myDiv"></div> <div id="myDiv_pizza"></div> <div class="SEPARADOR"></div> @@ -140,19 +127,6 @@ <br><br> - <center><h1>Máquinas do Ministério</h1> - <div id="myDiv2"></div> - <div id="myDiv2_pizza"></div> - <div class="SEPARADOR"></div> - </center> - - <br><br> - - <center><h1>Máquinas do Hospital</h1> - <div id="myDiv3"></div> - <div id="myDiv3_pizza"></div> - <div class="SEPARADOR"></div> - </center> </body> diff --git a/src/static/pinsis.ejs b/src/static/pinsis.ejs index 23974fb..724d23f 100644 --- a/src/static/pinsis.ejs +++ b/src/static/pinsis.ejs @@ -17,14 +17,26 @@ var Pinsis = { xmlhttp.send(); }, - lastUses: function(callback){ + lastUsesByDay: function(callback, hospital_id){ + var url = "http://<%= ip %>:3000/api/data/ResumeUsesDay"; + if(hospital_id) url+="?hospital_id="+hospital_id; this.getJson( callback, - "http://<%= ip %>:3000/api/data/listMachineUses" + url ); }, - agents: function(callback){ + lastUsesByMonth: function(callback, hospital_id){ + var url = "http://<%= ip %>:3000/api/data/ResumeUsesMonth"; + if(hospital_id) url+="?hospital_id="+hospital_id; + this.getJson( + callback, + url + ); + + }, + + hospitals: function(callback){ this.getJson( callback, "http://<%= ip %>:3000/api/data/listAgents" -- GitLab From acc0123175b90e6ab31d72e8f37e948914d2022f Mon Sep 17 00:00:00 2001 From: bhm15 <bruno.meyer@ufpr.br> Date: Fri, 23 Feb 2018 10:14:41 -0300 Subject: [PATCH 30/30] ISSUE#9: Update package.json --- package.json | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 4e52e6f..4821f8d 100644 --- a/package.json +++ b/package.json @@ -13,16 +13,18 @@ "start": "node src/server.js" }, "dependencies": { - "express": "^4.13.3", "async": "^2.1.2", "body-parser": "^1.14.1", + "bunyan": "^1.0.1", + "collect-webservice": "git+https://gitlab.c3sl.ufpr.br/c3sl/collect-webservice.git", + "cuid": "^1.2.4", + "ejs": "^2.5.7", + "express": "^4.13.3", + "minimist": "1.2.0", "pg": "^6.1.0", "pg-copy-streams": "^1.2.0", - "minimist": "1.2.0", - "cuid": "^1.2.4", - "bunyan": "^1.0.1", "squel": "^5.10.0", - "collect-webservice": "git+https://gitlab.c3sl.ufpr.br/c3sl/collect-webservice.git" + "xlsx": "^0.12.2" }, "devDependencies": { "chai": "^4.1.0", -- GitLab