jp.db.schemas 2.2.9 → 2.2.11
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/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/models/activity-log-user-login.interface.d.ts.map +1 -1
- package/dist/models/activity-log.enum.d.ts.map +1 -1
- package/dist/models/activity-log.enum.js.map +1 -1
- package/dist/models/currency.enum.d.ts.map +1 -1
- package/dist/models/currency.enum.js.map +1 -1
- package/dist/models/rating-add-bulk-item.interface.d.ts.map +1 -1
- package/dist/models/rating-monthly-result.interface.d.ts.map +1 -1
- package/dist/models/tournament-participant.interface.d.ts.map +1 -1
- package/dist/models/tournament-status.enum.d.ts.map +1 -1
- package/dist/models/tournament-status.enum.js.map +1 -1
- package/dist/models/tournament-template.enum.d.ts.map +1 -1
- package/dist/models/tournament-template.enum.js.map +1 -1
- package/dist/models/tournament-winner.interface.d.ts.map +1 -1
- package/dist/models/users-balance-reason.enum.d.ts.map +1 -1
- package/dist/models/users-balance-reason.enum.js.map +1 -1
- package/dist/repositories/achievement.repository.d.ts.map +1 -1
- package/dist/repositories/achievement.repository.js +1 -3
- package/dist/repositories/achievement.repository.js.map +1 -1
- package/dist/repositories/activity-log.repository.d.ts.map +1 -1
- package/dist/repositories/activity-log.repository.js +78 -26
- package/dist/repositories/activity-log.repository.js.map +1 -1
- package/dist/repositories/admin.repository.d.ts.map +1 -1
- package/dist/repositories/admin.repository.js +2 -6
- package/dist/repositories/admin.repository.js.map +1 -1
- package/dist/repositories/article.repository.d.ts.map +1 -1
- package/dist/repositories/article.repository.js +3 -13
- package/dist/repositories/article.repository.js.map +1 -1
- package/dist/repositories/banners.repository.d.ts.map +1 -1
- package/dist/repositories/banners.repository.js +7 -12
- package/dist/repositories/banners.repository.js.map +1 -1
- package/dist/repositories/complains.repository.d.ts.map +1 -1
- package/dist/repositories/complains.repository.js +1 -4
- package/dist/repositories/complains.repository.js.map +1 -1
- package/dist/repositories/daily-bonus.repository.d.ts.map +1 -1
- package/dist/repositories/daily-bonus.repository.js +1 -3
- package/dist/repositories/daily-bonus.repository.js.map +1 -1
- package/dist/repositories/friend.repository.d.ts.map +1 -1
- package/dist/repositories/friend.repository.js.map +1 -1
- package/dist/repositories/game-result.repository.d.ts.map +1 -1
- package/dist/repositories/game-result.repository.js.map +1 -1
- package/dist/repositories/game-statistic.repository.d.ts.map +1 -1
- package/dist/repositories/game-statistic.repository.js.map +1 -1
- package/dist/repositories/index.d.ts +1 -1
- package/dist/repositories/index.d.ts.map +1 -1
- package/dist/repositories/index.js.map +1 -1
- package/dist/repositories/menu.repository.d.ts.map +1 -1
- package/dist/repositories/menu.repository.js.map +1 -1
- package/dist/repositories/notification.repository.d.ts.map +1 -1
- package/dist/repositories/notification.repository.js +6 -9
- package/dist/repositories/notification.repository.js.map +1 -1
- package/dist/repositories/premium.repository.d.ts.map +1 -1
- package/dist/repositories/premium.repository.js +1 -3
- package/dist/repositories/premium.repository.js.map +1 -1
- package/dist/repositories/products.repository.d.ts.map +1 -1
- package/dist/repositories/products.repository.js +1 -3
- package/dist/repositories/products.repository.js.map +1 -1
- package/dist/repositories/purchase.repository.d.ts.map +1 -1
- package/dist/repositories/purchase.repository.js +7 -11
- package/dist/repositories/purchase.repository.js.map +1 -1
- package/dist/repositories/rating.repository.d.ts.map +1 -1
- package/dist/repositories/rating.repository.js +21 -21
- package/dist/repositories/rating.repository.js.map +1 -1
- package/dist/repositories/rooms.repository.d.ts.map +1 -1
- package/dist/repositories/rooms.repository.js +1 -3
- package/dist/repositories/rooms.repository.js.map +1 -1
- package/dist/repositories/rule.repository.d.ts.map +1 -1
- package/dist/repositories/rule.repository.js +1 -3
- package/dist/repositories/rule.repository.js.map +1 -1
- package/dist/repositories/scheduled-tournaments.repository.d.ts.map +1 -1
- package/dist/repositories/scheduled-tournaments.repository.js.map +1 -1
- package/dist/repositories/servers.repository.d.ts.map +1 -1
- package/dist/repositories/servers.repository.js +1 -3
- package/dist/repositories/servers.repository.js.map +1 -1
- package/dist/repositories/setting.repository.d.ts.map +1 -1
- package/dist/repositories/setting.repository.js.map +1 -1
- package/dist/repositories/settings-options.repository.d.ts.map +1 -1
- package/dist/repositories/settings-options.repository.js +1 -3
- package/dist/repositories/settings-options.repository.js.map +1 -1
- package/dist/repositories/simple-rooms.repository.d.ts.map +1 -1
- package/dist/repositories/simple-rooms.repository.js +1 -3
- package/dist/repositories/simple-rooms.repository.js.map +1 -1
- package/dist/repositories/tournament-many-tables-rooms.repository.d.ts.map +1 -1
- package/dist/repositories/tournament-many-tables-rooms.repository.js +23 -18
- package/dist/repositories/tournament-many-tables-rooms.repository.js.map +1 -1
- package/dist/repositories/tournament-one-table-rooms.repository.d.ts.map +1 -1
- package/dist/repositories/tournament-one-table-rooms.repository.js +16 -12
- package/dist/repositories/tournament-one-table-rooms.repository.js.map +1 -1
- package/dist/repositories/users-achievements.repository.d.ts.map +1 -1
- package/dist/repositories/users-achievements.repository.js +2 -6
- package/dist/repositories/users-achievements.repository.js.map +1 -1
- package/dist/repositories/users-balances.repository.d.ts.map +1 -1
- package/dist/repositories/users-balances.repository.js +21 -3
- package/dist/repositories/users-balances.repository.js.map +1 -1
- package/dist/repositories/users.repository.d.ts.map +1 -1
- package/dist/repositories/users.repository.js +28 -34
- package/dist/repositories/users.repository.js.map +1 -1
- package/dist/repositories/welcome.repository.d.ts.map +1 -1
- package/dist/repositories/welcome.repository.js +1 -3
- package/dist/repositories/welcome.repository.js.map +1 -1
- package/dist/schemas/achievement.schema.d.ts.map +1 -1
- package/dist/schemas/achievement.schema.js.map +1 -1
- package/dist/schemas/activity_log.schema.d.ts.map +1 -1
- package/dist/schemas/activity_log.schema.js.map +1 -1
- package/dist/schemas/admin.schema.d.ts.map +1 -1
- package/dist/schemas/admin.schema.js.map +1 -1
- package/dist/schemas/article.schema.d.ts.map +1 -1
- package/dist/schemas/article.schema.js.map +1 -1
- package/dist/schemas/banner.schema.d.ts.map +1 -1
- package/dist/schemas/banner.schema.js.map +1 -1
- package/dist/schemas/channel_message.schema.d.ts.map +1 -1
- package/dist/schemas/channel_message.schema.js.map +1 -1
- package/dist/schemas/complain.schema.d.ts.map +1 -1
- package/dist/schemas/complain.schema.js.map +1 -1
- package/dist/schemas/daily_bonus.schema.d.ts +4 -16
- package/dist/schemas/daily_bonus.schema.d.ts.map +1 -1
- package/dist/schemas/daily_bonus.schema.js +4 -12
- package/dist/schemas/daily_bonus.schema.js.map +1 -1
- package/dist/schemas/feature.schema.d.ts.map +1 -1
- package/dist/schemas/feature.schema.js.map +1 -1
- package/dist/schemas/friend.schema.d.ts.map +1 -1
- package/dist/schemas/friend.schema.js.map +1 -1
- package/dist/schemas/game_result.schema.d.ts +14 -14
- package/dist/schemas/game_result.schema.d.ts.map +1 -1
- package/dist/schemas/game_result.schema.js.map +1 -1
- package/dist/schemas/game_statistic.schema.d.ts.map +1 -1
- package/dist/schemas/game_statistic.schema.js.map +1 -1
- package/dist/schemas/menu.schema.d.ts +2 -12
- package/dist/schemas/menu.schema.d.ts.map +1 -1
- package/dist/schemas/menu.schema.js +2 -6
- package/dist/schemas/menu.schema.js.map +1 -1
- package/dist/schemas/notification.schema.d.ts.map +1 -1
- package/dist/schemas/notification.schema.js.map +1 -1
- package/dist/schemas/premium.schema.d.ts +4 -16
- package/dist/schemas/premium.schema.d.ts.map +1 -1
- package/dist/schemas/premium.schema.js +4 -12
- package/dist/schemas/premium.schema.js.map +1 -1
- package/dist/schemas/product.schema.d.ts +12 -72
- package/dist/schemas/product.schema.d.ts.map +1 -1
- package/dist/schemas/product.schema.js +12 -36
- package/dist/schemas/product.schema.js.map +1 -1
- package/dist/schemas/purchase.schema.d.ts +20 -20
- package/dist/schemas/purchase.schema.d.ts.map +1 -1
- package/dist/schemas/purchase.schema.js.map +1 -1
- package/dist/schemas/purchase_channel.schema.d.ts.map +1 -1
- package/dist/schemas/purchase_channel.schema.js.map +1 -1
- package/dist/schemas/rating.schema.d.ts.map +1 -1
- package/dist/schemas/rating.schema.js.map +1 -1
- package/dist/schemas/rooms.schema.d.ts.map +1 -1
- package/dist/schemas/rooms.schema.js.map +1 -1
- package/dist/schemas/rule.schema.d.ts +4 -16
- package/dist/schemas/rule.schema.d.ts.map +1 -1
- package/dist/schemas/rule.schema.js +4 -12
- package/dist/schemas/rule.schema.js.map +1 -1
- package/dist/schemas/scheduled_tournament.schema.d.ts.map +1 -1
- package/dist/schemas/scheduled_tournament.schema.js.map +1 -1
- package/dist/schemas/server.schema.d.ts.map +1 -1
- package/dist/schemas/server.schema.js.map +1 -1
- package/dist/schemas/setting.schema.d.ts +4 -24
- package/dist/schemas/setting.schema.d.ts.map +1 -1
- package/dist/schemas/setting.schema.js +4 -12
- package/dist/schemas/setting.schema.js.map +1 -1
- package/dist/schemas/settings_option.schema.d.ts +2 -12
- package/dist/schemas/settings_option.schema.d.ts.map +1 -1
- package/dist/schemas/settings_option.schema.js +2 -6
- package/dist/schemas/settings_option.schema.js.map +1 -1
- package/dist/schemas/simple_rooms.schema.d.ts.map +1 -1
- package/dist/schemas/simple_rooms.schema.js.map +1 -1
- package/dist/schemas/tournament_many_tables_rooms.schema.d.ts.map +1 -1
- package/dist/schemas/tournament_many_tables_rooms.schema.js.map +1 -1
- package/dist/schemas/tournament_one_table_rooms.schema.d.ts.map +1 -1
- package/dist/schemas/tournament_one_table_rooms.schema.js.map +1 -1
- package/dist/schemas/user.fb.schema.d.ts.map +1 -1
- package/dist/schemas/user.fb.schema.js.map +1 -1
- package/dist/schemas/user.google.schema.d.ts.map +1 -1
- package/dist/schemas/user.google.schema.js.map +1 -1
- package/dist/schemas/user.ok.schema.d.ts +8 -8
- package/dist/schemas/user.ok.schema.d.ts.map +1 -1
- package/dist/schemas/user.ok.schema.js.map +1 -1
- package/dist/schemas/user.schema.d.ts.map +1 -1
- package/dist/schemas/user.schema.js +1 -1
- package/dist/schemas/user.schema.js.map +1 -1
- package/dist/schemas/user.tg.schema.d.ts.map +1 -1
- package/dist/schemas/user.tg.schema.js.map +1 -1
- package/dist/schemas/user.vk.schema.d.ts.map +1 -1
- package/dist/schemas/user.vk.schema.js.map +1 -1
- package/dist/schemas/user.ya.schema.d.ts.map +1 -1
- package/dist/schemas/user.ya.schema.js.map +1 -1
- package/dist/schemas/users_achievement.schema.d.ts.map +1 -1
- package/dist/schemas/users_achievement.schema.js.map +1 -1
- package/dist/schemas/users_balance.schema.d.ts.map +1 -1
- package/dist/schemas/users_balance.schema.js.map +1 -1
- package/dist/schemas/welcome.schema.d.ts +4 -16
- package/dist/schemas/welcome.schema.d.ts.map +1 -1
- package/dist/schemas/welcome.schema.js +4 -12
- package/dist/schemas/welcome.schema.js.map +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +11 -4
- package/src/index.ts +218 -188
- package/src/models/account-type.enum.ts +1 -1
- package/src/models/activity-log-user-login.interface.ts +9 -9
- package/src/models/activity-log.enum.ts +7 -7
- package/src/models/currency.enum.ts +5 -5
- package/src/models/rating-add-bulk-item.interface.ts +6 -6
- package/src/models/rating-monthly-result.interface.ts +10 -10
- package/src/models/tournament-participant.interface.ts +3 -3
- package/src/models/tournament-status.enum.ts +4 -4
- package/src/models/tournament-template.enum.ts +1 -1
- package/src/models/tournament-winner.interface.ts +5 -5
- package/src/models/users-balance-reason.enum.ts +7 -7
- package/src/repositories/achievement.repository.ts +7 -8
- package/src/repositories/activity-log.repository.ts +197 -112
- package/src/repositories/admin.repository.ts +7 -10
- package/src/repositories/article.repository.ts +9 -18
- package/src/repositories/banners.repository.ts +25 -25
- package/src/repositories/complains.repository.ts +10 -9
- package/src/repositories/daily-bonus.repository.ts +21 -15
- package/src/repositories/friend.repository.ts +14 -10
- package/src/repositories/game-result.repository.ts +9 -5
- package/src/repositories/game-statistic.repository.ts +14 -10
- package/src/repositories/index.ts +30 -30
- package/src/repositories/menu.repository.ts +8 -10
- package/src/repositories/notification.repository.ts +25 -20
- package/src/repositories/premium.repository.ts +7 -9
- package/src/repositories/products.repository.ts +18 -17
- package/src/repositories/purchase.repository.ts +93 -97
- package/src/repositories/rating.repository.ts +76 -70
- package/src/repositories/rooms.repository.ts +4 -7
- package/src/repositories/rule.repository.ts +5 -9
- package/src/repositories/scheduled-tournaments.repository.ts +12 -7
- package/src/repositories/servers.repository.ts +6 -8
- package/src/repositories/setting.repository.ts +14 -10
- package/src/repositories/settings-options.repository.ts +8 -9
- package/src/repositories/simple-rooms.repository.ts +6 -7
- package/src/repositories/tournament-many-tables-rooms.repository.ts +143 -118
- package/src/repositories/tournament-one-table-rooms.repository.ts +118 -96
- package/src/repositories/users-achievements.repository.ts +35 -32
- package/src/repositories/users-balances.repository.ts +51 -14
- package/src/repositories/users.repository.ts +137 -128
- package/src/repositories/welcome.repository.ts +7 -9
- package/src/schemas/achievement.schema.ts +22 -22
- package/src/schemas/activity_log.schema.ts +20 -20
- package/src/schemas/admin.schema.ts +10 -10
- package/src/schemas/article.schema.ts +20 -20
- package/src/schemas/banner.schema.ts +22 -22
- package/src/schemas/channel_message.schema.ts +18 -17
- package/src/schemas/complain.schema.ts +26 -26
- package/src/schemas/daily_bonus.schema.ts +29 -37
- package/src/schemas/feature.schema.ts +14 -14
- package/src/schemas/friend.schema.ts +29 -31
- package/src/schemas/game_result.schema.ts +41 -41
- package/src/schemas/game_statistic.schema.ts +22 -22
- package/src/schemas/menu.schema.ts +20 -23
- package/src/schemas/notification.schema.ts +36 -36
- package/src/schemas/premium.schema.ts +21 -30
- package/src/schemas/product.schema.ts +69 -87
- package/src/schemas/purchase.schema.ts +37 -37
- package/src/schemas/purchase_channel.schema.ts +18 -17
- package/src/schemas/rating.schema.ts +20 -20
- package/src/schemas/rooms.schema.ts +37 -37
- package/src/schemas/rule.schema.ts +21 -30
- package/src/schemas/scheduled_tournament.schema.ts +58 -57
- package/src/schemas/server.schema.ts +10 -10
- package/src/schemas/setting.schema.ts +28 -34
- package/src/schemas/settings_option.schema.ts +24 -26
- package/src/schemas/simple_rooms.schema.ts +28 -28
- package/src/schemas/tournament_many_tables_rooms.schema.ts +54 -51
- package/src/schemas/tournament_one_table_rooms.schema.ts +52 -49
- package/src/schemas/user.fb.schema.ts +16 -16
- package/src/schemas/user.google.schema.ts +10 -10
- package/src/schemas/user.ok.schema.ts +26 -25
- package/src/schemas/user.schema.ts +127 -125
- package/src/schemas/user.tg.schema.ts +14 -14
- package/src/schemas/user.vk.schema.ts +36 -36
- package/src/schemas/user.ya.schema.ts +10 -10
- package/src/schemas/users_achievement.schema.ts +24 -23
- package/src/schemas/users_balance.schema.ts +18 -18
- package/src/schemas/welcome.schema.ts +21 -30
- package/src/utils.ts +1 -1
|
@@ -9,116 +9,201 @@ import { IActivityLogUserLogin } from '../models/activity-log-user-login.interfa
|
|
|
9
9
|
|
|
10
10
|
@Injectable()
|
|
11
11
|
export class ActivityLogRepository {
|
|
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
|
-
|
|
12
|
+
constructor(
|
|
13
|
+
@InjectModel(ActivityLog.name)
|
|
14
|
+
private activityLogModel: Model<ActivityLogDocument>,
|
|
15
|
+
) {}
|
|
16
|
+
|
|
17
|
+
async findLast7DaysLogins(
|
|
18
|
+
game: string,
|
|
19
|
+
userId: string,
|
|
20
|
+
): Promise<Array<IActivityLogUserLogin>> {
|
|
21
|
+
const weekAgo = dayjs().startOf('day').add(-1, 'week');
|
|
22
|
+
|
|
23
|
+
return this.activityLogModel.aggregate([
|
|
24
|
+
{
|
|
25
|
+
$match: {
|
|
26
|
+
game,
|
|
27
|
+
userId,
|
|
28
|
+
date: { $gte: weekAgo.toDate() },
|
|
29
|
+
event: ActivityLogEnum.USER_LOGIN,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
$group: {
|
|
34
|
+
_id: { $dateToString: { format: '%Y-%m-%d', date: '$date' } },
|
|
35
|
+
userId: { $first: '$userId' },
|
|
36
|
+
userName: { $first: '$userName' },
|
|
37
|
+
event: { $first: '$event' },
|
|
38
|
+
game: { $first: '$game' },
|
|
39
|
+
channels: { $first: '$channels' },
|
|
40
|
+
count: { $sum: 1 },
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
$project: {
|
|
45
|
+
_id: 0,
|
|
46
|
+
id: '$_id',
|
|
47
|
+
userId: 1,
|
|
48
|
+
userName: 1,
|
|
49
|
+
event: 1,
|
|
50
|
+
game: 1,
|
|
51
|
+
channel: 1,
|
|
52
|
+
count: 1,
|
|
53
|
+
date: '$_id',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
$sort: { date: -1 },
|
|
58
|
+
},
|
|
59
|
+
]);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async userIsNewbie(userId: string): Promise<boolean> {
|
|
63
|
+
return (
|
|
64
|
+
(await this.activityLogModel
|
|
65
|
+
.countDocuments({ userId, event: ActivityLogEnum.USER_LOGIN })
|
|
66
|
+
.exec()) === 1
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async getUserPlayedGamesCount(userId: string): Promise<number> {
|
|
71
|
+
return await this.activityLogModel
|
|
72
|
+
.countDocuments({ userId, event: ActivityLogEnum.USER_PLAYED_GAME })
|
|
73
|
+
.exec();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async getUserWonGamesCount(userId: string): Promise<number> {
|
|
77
|
+
return await this.activityLogModel
|
|
78
|
+
.countDocuments({ userId, event: ActivityLogEnum.USER_WON_GAME })
|
|
79
|
+
.exec();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async getUserWonProfiCount(userId: string): Promise<number> {
|
|
83
|
+
return await this.activityLogModel
|
|
84
|
+
.countDocuments({ userId, event: ActivityLogEnum.USER_WON_PROFI })
|
|
85
|
+
.exec();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async getUserWonOneTableTournamentCount(userId: string): Promise<number> {
|
|
89
|
+
return await this.activityLogModel
|
|
90
|
+
.countDocuments({
|
|
91
|
+
userId,
|
|
92
|
+
event: ActivityLogEnum.USER_WON_ONE_TABLE_TOURNAMENT,
|
|
93
|
+
})
|
|
94
|
+
.exec();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
async getUserTodayBonus(userId: string): Promise<number> {
|
|
98
|
+
const log = await this.activityLogModel
|
|
99
|
+
.findOne({
|
|
100
|
+
userId,
|
|
101
|
+
event: ActivityLogEnum.USER_GOT_BONUS,
|
|
102
|
+
date: {
|
|
103
|
+
$gte: dayjs().startOf('day').toDate(),
|
|
104
|
+
$lte: dayjs().endOf('day').toDate(),
|
|
105
|
+
},
|
|
106
|
+
})
|
|
107
|
+
.exec();
|
|
108
|
+
|
|
109
|
+
return log?.amount ?? 0;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async addUserLoginEvent(
|
|
113
|
+
userId: string,
|
|
114
|
+
userName: string,
|
|
115
|
+
game: string,
|
|
116
|
+
channels: string,
|
|
117
|
+
): Promise<ActivityLog> {
|
|
118
|
+
return this.addActivityLog({
|
|
119
|
+
event: ActivityLogEnum.USER_LOGIN,
|
|
120
|
+
userId,
|
|
121
|
+
userName,
|
|
122
|
+
game,
|
|
123
|
+
channels,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async addUserGotBonuseEvent(
|
|
128
|
+
userId: string,
|
|
129
|
+
userName: string,
|
|
130
|
+
game: string,
|
|
131
|
+
channels: string,
|
|
132
|
+
amount: number,
|
|
133
|
+
): Promise<ActivityLog> {
|
|
134
|
+
return this.addActivityLog({
|
|
135
|
+
event: ActivityLogEnum.USER_GOT_BONUS,
|
|
136
|
+
userId,
|
|
137
|
+
userName,
|
|
138
|
+
game,
|
|
139
|
+
channels,
|
|
140
|
+
amount,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
async addUserPlayedGameEvent(
|
|
145
|
+
userId: string,
|
|
146
|
+
userName: string,
|
|
147
|
+
game: string,
|
|
148
|
+
channels: string,
|
|
149
|
+
): Promise<ActivityLog> {
|
|
150
|
+
return this.addActivityLog({
|
|
151
|
+
event: ActivityLogEnum.USER_PLAYED_GAME,
|
|
152
|
+
userId,
|
|
153
|
+
userName,
|
|
154
|
+
game,
|
|
155
|
+
channels,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
async addUserWonGameEvent(
|
|
160
|
+
userId: string,
|
|
161
|
+
userName: string,
|
|
162
|
+
game: string,
|
|
163
|
+
channels: string,
|
|
164
|
+
): Promise<ActivityLog> {
|
|
165
|
+
return this.addActivityLog({
|
|
166
|
+
event: ActivityLogEnum.USER_WON_GAME,
|
|
167
|
+
userId,
|
|
168
|
+
userName,
|
|
169
|
+
game,
|
|
170
|
+
channels,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
async addUserWonProfieEvent(
|
|
175
|
+
userId: string,
|
|
176
|
+
userName: string,
|
|
177
|
+
game: string,
|
|
178
|
+
channels: string,
|
|
179
|
+
): Promise<ActivityLog> {
|
|
180
|
+
return this.addActivityLog({
|
|
181
|
+
event: ActivityLogEnum.USER_WON_PROFI,
|
|
182
|
+
userId,
|
|
183
|
+
userName,
|
|
184
|
+
game,
|
|
185
|
+
channels,
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
async addUserWonOneTableTournamentEvent(
|
|
190
|
+
userId: string,
|
|
191
|
+
userName: string,
|
|
192
|
+
game: string,
|
|
193
|
+
channels: string,
|
|
194
|
+
): Promise<ActivityLog> {
|
|
195
|
+
return this.addActivityLog({
|
|
196
|
+
event: ActivityLogEnum.USER_WON_ONE_TABLE_TOURNAMENT,
|
|
197
|
+
userId,
|
|
198
|
+
userName,
|
|
199
|
+
game,
|
|
200
|
+
channels,
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
async addActivityLog(
|
|
205
|
+
activityLog: Partial<ActivityLog>,
|
|
206
|
+
): Promise<ActivityLog> {
|
|
207
|
+
return this.activityLogModel.create(activityLog);
|
|
208
|
+
}
|
|
123
209
|
}
|
|
124
|
-
|
|
@@ -6,18 +6,15 @@ import { Admin, AdminDocument } from '../';
|
|
|
6
6
|
|
|
7
7
|
@Injectable()
|
|
8
8
|
export class AdminRepository {
|
|
9
|
-
constructor
|
|
10
|
-
|
|
9
|
+
constructor(
|
|
10
|
+
@InjectModel(Admin.name) private adminModel: Model<AdminDocument>,
|
|
11
|
+
) {}
|
|
11
12
|
|
|
12
|
-
async findById
|
|
13
|
-
return this.adminModel
|
|
14
|
-
.findOne({ _id: id })
|
|
15
|
-
.exec();
|
|
13
|
+
async findById(id: string): Promise<Admin | null> {
|
|
14
|
+
return this.adminModel.findOne({ _id: id }).exec();
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
async findByLogin
|
|
19
|
-
return this.adminModel
|
|
20
|
-
.findOne({ login })
|
|
21
|
-
.exec();
|
|
17
|
+
async findByLogin(login: string): Promise<Admin | null> {
|
|
18
|
+
return this.adminModel.findOne({ login }).exec();
|
|
22
19
|
}
|
|
23
20
|
}
|
|
@@ -6,28 +6,19 @@ import { Article, ArticleDocument } from '../';
|
|
|
6
6
|
|
|
7
7
|
@Injectable()
|
|
8
8
|
export class ArticleRepository {
|
|
9
|
-
constructor
|
|
10
|
-
|
|
9
|
+
constructor(
|
|
10
|
+
@InjectModel(Article.name) private articleModel: Model<ArticleDocument>,
|
|
11
|
+
) {}
|
|
11
12
|
|
|
12
|
-
async findAllArticles
|
|
13
|
-
return this.articleModel
|
|
14
|
-
.find()
|
|
15
|
-
.sort({ createDate: -1 })
|
|
16
|
-
.exec();
|
|
13
|
+
async findAllArticles(): Promise<Array<Article>> {
|
|
14
|
+
return this.articleModel.find().sort({ createDate: -1 }).exec();
|
|
17
15
|
}
|
|
18
16
|
|
|
19
|
-
async findLastArticle
|
|
20
|
-
return await this.articleModel
|
|
21
|
-
.findOne()
|
|
22
|
-
.sort({ createDate: -1 })
|
|
23
|
-
.exec();
|
|
17
|
+
async findLastArticle(): Promise<Article | null> {
|
|
18
|
+
return await this.articleModel.findOne().sort({ createDate: -1 }).exec();
|
|
24
19
|
}
|
|
25
20
|
|
|
26
|
-
async findTop3Articles
|
|
27
|
-
return this.articleModel
|
|
28
|
-
.find()
|
|
29
|
-
.sort({ createDate: -1 })
|
|
30
|
-
.limit(3)
|
|
31
|
-
.exec();
|
|
21
|
+
async findTop3Articles(): Promise<Array<Article>> {
|
|
22
|
+
return this.articleModel.find().sort({ createDate: -1 }).limit(3).exec();
|
|
32
23
|
}
|
|
33
24
|
}
|
|
@@ -6,24 +6,27 @@ import { Banner, BannerDocument } from '../';
|
|
|
6
6
|
|
|
7
7
|
@Injectable()
|
|
8
8
|
export class BannersRepository {
|
|
9
|
-
constructor(
|
|
9
|
+
constructor(
|
|
10
|
+
@InjectModel(Banner.name) private bannerModel: Model<BannerDocument>,
|
|
11
|
+
) {}
|
|
12
|
+
|
|
13
|
+
async findEnabledBanner(
|
|
14
|
+
game: string,
|
|
15
|
+
channels: string,
|
|
16
|
+
): Promise<Banner | null> {
|
|
17
|
+
return this.bannerModel.findOne({ enabled: true }).exec();
|
|
10
18
|
}
|
|
11
19
|
|
|
12
|
-
async
|
|
13
|
-
return this.bannerModel
|
|
14
|
-
.findOne({ enabled: true })
|
|
15
|
-
.exec();
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
async findById (id: string): Promise<Banner | null> {
|
|
19
|
-
return this.bannerModel
|
|
20
|
-
.findById(id)
|
|
21
|
-
.exec();
|
|
20
|
+
async findById(id: string): Promise<Banner | null> {
|
|
21
|
+
return this.bannerModel.findById(id).exec();
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
async findAndCount
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
async findAndCount(
|
|
25
|
+
limit: number,
|
|
26
|
+
skip: number,
|
|
27
|
+
): Promise<{
|
|
28
|
+
items: Array<Banner>;
|
|
29
|
+
total: number;
|
|
27
30
|
}> {
|
|
28
31
|
const items = await this.bannerModel
|
|
29
32
|
.find()
|
|
@@ -32,29 +35,26 @@ export class BannersRepository {
|
|
|
32
35
|
.skip(skip)
|
|
33
36
|
.exec();
|
|
34
37
|
|
|
35
|
-
const total = await this.bannerModel
|
|
36
|
-
.find()
|
|
37
|
-
.countDocuments()
|
|
38
|
-
.exec();
|
|
38
|
+
const total = await this.bannerModel.find().countDocuments().exec();
|
|
39
39
|
|
|
40
40
|
return { items, total };
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
public async createBanner
|
|
43
|
+
public async createBanner(banner: Banner): Promise<Banner> {
|
|
44
44
|
return this.bannerModel.create(banner);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
async updateBanner
|
|
48
|
-
await this.bannerModel
|
|
49
|
-
bannerId,
|
|
50
|
-
{
|
|
47
|
+
async updateBanner(bannerId: string, banner: Partial<Banner>): Promise<void> {
|
|
48
|
+
await this.bannerModel
|
|
49
|
+
.findByIdAndUpdate(bannerId, {
|
|
51
50
|
$set: {
|
|
52
51
|
...banner,
|
|
53
52
|
},
|
|
54
|
-
})
|
|
53
|
+
})
|
|
54
|
+
.exec();
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
public async removeBanner
|
|
57
|
+
public async removeBanner(bannerId: string): Promise<void> {
|
|
58
58
|
await this.bannerModel.findByIdAndDelete(bannerId);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -6,12 +6,16 @@ import { Complain, ComplainDocument } from '../';
|
|
|
6
6
|
|
|
7
7
|
@Injectable()
|
|
8
8
|
export class ComplainsRepository {
|
|
9
|
-
constructor
|
|
10
|
-
|
|
9
|
+
constructor(
|
|
10
|
+
@InjectModel(Complain.name) private complainModel: Model<ComplainDocument>,
|
|
11
|
+
) {}
|
|
11
12
|
|
|
12
|
-
async findAndCount
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
async findAndCount(
|
|
14
|
+
limit: number,
|
|
15
|
+
skip: number,
|
|
16
|
+
): Promise<{
|
|
17
|
+
items: Array<Complain>;
|
|
18
|
+
total: number;
|
|
15
19
|
}> {
|
|
16
20
|
const items = await this.complainModel
|
|
17
21
|
.find()
|
|
@@ -20,10 +24,7 @@ export class ComplainsRepository {
|
|
|
20
24
|
.skip(skip)
|
|
21
25
|
.exec();
|
|
22
26
|
|
|
23
|
-
const total = await this.complainModel
|
|
24
|
-
.find()
|
|
25
|
-
.countDocuments()
|
|
26
|
-
.exec();
|
|
27
|
+
const total = await this.complainModel.find().countDocuments().exec();
|
|
27
28
|
|
|
28
29
|
return { items, total };
|
|
29
30
|
}
|
|
@@ -7,20 +7,26 @@ import { getChannelRegExpFilter } from '../utils';
|
|
|
7
7
|
|
|
8
8
|
@Injectable()
|
|
9
9
|
export class DailyBonusRepository {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
constructor(
|
|
11
|
+
@InjectModel(DailyBonus.name)
|
|
12
|
+
private dailyBonusModel: Model<DailyBonusDocument>,
|
|
13
|
+
) {}
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
async findDailyBonuses(
|
|
16
|
+
channel: string,
|
|
17
|
+
game: string,
|
|
18
|
+
): Promise<Array<DailyBonus> | null> {
|
|
19
|
+
return this.dailyBonusModel
|
|
20
|
+
.find({
|
|
21
|
+
channels: getChannelRegExpFilter(channel),
|
|
22
|
+
})
|
|
23
|
+
.exec();
|
|
24
|
+
}
|
|
20
25
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
}
|
|
26
|
+
async findDailyBonusByDay(
|
|
27
|
+
day: number,
|
|
28
|
+
game: string,
|
|
29
|
+
): Promise<DailyBonus | null> {
|
|
30
|
+
return this.dailyBonusModel.findOne({ game, position: day }).exec();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -7,14 +7,18 @@ import { getChannelRegExpFilter } from '../utils';
|
|
|
7
7
|
|
|
8
8
|
@Injectable()
|
|
9
9
|
export class FriendRepository {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
constructor(
|
|
11
|
+
@InjectModel(Friend.name) private friendModel: Model<FriendDocument>,
|
|
12
|
+
) {}
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
14
|
+
async findFriend(
|
|
15
|
+
channel: string,
|
|
16
|
+
game: string,
|
|
17
|
+
): Promise<Array<Friend> | null> {
|
|
18
|
+
return this.friendModel
|
|
19
|
+
.find({
|
|
20
|
+
channels: getChannelRegExpFilter(channel),
|
|
21
|
+
})
|
|
22
|
+
.exec();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -6,10 +6,14 @@ import { GameResult, GameResultDocument } from '../';
|
|
|
6
6
|
|
|
7
7
|
@Injectable()
|
|
8
8
|
export class GameResultRepository {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
constructor(
|
|
10
|
+
@InjectModel(GameResult.name)
|
|
11
|
+
private gameResultModel: Model<GameResultDocument>,
|
|
12
|
+
) {}
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
public async createGameResult(
|
|
15
|
+
gameResult: Partial<GameResult>,
|
|
16
|
+
): Promise<GameResult> {
|
|
17
|
+
return this.gameResultModel.create(gameResult);
|
|
18
|
+
}
|
|
15
19
|
}
|
|
@@ -7,15 +7,19 @@ import { getChannelRegExpFilter } from '../utils';
|
|
|
7
7
|
|
|
8
8
|
@Injectable()
|
|
9
9
|
export class GameStatisticRepository {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
constructor(
|
|
11
|
+
@InjectModel(GameStatistic.name)
|
|
12
|
+
private gameStatisticModel: Model<GameStatisticDocument>,
|
|
13
|
+
) {}
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
async findGameStatistic(
|
|
16
|
+
channel: string,
|
|
17
|
+
game: string,
|
|
18
|
+
): Promise<Array<GameStatistic> | null> {
|
|
19
|
+
return this.gameStatisticModel
|
|
20
|
+
.find({
|
|
21
|
+
channels: getChannelRegExpFilter(channel),
|
|
22
|
+
})
|
|
23
|
+
.exec();
|
|
24
|
+
}
|
|
20
25
|
}
|
|
21
|
-
|