@positivegrid/pg-mongoose-schema 26.1.1 → 26.3.0
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/models/payment.js +9 -0
- package/models/preset.js +27 -1
- package/models/redeem.js +1 -1
- package/package.json +1 -1
package/models/payment.js
CHANGED
|
@@ -604,6 +604,15 @@ module.exports = function (mongoose) {
|
|
|
604
604
|
}
|
|
605
605
|
})
|
|
606
606
|
},
|
|
607
|
+
hasLicensePromise: async function (userID, productID) {
|
|
608
|
+
const hasProduct = await this.findOne({
|
|
609
|
+
user_id: userID,
|
|
610
|
+
product_id: productID,
|
|
611
|
+
status: 1,
|
|
612
|
+
'$or': [{ 'due_date': null }, { 'due_date': { $gt: new Date() } }]
|
|
613
|
+
}).exec()
|
|
614
|
+
return (hasProduct)
|
|
615
|
+
},
|
|
607
616
|
getLicenseByRedeem: function (redeem, cb) {
|
|
608
617
|
this.find({ from_redeem: redeem }).sort({ created_on: -1 }).exec(cb)
|
|
609
618
|
},
|
package/models/preset.js
CHANGED
|
@@ -249,6 +249,15 @@ module.exports = function (mongoose) {
|
|
|
249
249
|
description: 1,
|
|
250
250
|
category: 1
|
|
251
251
|
})
|
|
252
|
+
PresetSchema.index({
|
|
253
|
+
preset_for: 1,
|
|
254
|
+
status: 1
|
|
255
|
+
})
|
|
256
|
+
PresetSchema.index({
|
|
257
|
+
preset_for: 1,
|
|
258
|
+
signal_chain_type: 1,
|
|
259
|
+
status: 1
|
|
260
|
+
})
|
|
252
261
|
|
|
253
262
|
const PresetSongMappingSchema = new Schema({
|
|
254
263
|
preset_id: { type: ObjectId, ref: 'Preset', required: true },
|
|
@@ -357,6 +366,11 @@ module.exports = function (mongoose) {
|
|
|
357
366
|
text: {
|
|
358
367
|
path: 'name',
|
|
359
368
|
query: req.query.keyword,
|
|
369
|
+
fuzzy: {
|
|
370
|
+
maxEdits: 1,
|
|
371
|
+
prefixLength: 1,
|
|
372
|
+
maxExpansions: 30
|
|
373
|
+
},
|
|
360
374
|
score: {
|
|
361
375
|
boost: {
|
|
362
376
|
value: 3
|
|
@@ -366,7 +380,12 @@ module.exports = function (mongoose) {
|
|
|
366
380
|
}, {
|
|
367
381
|
text: {
|
|
368
382
|
path: ['description', 'category'],
|
|
369
|
-
query: req.query.keyword
|
|
383
|
+
query: req.query.keyword,
|
|
384
|
+
fuzzy: {
|
|
385
|
+
maxEdits: 2,
|
|
386
|
+
prefixLength: 0,
|
|
387
|
+
maxExpansions: 50
|
|
388
|
+
}
|
|
370
389
|
}
|
|
371
390
|
})
|
|
372
391
|
|
|
@@ -498,6 +517,13 @@ module.exports = function (mongoose) {
|
|
|
498
517
|
searchCondition = _.assign({}, searchCondition, { created_on: { $gte: moment().subtract(1, 'month').toDate() } })
|
|
499
518
|
}
|
|
500
519
|
|
|
520
|
+
// signal_chain_type query only works in Spark for now
|
|
521
|
+
if (searchCondition.preset_for === 'spark') {
|
|
522
|
+
if (_.has(req.query, 'signal_chain_type')) {
|
|
523
|
+
searchCondition.signal_chain_type = req.query.signal_chain_type
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
501
527
|
searchCondition = _handlePresetVersion(searchCondition, req)
|
|
502
528
|
|
|
503
529
|
debug('getPresetsBySearch:full_text %j %j', searchCondition, sortCondition)
|
package/models/redeem.js
CHANGED
|
@@ -17,7 +17,7 @@ module.exports = function (mongoose) {
|
|
|
17
17
|
created_on: { type: Date, default: Date.now },
|
|
18
18
|
updated_on: { type: Date, default: Date.now }
|
|
19
19
|
}, { collection: 'pg_redeem_code' })
|
|
20
|
-
RedeemCodeSchema.index({ code: 1 }, { unique: true })
|
|
20
|
+
RedeemCodeSchema.index({ code: 1, status: 1 }, { unique: true })
|
|
21
21
|
RedeemCodeSchema.index({ code: 1, product_id: 1, status: 1 })
|
|
22
22
|
RedeemCodeSchema.index({ code: 1, bundle_id: 1, status: 1 })
|
|
23
23
|
RedeemCodeSchema.index({ tracker: 1 })
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@positivegrid/pg-mongoose-schema",
|
|
3
|
-
"version": "26.
|
|
3
|
+
"version": "26.3.0",
|
|
4
4
|
"description": "Positive Grid mongoose schema",
|
|
5
5
|
"author": "Ferrari Lee <shiyung@positivegrid.com>",
|
|
6
6
|
"homepage": "https://git.positivegrid.com:8443/backend/pg-mongoose-schema",
|