@bluedot-innovation/models 5.1.39 → 5.1.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/Models.js +10 -5
- package/__tests__/cumulativeRulesRequests/checkDailyStats.js +31 -0
- package/__tests__/{ruleRequestAggregation/ruleRequestAggregation.data.json → dailyStats/dailyStats.data.json} +2 -2
- package/__tests__/dailyStats/dailyStats.spec.js +78 -0
- package/__tests__/monthlyStats/monthlyStats.data.json +18 -13
- package/__tests__/monthlyStats/monthlyStats.spec.js +16 -14
- package/__tests__/project/project.remote.config.json +2 -1
- package/models/CumulativeRulesRequests.js +37 -0
- package/models/DailyStats.js +15 -12
- package/models/MonthlyStats.js +5 -4
- package/models/TestScenario.js +4 -1
- package/package.json +1 -1
- package/schemas/IosConfig.js +7 -1
- package/__tests__/dailyStats/checkDailyStats.js +0 -31
- package/__tests__/ruleRequestAggregation/ruleRequestAggregation.spec.js +0 -78
- package/models/RuleRequestAggregation.js +0 -40
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
## 5.1.42
|
|
2
|
+
- Added accountId, projectId, zoneName and zoneId to TestScenario
|
|
3
|
+
|
|
4
|
+
## 5.1.41
|
|
5
|
+
- Added `disableBackgroundLocation` to IosConfig schema
|
|
6
|
+
|
|
7
|
+
## 5.1.40
|
|
8
|
+
- Rename and updated the `DailyStats`, `MonthlyStats` and `RuleRequestAggregation` models to:
|
|
9
|
+
- `RulesRequestAgregation` to `Daily Stats`
|
|
10
|
+
- `DailyStats` to `CumulativeRulesRequests`
|
|
11
|
+
|
|
1
12
|
## 5.1.39
|
|
2
13
|
- Changed MRT to HHH:MM (999:59) to match with V1
|
|
3
14
|
|
package/Models.js
CHANGED
|
@@ -8,9 +8,7 @@ Models.Account = require('./models/Account').Model
|
|
|
8
8
|
Models.Beacon = require('./models/Beacon').Model
|
|
9
9
|
|
|
10
10
|
Models.MessageAction = require('./models/MessageAction').Model
|
|
11
|
-
Models.MonthlyStats = require('./models/MonthlyStats').Model
|
|
12
11
|
Models.Project = require('./models/Project').Model
|
|
13
|
-
Models.RuleRequestAggregation = require('./models/RuleRequestAggregation').Model
|
|
14
12
|
Models.UrlAction = require('./models/UrlAction').Model
|
|
15
13
|
Models.User = require('./models/User').Model
|
|
16
14
|
Models.Zone = require('./models/Zone').Model
|
|
@@ -42,21 +40,28 @@ Models.NotificationLogEntry = require('./models/NotificationLogEntry').Model
|
|
|
42
40
|
Models.DBEvent = require('./models/DBEvent').Model
|
|
43
41
|
Models.SingleUseToken = require('./models/SingleUseToken').Model
|
|
44
42
|
Models.Contract = require('./models/Contract').Model
|
|
45
|
-
Models.DailyStats = require('./models/DailyStats').Model
|
|
46
43
|
Models.ConfigurationParameters = require('./models/ConfigurationParameters').Model
|
|
47
44
|
|
|
45
|
+
// Stats Aggregator
|
|
46
|
+
Models.CumulativeRulesRequests = require('./models/CumulativeRulesRequests').Model
|
|
47
|
+
Models.MonthlyStats = require('./models/MonthlyStats').Model
|
|
48
|
+
Models.DailyStats = require('./models/DailyStats').Model
|
|
49
|
+
|
|
48
50
|
let Schemas = {}
|
|
49
51
|
|
|
50
52
|
Schemas.Account = require('./models/Account').Schema
|
|
51
53
|
Schemas.Beacon = require('./models/Beacon').Schema
|
|
52
54
|
Schemas.MessageAction = require('./models/MessageAction').Schema
|
|
53
|
-
Schemas.MonthlyStats = require('./models/MonthlyStats').Schema
|
|
54
55
|
Schemas.Project = require('./models/Project').Schema
|
|
55
|
-
Schemas.RuleRequestAggregation = require('./models/RuleRequestAggregation').Schema
|
|
56
56
|
Schemas.UrlAction = require('./models/UrlAction').Schema
|
|
57
57
|
Schemas.User = require('./models/User').Schema
|
|
58
58
|
Schemas.Zone = require('./models/Zone').Schema
|
|
59
59
|
|
|
60
|
+
// Stats Aggregator Schemas
|
|
61
|
+
Schemas.DailyStats = require('./models/DailyStats').Schema
|
|
62
|
+
Schemas.MonthlyStats = require('./models/MonthlyStats').Schema
|
|
63
|
+
Schemas.CumulativeRulesRequests = require('./models/ConfigurationParameters').Schema
|
|
64
|
+
|
|
60
65
|
// Geofeatures
|
|
61
66
|
Schemas.BoundingBox = require('./models/geofeatures/BoundingBox').Schema
|
|
62
67
|
Schemas.Circle = require('./models/geofeatures/Circle').Schema
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const assert = require('chai').assert
|
|
2
|
+
const CumulativeRulesRequests = require('../../models/CumulativeRulesRequests')
|
|
3
|
+
let testCase = require('mocha').describe
|
|
4
|
+
let assertions = require('mocha').it
|
|
5
|
+
|
|
6
|
+
const cumulativeRulesRequest = {
|
|
7
|
+
totalEndUsers: 4626,
|
|
8
|
+
totalIos: 2196,
|
|
9
|
+
totalAndroid: 2430
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
testCase('Creating new cumulativeRulesRequest document ', () => {
|
|
13
|
+
assertions('validates data types and structure of cumulativeRulesRequest document', (done) => {
|
|
14
|
+
const createCumulativeRulesRequests = new CumulativeRulesRequests(cumulativeRulesRequest)
|
|
15
|
+
assert(createCumulativeRulesRequests._id)
|
|
16
|
+
assert(createCumulativeRulesRequests._id.match(/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/))
|
|
17
|
+
createCumulativeRulesRequests.validate()
|
|
18
|
+
.then(() => {
|
|
19
|
+
console.log('validate CumulativeRulesRequests')
|
|
20
|
+
assert(true)
|
|
21
|
+
done()
|
|
22
|
+
}).catch(err => {
|
|
23
|
+
console.log('Errors found:')
|
|
24
|
+
for (let key of Object.keys(err.errors)) {
|
|
25
|
+
console.log(err.errors[key].message)
|
|
26
|
+
}
|
|
27
|
+
assert(false)
|
|
28
|
+
done(err)
|
|
29
|
+
})
|
|
30
|
+
})
|
|
31
|
+
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"_id" : "bf93ddd2-e7e9-4a89-9bcb-0b2164c17e45",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
3
|
+
"projectId" : "fd150b63-08dc-4114-aaf9-359cef30def6",
|
|
4
|
+
"accountId" : "f944c7e9-63cc-4c0a-8ad3-acf3c30415fc",
|
|
5
5
|
"iosCount" : 9,
|
|
6
6
|
"androidCount" : 0,
|
|
7
7
|
"creationDate" : "2018-02-22T05:54:21.327+0000"
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
let mongoose = require('mongoose')
|
|
2
|
+
|
|
3
|
+
mongoose.Promise = global.Promise
|
|
4
|
+
|
|
5
|
+
let DailyStatsModel = require('../../Models').DailyStats(mongoose)
|
|
6
|
+
let DailyStatsModelBuiltInMongoose = require('../../Models').DailyStats()
|
|
7
|
+
let testCase = require('mocha').describe
|
|
8
|
+
let assertions = require('mocha').it
|
|
9
|
+
let chai = require('chai')
|
|
10
|
+
|
|
11
|
+
let assert = chai.assert
|
|
12
|
+
let mocha = require('mocha')
|
|
13
|
+
let beforeEach = mocha.beforeEach
|
|
14
|
+
|
|
15
|
+
let dailyStats
|
|
16
|
+
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
dailyStats = JSON.parse(JSON.stringify(require('./dailyStats.data.json')))
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
testCase('DailyStats', () => {
|
|
22
|
+
testCase('Valid DailyStats document', () => {
|
|
23
|
+
assertions('should validate a valid DailyStats document ', (done) => {
|
|
24
|
+
let DailyStats = new DailyStatsModel(dailyStats)
|
|
25
|
+
DailyStats.validate((err, res) => {
|
|
26
|
+
assert.notExists(res)
|
|
27
|
+
assert(err === null, 'err should equals null')
|
|
28
|
+
done()
|
|
29
|
+
})
|
|
30
|
+
})
|
|
31
|
+
assertions('should validate a valid DailyStats document ', (done) => {
|
|
32
|
+
let DailyStats = new DailyStatsModelBuiltInMongoose(dailyStats)
|
|
33
|
+
DailyStats.validate((err, res) => {
|
|
34
|
+
assert.notExists(res)
|
|
35
|
+
assert(err === null, 'err should equals null')
|
|
36
|
+
done()
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
assertions('should not accept a invalid accountId', (done) => {
|
|
40
|
+
dailyStats.accountId = 'invalid-accountId'
|
|
41
|
+
let DailyStats = new DailyStatsModel(dailyStats)
|
|
42
|
+
DailyStats.validate((err, res) => {
|
|
43
|
+
assert.exists(err, 'invalid accountId')
|
|
44
|
+
assert.isObject(err)
|
|
45
|
+
done()
|
|
46
|
+
})
|
|
47
|
+
})
|
|
48
|
+
assertions('should not accept a invalid projectId', (done) => {
|
|
49
|
+
dailyStats.projectId = 'invalid-projectId'
|
|
50
|
+
let DailyStats = new DailyStatsModel(dailyStats)
|
|
51
|
+
DailyStats.validate((err, res) => {
|
|
52
|
+
assert.exists(err, 'invalid projectId')
|
|
53
|
+
assert.isObject(err)
|
|
54
|
+
done()
|
|
55
|
+
})
|
|
56
|
+
})
|
|
57
|
+
assertions('should not accept a negative iosCount value', (done) => {
|
|
58
|
+
const negativeIosCount = -100
|
|
59
|
+
dailyStats.iosCount = negativeIosCount
|
|
60
|
+
let DailyStats = new DailyStatsModel(dailyStats)
|
|
61
|
+
DailyStats.validate((err, res) => {
|
|
62
|
+
assert.exists(err, 'Path `iosCount` (' + negativeIosCount + ') is less than minimum allowed value (0)')
|
|
63
|
+
assert.isObject(err)
|
|
64
|
+
done()
|
|
65
|
+
})
|
|
66
|
+
})
|
|
67
|
+
assertions('should not accept a negative androidCount value', (done) => {
|
|
68
|
+
const negativeAndroidCount = -100
|
|
69
|
+
dailyStats.androidCount = negativeAndroidCount
|
|
70
|
+
let DailyStats = new DailyStatsModel(dailyStats)
|
|
71
|
+
DailyStats.validate((err, res) => {
|
|
72
|
+
assert.exists(err, 'Path `androidCount` (' + negativeAndroidCount + ') is less than minimum allowed value (0)')
|
|
73
|
+
assert.isObject(err)
|
|
74
|
+
done()
|
|
75
|
+
})
|
|
76
|
+
})
|
|
77
|
+
})
|
|
78
|
+
})
|
|
@@ -1,29 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"_id": "709aa8f4-3c53-496d-8824-73cb73ce6963",
|
|
3
3
|
"creationTime": "2017-12-31T23:17:30.658Z",
|
|
4
|
-
"
|
|
5
|
-
"
|
|
4
|
+
"countMonth": "2017-12-31T23:17:30.658Z",
|
|
5
|
+
"accountId": "313ff409-0bb7-4af5-8cc9-9d0ff3631b9f",
|
|
6
6
|
"totalMonthlyUsers": 23,
|
|
7
|
-
"
|
|
7
|
+
"projects": [
|
|
8
8
|
{
|
|
9
|
-
"
|
|
10
|
-
"
|
|
9
|
+
"projectId": "d49fdf10-3744-462c-84f8-abad444d7044",
|
|
10
|
+
"iosUsersCount": 3,
|
|
11
|
+
"androidUsersCount": 5
|
|
11
12
|
},
|
|
12
13
|
{
|
|
13
|
-
"
|
|
14
|
-
"
|
|
14
|
+
"projectId": "d26b75ad-42ca-401c-b526-d745105886cd",
|
|
15
|
+
"iosUsersCount": 12,
|
|
16
|
+
"androidUsersCount": 5
|
|
15
17
|
},
|
|
16
18
|
{
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
+
"projectId": "6a2d898f-6894-41b8-8e7b-3445872f27d3",
|
|
20
|
+
"iosUsersCount": 3,
|
|
21
|
+
"androidUsersCount": 7
|
|
19
22
|
},
|
|
20
23
|
{
|
|
21
|
-
"
|
|
22
|
-
"
|
|
24
|
+
"projectId": "df9dd8a9-e6f1-417b-88c4-6d314a64ab80",
|
|
25
|
+
"iosUsersCount": 6,
|
|
26
|
+
"androidUsersCount": 15
|
|
23
27
|
},
|
|
24
28
|
{
|
|
25
|
-
"
|
|
26
|
-
"
|
|
29
|
+
"projectId": "ab45514e-0d66-47dd-9508-b19c8cad1c4e",
|
|
30
|
+
"iosUsersCount": 32,
|
|
31
|
+
"androidUsersCount": 52
|
|
27
32
|
}
|
|
28
33
|
]
|
|
29
34
|
}
|
|
@@ -36,37 +36,39 @@ describe('MonthlyStat', () => {
|
|
|
36
36
|
done()
|
|
37
37
|
})
|
|
38
38
|
})
|
|
39
|
-
it('should not accept a invalid
|
|
40
|
-
monthlyStats.
|
|
39
|
+
it('should not accept a invalid accountId', (done) => {
|
|
40
|
+
monthlyStats.accountId = 'invalid-accountId'
|
|
41
41
|
let MonthlyStats = new MonthlyStatsModel(monthlyStats)
|
|
42
42
|
MonthlyStats.validate((err, res) => {
|
|
43
|
-
assert.exists(err, 'invalid
|
|
43
|
+
assert.exists(err, 'invalid accountId')
|
|
44
44
|
assert.isObject(err)
|
|
45
45
|
done()
|
|
46
46
|
})
|
|
47
47
|
})
|
|
48
|
-
it('should not accept a invalid
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
it('should not accept a invalid projectId', (done) => {
|
|
49
|
+
const invalidProjectId = {
|
|
50
|
+
projectId: 'invalid-projectId',
|
|
51
|
+
iosUserCount: 0,
|
|
52
|
+
androidUserCount: 0
|
|
52
53
|
}
|
|
53
|
-
monthlyStats.
|
|
54
|
+
monthlyStats.projects.push(invalidProjectId)
|
|
54
55
|
let MonthlyStats = new MonthlyStatsModel(monthlyStats)
|
|
55
56
|
MonthlyStats.validate((err, res) => {
|
|
56
|
-
assert.exists(err, 'invalid
|
|
57
|
+
assert.exists(err, 'invalid projectId')
|
|
57
58
|
assert.isObject(err)
|
|
58
59
|
done()
|
|
59
60
|
})
|
|
60
61
|
})
|
|
61
62
|
it('should not accept a negative monthlyUsers value', (done) => {
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
const invalidUsersCount = {
|
|
64
|
+
projectId: 'd49fdf10-3744-462c-84f8-abad444d7044',
|
|
65
|
+
iosUserCount: -100,
|
|
66
|
+
androidUserCount: 0
|
|
65
67
|
}
|
|
66
|
-
monthlyStats.
|
|
68
|
+
monthlyStats.projects.push(invalidUsersCount)
|
|
67
69
|
let MonthlyStats = new MonthlyStatsModel(monthlyStats)
|
|
68
70
|
MonthlyStats.validate((err, res) => {
|
|
69
|
-
assert.exists(err, 'Path `
|
|
71
|
+
assert.exists(err, 'Path `iosUserCount` (-100) is less than minimum allowed value (0)')
|
|
70
72
|
assert.isObject(err)
|
|
71
73
|
done()
|
|
72
74
|
})
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Created by Daniel on 23/11/2017.
|
|
3
|
+
* Copyright : Bluedot Innovations.
|
|
4
|
+
* Owner :
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const mongoose = require('mongoose')
|
|
8
|
+
const Schema = mongoose.Schema
|
|
9
|
+
const uuidv4 = require('uuid/v4')
|
|
10
|
+
|
|
11
|
+
const CumulativeRulesRequestsSchema = new Schema(
|
|
12
|
+
{
|
|
13
|
+
_id: {type: String, default: uuidv4},
|
|
14
|
+
totalEndUsers: Number,
|
|
15
|
+
totalIos: Number,
|
|
16
|
+
totalAndroid: Number,
|
|
17
|
+
creationDate: {type: Date, default: Date.now}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
collection: 'cumulativeRulesRequests',
|
|
21
|
+
versionKey: false
|
|
22
|
+
}
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
// optional mongoose
|
|
26
|
+
let model = (mongooseInstance) => {
|
|
27
|
+
let CumulativeRulesRequests
|
|
28
|
+
if (mongooseInstance) {
|
|
29
|
+
CumulativeRulesRequests = mongooseInstance.model('CumulativeRulesRequests', CumulativeRulesRequestsSchema)
|
|
30
|
+
} else {
|
|
31
|
+
CumulativeRulesRequests = mongoose.model('CumulativeRulesRequests', CumulativeRulesRequestsSchema)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return CumulativeRulesRequests
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports = { Model: model, Schema: CumulativeRulesRequestsSchema }
|
package/models/DailyStats.js
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Created by Daniel on
|
|
3
|
-
* Copyright : Bluedot
|
|
2
|
+
* Created by Daniel on 04/06/2017.
|
|
3
|
+
* Copyright : Bluedot Innovation.
|
|
4
4
|
* Owner :
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
6
|
const mongoose = require('mongoose')
|
|
8
|
-
const Schema = mongoose.Schema
|
|
9
7
|
const uuidv4 = require('uuid/v4')
|
|
8
|
+
const helpers = require('../helpers')
|
|
10
9
|
|
|
11
|
-
const
|
|
12
|
-
{
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
const schema = {
|
|
11
|
+
_id: { type: String, default: uuidv4 },
|
|
12
|
+
projectId: {type: String, required: [true, 'projectId is required'], validate: {isAsync: false, validator: helpers.validateUUIDv4, msg: 'invalid projectId'}},
|
|
13
|
+
accountId: {type: String, required: [true, 'accountId is required'], validate: {isAsync: false, validator: helpers.validateUUIDv4, msg: 'invalid accountId'}},
|
|
14
|
+
iosCount: {type: Number, required: [true, 'iosCount is required'], min: 0},
|
|
15
|
+
androidCount: {type: Number, required: [true, 'androidCount is required'], min: 0},
|
|
16
|
+
creationDate: { type: Date, default: Date.now }
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const DailyStatsSchema = new mongoose.Schema(
|
|
20
|
+
schema,
|
|
19
21
|
{
|
|
20
22
|
collection: 'dailyStats',
|
|
21
23
|
versionKey: false
|
|
@@ -34,4 +36,5 @@ let model = (mongooseInstance) => {
|
|
|
34
36
|
return DailyStats
|
|
35
37
|
}
|
|
36
38
|
|
|
39
|
+
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
37
40
|
module.exports = { Model: model, Schema: DailyStatsSchema }
|
package/models/MonthlyStats.js
CHANGED
|
@@ -10,11 +10,12 @@ const helpers = require('../helpers')
|
|
|
10
10
|
|
|
11
11
|
const schema = {
|
|
12
12
|
_id: { type: String, default: uuidv4 },
|
|
13
|
-
|
|
13
|
+
accountId: {type: String, required: [true, 'accountId is required'], validate: {isAsync: false, validator: helpers.validateUUIDv4, msg: 'invalid accountId'}},
|
|
14
14
|
totalMonthlyUsers: {type: Number, required: [true, 'totalMonthlyUsers is required'], min: 0},
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
projects: [{
|
|
16
|
+
projectId: {type: String, required: [true, 'projectId is required'], validate: {isAsync: false, validator: helpers.validateUUIDv4, msg: 'invalid projectId'}},
|
|
17
|
+
iosUsersCount: {type: Number, required: [true, 'iosUsersCount is required'], min: 0},
|
|
18
|
+
androidUsersCount: {type: Number, required: [true, 'androidUsersCount is required'], min: 0}
|
|
18
19
|
}],
|
|
19
20
|
countMonth: { type: Date, default: Date.now },
|
|
20
21
|
creationDate: { type: Date, default: Date.now }
|
package/models/TestScenario.js
CHANGED
|
@@ -17,7 +17,10 @@ let TestScenarioSchema = new mongoose.Schema(
|
|
|
17
17
|
state: {type: String, default: StateEnum.ACTIVE},
|
|
18
18
|
numberZones: String,
|
|
19
19
|
comments: String,
|
|
20
|
-
environment: String
|
|
20
|
+
environment: String,
|
|
21
|
+
accountId: String,
|
|
22
|
+
projectId: String,
|
|
23
|
+
zones: []
|
|
21
24
|
},
|
|
22
25
|
{ collection: 'testScenario' }
|
|
23
26
|
)
|
package/package.json
CHANGED
package/schemas/IosConfig.js
CHANGED
|
@@ -14,6 +14,11 @@ let triggerEngineEnum = {
|
|
|
14
14
|
message: 'enum validator failed for path `{PATH}` with value `{VALUE}`'
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
let disableBackgroundLocationEnum = {
|
|
18
|
+
values: ['None', 'BD'],
|
|
19
|
+
message: 'enum validator failed for path `{PATH}` with value `{VALUE}`'
|
|
20
|
+
}
|
|
21
|
+
|
|
17
22
|
let IosSchema = new mongoose.Schema({
|
|
18
23
|
triggeringOnWifiAccuracyThreshold : {type: Number, required: true},
|
|
19
24
|
triggeringOnGpsAccuracyThreshold : {type: Number, required: true},
|
|
@@ -35,7 +40,8 @@ let IosSchema = new mongoose.Schema({
|
|
|
35
40
|
telemetry: telemetrySchema,
|
|
36
41
|
accuracySuppression: accuracySuppressionSchema,
|
|
37
42
|
starvationDetector: starvationDetectionSchema,
|
|
38
|
-
triggerEngine: {type: String, enum: triggerEngineEnum, required: true}
|
|
43
|
+
triggerEngine: {type: String, enum: triggerEngineEnum, required: true},
|
|
44
|
+
disableBackgroundLocation: {type: String, enum: disableBackgroundLocationEnum, required: true}
|
|
39
45
|
}, {
|
|
40
46
|
_id: false
|
|
41
47
|
})
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
const assert = require('chai').assert
|
|
2
|
-
const DailyStats = require('../../models/DailyStats')
|
|
3
|
-
let testCase = require('mocha').describe
|
|
4
|
-
let assertions = require('mocha').it
|
|
5
|
-
|
|
6
|
-
const dailyStats = {
|
|
7
|
-
totalEndUsers: 4626,
|
|
8
|
-
totalIos: 2196,
|
|
9
|
-
totalAndroid: 2430
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
testCase('Creating new dailyStats document ', () => {
|
|
13
|
-
assertions('validates data types and structure of dailyStats document', (done) => {
|
|
14
|
-
const createDailyStats = new DailyStats(dailyStats)
|
|
15
|
-
assert(createDailyStats._id)
|
|
16
|
-
assert(createDailyStats._id.match(/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/))
|
|
17
|
-
createDailyStats.validate()
|
|
18
|
-
.then(() => {
|
|
19
|
-
console.log('validate DailyStats')
|
|
20
|
-
assert(true)
|
|
21
|
-
done()
|
|
22
|
-
}).catch(err => {
|
|
23
|
-
console.log('Errors found:')
|
|
24
|
-
for (let key of Object.keys(err.errors)) {
|
|
25
|
-
console.log(err.errors[key].message)
|
|
26
|
-
}
|
|
27
|
-
assert(false)
|
|
28
|
-
done(err)
|
|
29
|
-
})
|
|
30
|
-
})
|
|
31
|
-
})
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
let mongoose = require('mongoose')
|
|
2
|
-
|
|
3
|
-
mongoose.Promise = global.Promise
|
|
4
|
-
|
|
5
|
-
let RuleRequestAggregationModel = require('../../Models').RuleRequestAggregation(mongoose)
|
|
6
|
-
let RuleRequestAggregationModelBuiltInMongoose = require('../../Models').RuleRequestAggregation()
|
|
7
|
-
let testCase = require('mocha').describe
|
|
8
|
-
let assertions = require('mocha').it
|
|
9
|
-
let chai = require('chai')
|
|
10
|
-
|
|
11
|
-
let assert = chai.assert
|
|
12
|
-
let mocha = require('mocha')
|
|
13
|
-
let beforeEach = mocha.beforeEach
|
|
14
|
-
|
|
15
|
-
let ruleRequestAggregation
|
|
16
|
-
|
|
17
|
-
beforeEach(() => {
|
|
18
|
-
ruleRequestAggregation = JSON.parse(JSON.stringify(require('./ruleRequestAggregation.data.json')))
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
testCase('RuleRequestAggregation', () => {
|
|
22
|
-
testCase('Valid RuleRequestAggregation document', () => {
|
|
23
|
-
assertions('should validate a valid RuleRequestAggregation document ', (done) => {
|
|
24
|
-
let RuleRequestAggregation = new RuleRequestAggregationModel(ruleRequestAggregation)
|
|
25
|
-
RuleRequestAggregation.validate((err, res) => {
|
|
26
|
-
assert.notExists(res)
|
|
27
|
-
assert(err === null, 'err should equals null')
|
|
28
|
-
done()
|
|
29
|
-
})
|
|
30
|
-
})
|
|
31
|
-
assertions('should validate a valid RuleRequestAggregation document ', (done) => {
|
|
32
|
-
let RuleRequestAggregation = new RuleRequestAggregationModelBuiltInMongoose(ruleRequestAggregation)
|
|
33
|
-
RuleRequestAggregation.validate((err, res) => {
|
|
34
|
-
assert.notExists(res)
|
|
35
|
-
assert(err === null, 'err should equals null')
|
|
36
|
-
done()
|
|
37
|
-
})
|
|
38
|
-
})
|
|
39
|
-
assertions('should not accept a invalid customerId', (done) => {
|
|
40
|
-
ruleRequestAggregation.customerId = 'invalid-customerId'
|
|
41
|
-
let RuleRequestAggregation = new RuleRequestAggregationModel(ruleRequestAggregation)
|
|
42
|
-
RuleRequestAggregation.validate((err, res) => {
|
|
43
|
-
assert.exists(err, 'invalid customerId')
|
|
44
|
-
assert.isObject(err)
|
|
45
|
-
done()
|
|
46
|
-
})
|
|
47
|
-
})
|
|
48
|
-
assertions('should not accept a invalid applicationId', (done) => {
|
|
49
|
-
ruleRequestAggregation.applicationId = 'invalid-applicationId'
|
|
50
|
-
let RuleRequestAggregation = new RuleRequestAggregationModel(ruleRequestAggregation)
|
|
51
|
-
RuleRequestAggregation.validate((err, res) => {
|
|
52
|
-
assert.exists(err, 'invalid applicationId')
|
|
53
|
-
assert.isObject(err)
|
|
54
|
-
done()
|
|
55
|
-
})
|
|
56
|
-
})
|
|
57
|
-
assertions('should not accept a negative iosCount value', (done) => {
|
|
58
|
-
const negativeIosCount = -100
|
|
59
|
-
ruleRequestAggregation.iosCount = negativeIosCount
|
|
60
|
-
let RuleRequestAggregation = new RuleRequestAggregationModel(ruleRequestAggregation)
|
|
61
|
-
RuleRequestAggregation.validate((err, res) => {
|
|
62
|
-
assert.exists(err, 'Path `androidCount` (' + negativeIosCount + ') is less than minimum allowed value (0)')
|
|
63
|
-
assert.isObject(err)
|
|
64
|
-
done()
|
|
65
|
-
})
|
|
66
|
-
})
|
|
67
|
-
assertions('should not accept a negative androidCount value', (done) => {
|
|
68
|
-
const negativeAndroidCount = -100
|
|
69
|
-
ruleRequestAggregation.androidCount = negativeAndroidCount
|
|
70
|
-
let RuleRequestAggregation = new RuleRequestAggregationModel(ruleRequestAggregation)
|
|
71
|
-
RuleRequestAggregation.validate((err, res) => {
|
|
72
|
-
assert.exists(err, 'Path `androidCount` (' + negativeAndroidCount + ') is less than minimum allowed value (0)')
|
|
73
|
-
assert.isObject(err)
|
|
74
|
-
done()
|
|
75
|
-
})
|
|
76
|
-
})
|
|
77
|
-
})
|
|
78
|
-
})
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Created by Daniel on 04/06/2017.
|
|
3
|
-
* Copyright : Bluedot Innovations.
|
|
4
|
-
* Owner :
|
|
5
|
-
*/
|
|
6
|
-
const mongoose = require('mongoose')
|
|
7
|
-
const uuidv4 = require('uuid/v4')
|
|
8
|
-
const helpers = require('../helpers')
|
|
9
|
-
|
|
10
|
-
const schema = {
|
|
11
|
-
_id: { type: String, default: uuidv4 },
|
|
12
|
-
applicationId: {type: String, required: [true, 'applicationId is required'], validate: {isAsync: false, validator: helpers.validateUUIDv4, msg: 'invalid applicationId'}},
|
|
13
|
-
customerId: {type: String, required: [true, 'customerId is required'], validate: {isAsync: false, validator: helpers.validateUUIDv4, msg: 'invalid customerId'}},
|
|
14
|
-
iosCount: {type: Number, required: [true, 'iosCount is required'], min: 0},
|
|
15
|
-
androidCount: {type: Number, required: [true, 'androidCount is required'], min: 0},
|
|
16
|
-
creationDate: { type: Date, default: Date.now }
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const RuleRequestAggregationSchema = new mongoose.Schema(
|
|
20
|
-
schema,
|
|
21
|
-
{
|
|
22
|
-
collection: 'ruleRequestAggregation',
|
|
23
|
-
versionKey: false
|
|
24
|
-
}
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
// optional mongoose
|
|
28
|
-
let model = (mongooseInstance) => {
|
|
29
|
-
let RuleRequestAggregation
|
|
30
|
-
if (mongooseInstance) {
|
|
31
|
-
RuleRequestAggregation = mongooseInstance.model('RuleRequestAggregation', RuleRequestAggregationSchema)
|
|
32
|
-
} else {
|
|
33
|
-
RuleRequestAggregation = mongoose.model('RuleRequestAggregation', RuleRequestAggregationSchema)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return RuleRequestAggregation
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
40
|
-
module.exports = { Model: model, Schema: RuleRequestAggregationSchema }
|