playov2-js-utilities 0.3.61 → 0.3.62
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/lib/db_interface/monog/index.js +4 -0
- package/lib/db_interface/monog/schemas/activitySchemas/_activityIndex.js +5 -0
- package/lib/db_interface/monog/schemas/activitySchemas/activityInsurance.js +17 -0
- package/lib/db_interface/monog/schemas/activitySchemas/activityLocation.js +105 -0
- package/lib/db_interface/monog/schemas/activitySchemas/activityQueryBlock.js +12 -0
- package/lib/db_interface/monog/schemas/activitySchemas/activityView.js +14 -0
- package/lib/db_interface/monog/schemas/activitySchemas/cronJobLog.js +13 -0
- package/lib/db_interface/monog/schemas/activitySchemas/playogame.request.js +38 -0
- package/lib/db_interface/monog/schemas/activitySchemas/scheduled.tasks.js +53 -0
- package/lib/db_interface/monog/schemas/activitySchemas/userActivity.js +134 -0
- package/lib/db_interface/monog/schemas/userSchemas/QuickActions.js +26 -0
- package/lib/db_interface/monog/schemas/userSchemas/_userIndex.js +8 -0
- package/lib/db_interface/monog/schemas/userSchemas/blockedUser.js +12 -0
- package/lib/db_interface/monog/schemas/userSchemas/city.js +62 -0
- package/lib/db_interface/monog/schemas/userSchemas/country.js +64 -0
- package/lib/db_interface/monog/schemas/userSchemas/emailOtp.js +13 -0
- package/lib/db_interface/monog/schemas/userSchemas/emailVerificationToken.js +12 -0
- package/lib/db_interface/monog/schemas/userSchemas/gt.trial.games.js +24 -0
- package/lib/db_interface/monog/schemas/userSchemas/invite.js +14 -0
- package/lib/db_interface/monog/schemas/userSchemas/karmaConfig.js +12 -0
- package/lib/db_interface/monog/schemas/userSchemas/karmaLog.js +29 -0
- package/lib/db_interface/monog/schemas/userSchemas/passwordResetToken.js +12 -0
- package/lib/db_interface/monog/schemas/userSchemas/playo.subscription.pack.js +67 -0
- package/lib/db_interface/monog/schemas/userSchemas/rankings.js +17 -0
- package/lib/db_interface/monog/schemas/userSchemas/sports.js +26 -0
- package/lib/db_interface/monog/schemas/userSchemas/sportsCategory.js +12 -0
- package/lib/db_interface/monog/schemas/userSchemas/tempUser.js +36 -0
- package/lib/db_interface/monog/schemas/userSchemas/trendingSports.js +14 -0
- package/lib/db_interface/monog/schemas/userSchemas/user.activity.health.kit.data.js +27 -0
- package/lib/db_interface/monog/schemas/userSchemas/user.contacts.js +34 -0
- package/lib/db_interface/monog/schemas/userSchemas/user.js +111 -0
- package/lib/db_interface/monog/schemas/userSchemas/userAlerts.js +24 -0
- package/lib/db_interface/monog/schemas/userSchemas/userCredentials.js +50 -0
- package/lib/db_interface/monog/schemas/userSchemas/userFavourites.js +81 -0
- package/lib/db_interface/monog/schemas/userSchemas/userOtp.js +10 -0
- package/lib/db_interface/monog/schemas/userSchemas/userReputation.js +22 -0
- package/lib/db_interface/monog/schemas/userSchemas/userSocial.js +18 -0
- package/lib/db_interface/monog/schemas/userSchemas/year.in.playo.js +52 -0
- package/lib/index.js +3 -0
- package/package.json +3 -2
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const MONGOOSE = require("mongoose")
|
|
2
|
+
const Schema = MONGOOSE.Schema
|
|
3
|
+
const karmaLogSchema = new Schema({
|
|
4
|
+
userId: String,
|
|
5
|
+
karma: Number,
|
|
6
|
+
createdTS: { type: Date, default: Date.now },
|
|
7
|
+
type: String,
|
|
8
|
+
remarks: String,
|
|
9
|
+
id: String
|
|
10
|
+
}, { timestamps: { createdAt: 'createdTS', updatedAt: "modTS" } })
|
|
11
|
+
|
|
12
|
+
karmaLogSchema.index({ 'userId': 1, 'id': 1 })
|
|
13
|
+
|
|
14
|
+
module.exports = MONGOOSE.model("karmalog", karmaLogSchema)
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
type={
|
|
18
|
+
activity: on finishing a match successfully
|
|
19
|
+
firstActivity: on hosting first match successfully
|
|
20
|
+
venue: on rating avenue
|
|
21
|
+
referral: on successfull referral
|
|
22
|
+
profile: on succesfully completing the profile
|
|
23
|
+
onboard: on on boarding into app,
|
|
24
|
+
host: karma for successfully hosting activity ,
|
|
25
|
+
reset: on resetting account,
|
|
26
|
+
custom: any custom karma
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
*/
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const MONGOOSE = require("mongoose")
|
|
2
|
+
const Schema = MONGOOSE.Schema
|
|
3
|
+
|
|
4
|
+
const passwordResetToken = new Schema(
|
|
5
|
+
{
|
|
6
|
+
userId: { type: String, required: true, unique : true },
|
|
7
|
+
token: String,
|
|
8
|
+
expiry: Date
|
|
9
|
+
}
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
module.exports = MONGOOSE.model("passwordresettoken", passwordResetToken)
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
const mongoose = require("mongoose");
|
|
2
|
+
const MongooseUtils = require("../mongoose.utils");
|
|
3
|
+
|
|
4
|
+
const PlayoSubscriptionSchema = new mongoose.Schema(
|
|
5
|
+
{
|
|
6
|
+
id: {
|
|
7
|
+
type: String,
|
|
8
|
+
required: true,
|
|
9
|
+
unique: true,
|
|
10
|
+
},
|
|
11
|
+
name: {
|
|
12
|
+
type: String,
|
|
13
|
+
required: true,
|
|
14
|
+
},
|
|
15
|
+
cityCode: {
|
|
16
|
+
type: String,
|
|
17
|
+
required: true,
|
|
18
|
+
},
|
|
19
|
+
sportId: {
|
|
20
|
+
type: String,
|
|
21
|
+
required: true,
|
|
22
|
+
},
|
|
23
|
+
price: {
|
|
24
|
+
type: Number,
|
|
25
|
+
required: true,
|
|
26
|
+
},
|
|
27
|
+
strikeThroughPrice: {
|
|
28
|
+
type: Number,
|
|
29
|
+
required: true
|
|
30
|
+
},
|
|
31
|
+
currencyText: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: "INR",
|
|
34
|
+
},
|
|
35
|
+
slotsCount: {
|
|
36
|
+
type: Number,
|
|
37
|
+
required: true
|
|
38
|
+
},
|
|
39
|
+
active: {
|
|
40
|
+
type: Boolean,
|
|
41
|
+
default: true,
|
|
42
|
+
},
|
|
43
|
+
colorCode: {
|
|
44
|
+
type: String,
|
|
45
|
+
required: true
|
|
46
|
+
},
|
|
47
|
+
icon: {
|
|
48
|
+
type: String,
|
|
49
|
+
},
|
|
50
|
+
daysValid: {
|
|
51
|
+
type: Number,
|
|
52
|
+
},
|
|
53
|
+
valueSavedPerGame: {
|
|
54
|
+
type: Number,
|
|
55
|
+
},
|
|
56
|
+
maxActiveSubscriptions: {
|
|
57
|
+
type: Number
|
|
58
|
+
},
|
|
59
|
+
countryCode: {
|
|
60
|
+
type: String,
|
|
61
|
+
default: '+91'
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
MongooseUtils.defaultSchemaOptions
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
module.exports = mongoose.model("playosubscriptions", PlayoSubscriptionSchema);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const Mongoose = require("mongoose")
|
|
2
|
+
const Schema = Mongoose.Schema
|
|
3
|
+
|
|
4
|
+
const rankingsSchema = new Schema(
|
|
5
|
+
{
|
|
6
|
+
userId: { required: true, type: String },
|
|
7
|
+
activityRank: { type: Number, default: 0 },
|
|
8
|
+
matches: Number,
|
|
9
|
+
sports: [{
|
|
10
|
+
sportId: String,
|
|
11
|
+
rank: Number,
|
|
12
|
+
matches: Number
|
|
13
|
+
}]
|
|
14
|
+
}
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
module.exports = Mongoose.model("rankings", rankingsSchema)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
var mongoose = require('mongoose');
|
|
2
|
+
var Schema = mongoose.Schema;
|
|
3
|
+
|
|
4
|
+
var SportsSchema = new Schema({
|
|
5
|
+
name: { type: String, required: true },
|
|
6
|
+
sportId: { type: String, required: true, unique: true },
|
|
7
|
+
isRateable: { type: Number, default: 1 },
|
|
8
|
+
skillSet: [{
|
|
9
|
+
skill: String
|
|
10
|
+
}],
|
|
11
|
+
grayIcon: String,
|
|
12
|
+
colorIcon: String,
|
|
13
|
+
v2GrayIcon: String,
|
|
14
|
+
v2SportIllustration: String,
|
|
15
|
+
sportsBro: [],
|
|
16
|
+
active: { type: Boolean, default: true },
|
|
17
|
+
content: { type: Boolean, default: false },
|
|
18
|
+
sportsPlayingMode: [{
|
|
19
|
+
name: { type: String },
|
|
20
|
+
icon: { type: String }
|
|
21
|
+
}],
|
|
22
|
+
createdTS: { type: Date, default: Date.now },
|
|
23
|
+
modTS: { type: Date, default: Date.now }
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
module.exports = mongoose.model('Sports', SportsSchema);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var mongoose = require('mongoose');
|
|
2
|
+
var Schema = mongoose.Schema;
|
|
3
|
+
|
|
4
|
+
var SportsCategorySchema = new Schema({
|
|
5
|
+
id: String,
|
|
6
|
+
name: String,
|
|
7
|
+
priority: Number,
|
|
8
|
+
sports: String,
|
|
9
|
+
cityCode: Number,
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
module.exports = mongoose.model('SportsCategory', SportsCategorySchema);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const { Schema, model } = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const TempUserSchema = new Schema({
|
|
4
|
+
id: { type: String, required: true },
|
|
5
|
+
deviceType: {
|
|
6
|
+
type: Number,
|
|
7
|
+
enum: [11, 0, 1], // 1 -> android, 11 -> ios, 0 -> web (not used)
|
|
8
|
+
default: -1
|
|
9
|
+
},
|
|
10
|
+
onesignalId: [{ type: String }], // onesignalId
|
|
11
|
+
fcmId: { type: String }, // unique id for devices
|
|
12
|
+
version: { type: String, default: '' },
|
|
13
|
+
ispCarrier: { type: String, default: '' },
|
|
14
|
+
geoLocation: {
|
|
15
|
+
type: { type: String, default: 'Point' },
|
|
16
|
+
coordinates: { type: [Number], default: [0, 0] }
|
|
17
|
+
},
|
|
18
|
+
geoLocationCity: {
|
|
19
|
+
type: { type: String, default: 'Point' },
|
|
20
|
+
coordinates: { type: [Number], default: [0, 0] }
|
|
21
|
+
},
|
|
22
|
+
lastActiveAreaName: { type: String, default: '' },
|
|
23
|
+
cityCode: { type: Number, default: 0 },
|
|
24
|
+
placeId: { type: String, default: '' },
|
|
25
|
+
countryCode: { type: String, default: '' },
|
|
26
|
+
phoneCountryCode: { type: String, default: '' },
|
|
27
|
+
deviceModel: { type: String, default: '' },
|
|
28
|
+
versionCode: { type: Number, default: 0 },
|
|
29
|
+
userRegistered : { type: Boolean, default: false },
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
timestamps: { createdAt: 'createdTS', updatedAt: "modTS" }
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
module.exports = model('TempUser', TempUserSchema);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const { Schema, model } = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const TrendingSportsSchema = new Schema({
|
|
4
|
+
sportId: { type: String, required: true },
|
|
5
|
+
isTrending: { type: Boolean, required: true },
|
|
6
|
+
tags: {
|
|
7
|
+
type: [
|
|
8
|
+
{ type: String }
|
|
9
|
+
],
|
|
10
|
+
default: []
|
|
11
|
+
}
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
module.exports = model('TrendingSports', TrendingSportsSchema);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
const Schema = mongoose.Schema;
|
|
3
|
+
const MongooseUtils = require('../mongoose.utils');
|
|
4
|
+
|
|
5
|
+
const userHealthKitSchema = new Schema({
|
|
6
|
+
userId: { type: String, required: true },
|
|
7
|
+
activityId: { type: String, required: true },
|
|
8
|
+
healthKitActivityDate: { type: Date, default: Date.now },
|
|
9
|
+
peakHeartrateReached: { type: Number, default: 0 },
|
|
10
|
+
stepsTaken: { type: Number, default: 0 },
|
|
11
|
+
kCaloriesBurned: { type: Number, default: 0 },
|
|
12
|
+
minutesPlayed: { type: Number, default: 0 },
|
|
13
|
+
distanceCoveredInMetres: { type: Number, default: 0 },
|
|
14
|
+
healthKitDataSource: { type: String, required: true }, // google / ios
|
|
15
|
+
year: { type: Number, required: true },
|
|
16
|
+
week: { type: Number, required: true },
|
|
17
|
+
sportId: { type: String, required: true },
|
|
18
|
+
metadata: {},
|
|
19
|
+
isValid: { type: Boolean, default: true },
|
|
20
|
+
lastSyncedDate: { type: Date, default: null },
|
|
21
|
+
}, MongooseUtils.defaultSchemaOptions);
|
|
22
|
+
|
|
23
|
+
// compound indexes on - userId and healthKitActivityDate
|
|
24
|
+
// userId, activityId
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
module.exports = mongoose.model('userhealthkitdata', userHealthKitSchema);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
const Schema = mongoose.Schema;
|
|
3
|
+
const MongooseUtils = require('../mongoose.utils');
|
|
4
|
+
|
|
5
|
+
const userContactsSchema = new Schema({
|
|
6
|
+
id: String,
|
|
7
|
+
userId: String,
|
|
8
|
+
fName: String,
|
|
9
|
+
lName: String,
|
|
10
|
+
email: String,
|
|
11
|
+
mobile: {
|
|
12
|
+
countryCode: String,
|
|
13
|
+
phone: String
|
|
14
|
+
},
|
|
15
|
+
playPal: {
|
|
16
|
+
type: Boolean,
|
|
17
|
+
default: false
|
|
18
|
+
},
|
|
19
|
+
contactId: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: null
|
|
22
|
+
},
|
|
23
|
+
active: {
|
|
24
|
+
type: Boolean,
|
|
25
|
+
default: true
|
|
26
|
+
},
|
|
27
|
+
linkingId: String
|
|
28
|
+
}, MongooseUtils.defaultSchemaOptions);
|
|
29
|
+
|
|
30
|
+
userContactsSchema.virtual('onPlayo').get(function () {
|
|
31
|
+
return this.contactId !== null;
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
module.exports = mongoose.model('UserContacts', userContactsSchema);
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
const mongoose = require('mongoose')
|
|
2
|
+
const Schema = mongoose.Schema
|
|
3
|
+
const userSchema = new Schema({
|
|
4
|
+
id: { type: String, required: true, unique: true },
|
|
5
|
+
fName: { type: String, default: "" },
|
|
6
|
+
lName: { type: String, default: "" },
|
|
7
|
+
userName: {type: String, default: ""},
|
|
8
|
+
email: { type: String, primary: true, default: "" },
|
|
9
|
+
officialEmail: { type: String, required: false },
|
|
10
|
+
mobile: { type: String, default: "" },
|
|
11
|
+
oldPlayoId: { type: String, default: "" },
|
|
12
|
+
lastActiveAreaName: { type: String, default: "" },
|
|
13
|
+
active: { type: Date, default: Date.now },
|
|
14
|
+
phoneCountryCode: { type: String, default: "" },
|
|
15
|
+
countryCode: { type: String, default: "" },
|
|
16
|
+
cityCode: { type: Number, default: 1 },
|
|
17
|
+
profilePicUrl: { type: String, default: "" },
|
|
18
|
+
gender: { type: Number, default: 2, min: 0, max: 3 }, // 0-female , 1-male, 2-does not matter;3-others
|
|
19
|
+
karma: { type: Number, default: 0 },
|
|
20
|
+
karmaRedeem: { type: Number, default: 0 },
|
|
21
|
+
city: { type: String, default: "" },
|
|
22
|
+
geoLocation: {
|
|
23
|
+
type: { type: String, enum: ['Point'], default: 'Point' },
|
|
24
|
+
coordinates: {
|
|
25
|
+
type : [Number], default: [0, 0]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
geoLocationCity: {
|
|
29
|
+
type: { type: String },
|
|
30
|
+
coordinates: []
|
|
31
|
+
},
|
|
32
|
+
bio: { type: String, default: "" },
|
|
33
|
+
palsCount: Number,
|
|
34
|
+
emailVerified: { type: Boolean, default: false },
|
|
35
|
+
officialEmailVerified: { type: Boolean, default: false },
|
|
36
|
+
verified: { type: Boolean, default: false },
|
|
37
|
+
reportCount: Number,
|
|
38
|
+
superUser: { type: Boolean, default: false },
|
|
39
|
+
venueId: { type: String, default: "" },
|
|
40
|
+
rules: { type: String, default: "" },
|
|
41
|
+
messages: [ // for notifications
|
|
42
|
+
{
|
|
43
|
+
key: String,
|
|
44
|
+
value: String
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
isOnApplozic: { type: Boolean, default: false },
|
|
48
|
+
lastPlayed: { type: Date, default: null },
|
|
49
|
+
// createdTS: { type: Date, default: Date.now },
|
|
50
|
+
// modTS: {
|
|
51
|
+
// type: Date, default: new Date().toISOString(),
|
|
52
|
+
|
|
53
|
+
// },
|
|
54
|
+
helpTS: { type: Date, default: Date.now },
|
|
55
|
+
deviceType: { type: Number, default: -1 }, //11-ios, 0-android - 11 is correct for ios
|
|
56
|
+
deviceModel: { type: String, default: "" },
|
|
57
|
+
gcmRegId: [],
|
|
58
|
+
iosRegId: [],
|
|
59
|
+
iosBadge: { type: Number, default: 0 },
|
|
60
|
+
version: { type: Number, default: 0 },
|
|
61
|
+
onesignalId: [],
|
|
62
|
+
shareLink: { type: String, default: "" },
|
|
63
|
+
deferLink: { type: String, default: "" },
|
|
64
|
+
chatStatus: { type: Number, default: 0 },
|
|
65
|
+
fullLink: { type: String, default: "" },
|
|
66
|
+
referralLink: { type: String, default: null },
|
|
67
|
+
lastResetOn: { type: Date, default: null },
|
|
68
|
+
oldEmail: { type: String, default: "" },
|
|
69
|
+
oldMobile: { type: String, default: "" },
|
|
70
|
+
publicActivityLimit: { type: Number, default: 5 },
|
|
71
|
+
placeId: { type: String },
|
|
72
|
+
paytmOpenId: { type: String },
|
|
73
|
+
paidHostName: { type: String, default: "" },
|
|
74
|
+
paidHostCity: { type: String, default: "" },
|
|
75
|
+
activityHistory: [
|
|
76
|
+
{
|
|
77
|
+
_id: false,
|
|
78
|
+
activityId: { type: String, unique: true },
|
|
79
|
+
activityTS: Date
|
|
80
|
+
}
|
|
81
|
+
],
|
|
82
|
+
lastProcessed: Date,
|
|
83
|
+
calendarLink: { type: String, default: "" },
|
|
84
|
+
activityStack: Boolean, // config which informs whether user's activities are to be stacked
|
|
85
|
+
extraFields: [{
|
|
86
|
+
_id: false,
|
|
87
|
+
id: { type: String, required: true },
|
|
88
|
+
value: { type: String, required: true }
|
|
89
|
+
}],
|
|
90
|
+
lastContactSyncedAt : {
|
|
91
|
+
type: Date,
|
|
92
|
+
default: null
|
|
93
|
+
},
|
|
94
|
+
onboardSource: {
|
|
95
|
+
type: String,
|
|
96
|
+
enum: ['web', 'android', 'ios', 'others'],
|
|
97
|
+
default: 'others'
|
|
98
|
+
}
|
|
99
|
+
}, { timestamps: { createdAt: 'createdTS', updatedAt: "modTS" } })
|
|
100
|
+
|
|
101
|
+
userSchema.index({ 'onesignalId': 1 }, { 'background': true })
|
|
102
|
+
userSchema.index({ 'mobile': 1 })
|
|
103
|
+
userSchema.index({ 'email': 1 }, { collation: { locale: "en", strength: 2 } }) // case insensitive index
|
|
104
|
+
userSchema.index({ 'officialEmail': 1 }, { collation: { locale: "en", strength: 2 } }) // case insensitive index
|
|
105
|
+
|
|
106
|
+
userSchema.index({ 'oldPlayoId': 1 })
|
|
107
|
+
|
|
108
|
+
const User = mongoose.model('User', userSchema)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
module.exports = User
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
var mongoose = require('mongoose');
|
|
2
|
+
var Schema = mongoose.Schema;
|
|
3
|
+
|
|
4
|
+
var userAlertSchema = new Schema({
|
|
5
|
+
userId: { type: String },
|
|
6
|
+
id: { type: String },
|
|
7
|
+
message: { type: String, default: "" },
|
|
8
|
+
isRead: { type: Boolean, default: false },
|
|
9
|
+
delete: { type: Boolean, default: false },
|
|
10
|
+
pic: { type: String, default: "" },
|
|
11
|
+
data: {
|
|
12
|
+
url: String
|
|
13
|
+
},
|
|
14
|
+
source: { type: String, default: "" },
|
|
15
|
+
isInvitation: { type: Boolean, default: false },
|
|
16
|
+
invitationExpiry: Date,
|
|
17
|
+
expiry: Date,
|
|
18
|
+
createdTS: { type: Date, default: Date.now },
|
|
19
|
+
notificationId: { type: String }
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
userAlertSchema.index({ 'userId': 1 })
|
|
23
|
+
|
|
24
|
+
module.exports = mongoose.model('UserAlert', userAlertSchema);
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const MONGOOSE = require('mongoose')
|
|
2
|
+
const Schema = MONGOOSE.Schema
|
|
3
|
+
const bcrypt = require("bcrypt")
|
|
4
|
+
const UTIL = require('../util')
|
|
5
|
+
const SALT_WORK_FACTOR = 10
|
|
6
|
+
const userCredentialSchema = new Schema({
|
|
7
|
+
// _id: false,
|
|
8
|
+
userId: { type: String, required: true, unique: true },
|
|
9
|
+
password: String
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
userCredentialSchema.pre('save', function (next) {
|
|
14
|
+
var user = this;
|
|
15
|
+
|
|
16
|
+
// only hash the password if it has been modified (or is new)
|
|
17
|
+
if (!user.isModified('password')) return next();
|
|
18
|
+
|
|
19
|
+
// generate a salt
|
|
20
|
+
bcrypt.genSalt(SALT_WORK_FACTOR, function (err, salt) {
|
|
21
|
+
if (err) return next(err);
|
|
22
|
+
|
|
23
|
+
// hash the password along with our new salt
|
|
24
|
+
bcrypt.hash(user.password, salt, function (err, hash) {
|
|
25
|
+
if (err) return next(err);
|
|
26
|
+
|
|
27
|
+
// override the cleartext password with the hashed one
|
|
28
|
+
user.password = hash;
|
|
29
|
+
next();
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
userCredentialSchema.methods.comparePassword = function (candidatePassword) {
|
|
35
|
+
// console.log("incoming password", candidatePassword, this.password)
|
|
36
|
+
return bcrypt.compare(candidatePassword, this.password).then(res => {
|
|
37
|
+
if (res)
|
|
38
|
+
return true
|
|
39
|
+
else
|
|
40
|
+
return false
|
|
41
|
+
}).catch(err => {
|
|
42
|
+
return err
|
|
43
|
+
})
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
module.exports = MONGOOSE.model('usercredentials', userCredentialSchema)
|
|
49
|
+
|
|
50
|
+
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
const MONGOOSE = require('mongoose')
|
|
2
|
+
const Schema = MONGOOSE.Schema
|
|
3
|
+
|
|
4
|
+
const UserFavouriteSchema = new Schema({
|
|
5
|
+
userId: { type: String, unique: true, required: true },
|
|
6
|
+
isTempUser: { type: Boolean, default: false },
|
|
7
|
+
sports: [{
|
|
8
|
+
_id: false,
|
|
9
|
+
sportId: { type: String, required: true },
|
|
10
|
+
selfRating: { type: Number, default: 0, min: 0, max: 5 },
|
|
11
|
+
rating: { type: Number, default: 0, min: 0, max: 5 },
|
|
12
|
+
ratingCount: { type: Number, default: 0, min: 0 },
|
|
13
|
+
matches: { type: Number, default: 0, min: 0 },
|
|
14
|
+
active: { type: Boolean, default: true },
|
|
15
|
+
oldCount: { type: Number, default: 0 }, // matched count is added when user reset sport stats
|
|
16
|
+
timestamp: Date,
|
|
17
|
+
lastReset: { type: Date },
|
|
18
|
+
activityRank: { type: Number, default: 0 }
|
|
19
|
+
}],
|
|
20
|
+
activityShortlist: [], //list of actvityId
|
|
21
|
+
venueBookmarks: [],//list of venueIds
|
|
22
|
+
activityShortlistLog: [],
|
|
23
|
+
areas: [{
|
|
24
|
+
_id: false,
|
|
25
|
+
geoLocation: {
|
|
26
|
+
type: { type: String },
|
|
27
|
+
coordinates: []
|
|
28
|
+
},
|
|
29
|
+
timestamp: { type: Date, default: Date.now },
|
|
30
|
+
areaName: { type: String, required: true },
|
|
31
|
+
type: { type: Number, default: 1 } // 1 - area, 2 - venue
|
|
32
|
+
}],
|
|
33
|
+
areasLog: [
|
|
34
|
+
{
|
|
35
|
+
_id: false,
|
|
36
|
+
geoLocation: {
|
|
37
|
+
type: { type: String },
|
|
38
|
+
coordinates: []
|
|
39
|
+
},
|
|
40
|
+
timestamp: { type: Date, default: Date.now },
|
|
41
|
+
areaName: { type: String, required: true },
|
|
42
|
+
type: { type: Number, default: 1 } // 1- area, 2 - venue
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
blocked: [], //list of userIds whom user blocked
|
|
46
|
+
isBlocked: [], //list of userids who blocked user
|
|
47
|
+
gatewayInfo: [{
|
|
48
|
+
_id: false,
|
|
49
|
+
gateway: { type: String, required: true },
|
|
50
|
+
customerId: { type: String, required: true }
|
|
51
|
+
}],
|
|
52
|
+
notificationPref: [{
|
|
53
|
+
_id: false,
|
|
54
|
+
category: { type: String, required: true },
|
|
55
|
+
status: { type: Boolean, required: true }
|
|
56
|
+
}],
|
|
57
|
+
lastPlayed: { type: Date, default: null },
|
|
58
|
+
lastReset: { type: Date, default: null },
|
|
59
|
+
weeklyHealthkitGoal: [{
|
|
60
|
+
_id: false,
|
|
61
|
+
weeklyMinutesGoal: {
|
|
62
|
+
type: Number,
|
|
63
|
+
default: 0
|
|
64
|
+
},
|
|
65
|
+
lastSetOn: {
|
|
66
|
+
type: Date,
|
|
67
|
+
default: null
|
|
68
|
+
}
|
|
69
|
+
}],
|
|
70
|
+
healthkitSettings: {
|
|
71
|
+
permissions: [],
|
|
72
|
+
provider: { type: String },
|
|
73
|
+
permissionProvidedDate: { type: Date, default: null }
|
|
74
|
+
}
|
|
75
|
+
}, { timestamps: { createdAt: 'createdTS', updatedAt: "modTS" } })
|
|
76
|
+
|
|
77
|
+
UserFavouriteSchema.index({ 'activityShortlist': 1 }, { 'background': true })
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
module.exports = MONGOOSE.model('userFavourites', UserFavouriteSchema)
|
|
81
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var mongoose = require('mongoose');
|
|
2
|
+
var Schema = mongoose.Schema;
|
|
3
|
+
|
|
4
|
+
var OTPSchema = new Schema({
|
|
5
|
+
mobile: { type: String, required: true, unique: true },
|
|
6
|
+
ts: { type: String, default: new Date() },
|
|
7
|
+
otp: { type: Number, required: true }
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
module.exports = mongoose.model('OTP', OTPSchema);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const MONGOOSE = require("mongoose")
|
|
2
|
+
const Schema = MONGOOSE.Schema
|
|
3
|
+
const userReputationSchema = new Schema(
|
|
4
|
+
{
|
|
5
|
+
userId: { type: String, primary: true, unique: true },
|
|
6
|
+
reputations: [{
|
|
7
|
+
_id: false,
|
|
8
|
+
reputationId: { type: Number, required: true },
|
|
9
|
+
upvotes: { type: Number, default: 0, required: true, min: 0 },
|
|
10
|
+
downvotes: { type: Number, default: 0, required: true, min: 0 }
|
|
11
|
+
}],
|
|
12
|
+
noshow: [{
|
|
13
|
+
_id: false,
|
|
14
|
+
activityId: { type: String, required: true },
|
|
15
|
+
timestamp: { type: Date, required: true },
|
|
16
|
+
status: { type: Boolean, required: true }
|
|
17
|
+
}]
|
|
18
|
+
}, { timestamps: { createdAt: 'createdTS', updatedAt: "modTS" } }
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
module.exports = MONGOOSE.model("userReputation", userReputationSchema)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const MONGOOSE = require("mongoose")
|
|
2
|
+
const Schema = MONGOOSE.Schema
|
|
3
|
+
const accountSchema = new Schema({
|
|
4
|
+
_id: false,
|
|
5
|
+
type: Number, // 0-google , 1-fb
|
|
6
|
+
link: String,
|
|
7
|
+
id: String,
|
|
8
|
+
isActive: { type: Boolean, default: true }
|
|
9
|
+
})
|
|
10
|
+
const userSocialSchema = new Schema({
|
|
11
|
+
userId: { type: String, unique: true },
|
|
12
|
+
accounts: [
|
|
13
|
+
accountSchema
|
|
14
|
+
]
|
|
15
|
+
}, { timestamps: { createdAt: 'createdTS', updatedAt: "modTS" } })
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
module.exports = MONGOOSE.model("userSocial", userSocialSchema)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const MONGOOSE = require("mongoose")
|
|
2
|
+
const Schema = MONGOOSE.Schema
|
|
3
|
+
const yearInPlayoSchema = new Schema({
|
|
4
|
+
userId: { type: String, unique: true },
|
|
5
|
+
totalNumberOfGamesPlayed: { type: Number, default: 0 },
|
|
6
|
+
totalNumberOfHoursPlayed: { type: Number, default: 0 },
|
|
7
|
+
totalCaloriesBurnt: { type: Number, default: 0 },
|
|
8
|
+
karma: {
|
|
9
|
+
totalEarned: { type: Number, default: 0 },
|
|
10
|
+
bestMonth: String,
|
|
11
|
+
moneySavedByKarma: { type: Number, default: 0 },
|
|
12
|
+
},
|
|
13
|
+
venues: {
|
|
14
|
+
venuesTried: { type: Number, default: 0 },
|
|
15
|
+
favoriteVenue: String,
|
|
16
|
+
totalGamesAtFavouriteVenue: Number
|
|
17
|
+
},
|
|
18
|
+
sports: {
|
|
19
|
+
numberOfSportsPlayed: { type: Number, default: 0 }, // different sports user played last year
|
|
20
|
+
favoriteSports: String,
|
|
21
|
+
favouriteSportPlayedCount: { type: Number, default: 0 },
|
|
22
|
+
},
|
|
23
|
+
playpals: {
|
|
24
|
+
newPlayPals: { type: Number, default: 0 },
|
|
25
|
+
favorite: String,
|
|
26
|
+
totalGamesWithFavoritePlayPal: { type: Number, default: 0 },
|
|
27
|
+
topPlaypals: [
|
|
28
|
+
{
|
|
29
|
+
userId: String,
|
|
30
|
+
name: String,
|
|
31
|
+
profilePicUrl: String
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
referredUsers: [
|
|
36
|
+
{
|
|
37
|
+
userId: String,
|
|
38
|
+
name: String,
|
|
39
|
+
profilePicUrl: String,
|
|
40
|
+
gamesCompleted: { type: Number, default: 0 },
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
leaderBoardRank: { type: Number, default: 0 },
|
|
44
|
+
year: Number,
|
|
45
|
+
hours: {},
|
|
46
|
+
url: String,
|
|
47
|
+
cityCode: Number
|
|
48
|
+
}, { timestamps: { createdAt: 'createdTS', updatedAt: "modTS" } })
|
|
49
|
+
|
|
50
|
+
yearInPlayoSchema.index({ 'userId': 1 })
|
|
51
|
+
|
|
52
|
+
module.exports = MONGOOSE.model("yearinplayo", yearInPlayoSchema)
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
/*
|
|
3
3
|
* Naming terminology - While exporting constants use PascalCase while exporting functions/methods use camelCase
|
|
4
|
+
* This repo should be used as a library for all the common functionalities that are used across the services.
|
|
5
|
+
* This repo should be privatized, no idea why it was public in the first place :(
|
|
4
6
|
*/
|
|
5
7
|
module.exports = {
|
|
6
8
|
ratings: require('./ratings/index'),
|
|
@@ -17,4 +19,5 @@ module.exports = {
|
|
|
17
19
|
PLAYO_ERROR_HANDLER: require("./playo.utils/playo.error.handler"),
|
|
18
20
|
PLAYO_HTTP_HANDLER: require("./playo.utils/playo.http.handler"),
|
|
19
21
|
PLAYO_RESPONSE_GENERATOR: require("./playo.utils/playo.res.generator"),
|
|
22
|
+
PLAYO_MONGO_MODELS: require("./db_interface/mongo/index"),
|
|
20
23
|
};
|