ballrush-core 0.4.2 → 0.5.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/dist/domain/group.d.ts +4 -0
- package/dist/domain/group.js +7 -2
- package/dist/domain/index.d.ts +1 -0
- package/dist/domain/index.js +1 -0
- package/dist/domain/stat-group.d.ts +26 -0
- package/dist/domain/stat-group.js +35 -0
- package/dist/mongo/index.d.ts +5 -0
- package/dist/mongo/index.js +5 -0
- package/dist/mongo/schemas/group.schema.d.ts +3 -0
- package/dist/mongo/schemas/group.schema.js +3 -0
- package/dist/mongo/schemas/stat-group-activity-chart.schema.d.ts +27 -0
- package/dist/mongo/schemas/stat-group-activity-chart.schema.js +27 -0
- package/dist/mongo/schemas/stat-group-last-100-games.schema.d.ts +33 -0
- package/dist/mongo/schemas/stat-group-last-100-games.schema.js +31 -0
- package/dist/mongo/schemas/stat-group-profile.schema.d.ts +27 -0
- package/dist/mongo/schemas/stat-group-profile.schema.js +29 -0
- package/dist/mongo/schemas/stat-group-season.schema.d.ts +37 -0
- package/dist/mongo/schemas/stat-group-season.schema.js +39 -0
- package/dist/mongo/schemas/stat-group.schema.d.ts +15 -0
- package/dist/mongo/schemas/stat-group.schema.js +19 -0
- package/dist/ports/groups.repository.d.ts +1 -0
- package/dist/ports/index.d.ts +5 -0
- package/dist/ports/index.js +5 -0
- package/dist/ports/stat-group-activity-chart.repository.d.ts +14 -0
- package/dist/ports/stat-group-activity-chart.repository.js +2 -0
- package/dist/ports/stat-group-last-100-games.repository.d.ts +13 -0
- package/dist/ports/stat-group-last-100-games.repository.js +2 -0
- package/dist/ports/stat-group-profile.repository.d.ts +14 -0
- package/dist/ports/stat-group-profile.repository.js +2 -0
- package/dist/ports/stat-group-season.repository.d.ts +14 -0
- package/dist/ports/stat-group-season.repository.js +2 -0
- package/dist/ports/stat-group.repository.d.ts +41 -0
- package/dist/ports/stat-group.repository.js +2 -0
- package/dist/repositories/index.d.ts +5 -0
- package/dist/repositories/index.js +5 -0
- package/dist/repositories/mongo/group.mapper.js +2 -0
- package/dist/repositories/mongo/stat-group-activity-chart.repository.d.ts +13 -0
- package/dist/repositories/mongo/stat-group-activity-chart.repository.js +46 -0
- package/dist/repositories/mongo/stat-group-last-100-games.repository.d.ts +13 -0
- package/dist/repositories/mongo/stat-group-last-100-games.repository.js +49 -0
- package/dist/repositories/mongo/stat-group-profile.repository.d.ts +13 -0
- package/dist/repositories/mongo/stat-group-profile.repository.js +47 -0
- package/dist/repositories/mongo/stat-group-season.repository.d.ts +13 -0
- package/dist/repositories/mongo/stat-group-season.repository.js +54 -0
- package/dist/repositories/mongo/stat-group.mapper.d.ts +4 -0
- package/dist/repositories/mongo/stat-group.mapper.js +27 -0
- package/dist/repositories/mongo/stat-group.repository.d.ts +13 -0
- package/dist/repositories/mongo/stat-group.repository.js +165 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.js +4 -0
- package/dist/types/stat-group-activity-chart.types.d.ts +15 -0
- package/dist/types/stat-group-activity-chart.types.js +6 -0
- package/dist/types/stat-group-last-100-games.types.d.ts +21 -0
- package/dist/types/stat-group-last-100-games.types.js +6 -0
- package/dist/types/stat-group-profile.types.d.ts +19 -0
- package/dist/types/stat-group-profile.types.js +6 -0
- package/dist/types/stat-group-season.types.d.ts +25 -0
- package/dist/types/stat-group-season.types.js +6 -0
- package/package.json +1 -1
package/dist/domain/group.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export declare class Group {
|
|
|
6
6
|
private timezone;
|
|
7
7
|
private isMessageLast;
|
|
8
8
|
private language;
|
|
9
|
+
private isPublic;
|
|
9
10
|
private constructor();
|
|
10
11
|
static create(params: {
|
|
11
12
|
groupId: number;
|
|
@@ -14,6 +15,7 @@ export declare class Group {
|
|
|
14
15
|
timezone?: string;
|
|
15
16
|
isMessageLast?: boolean;
|
|
16
17
|
language?: LanguageType;
|
|
18
|
+
isPublic?: boolean;
|
|
17
19
|
}): Group;
|
|
18
20
|
getGroupId(): number;
|
|
19
21
|
getGroupName(): string;
|
|
@@ -21,11 +23,13 @@ export declare class Group {
|
|
|
21
23
|
getIsMessageLast(): boolean;
|
|
22
24
|
getLanguage(): LanguageType;
|
|
23
25
|
getParticipants(): ParticipantGroup[];
|
|
26
|
+
getIsPublic(): boolean;
|
|
24
27
|
getAdmins(): ParticipantGroup[];
|
|
25
28
|
getAdminIds(): number[];
|
|
26
29
|
setTimezone(tz: string): void;
|
|
27
30
|
setIsMessageLast(v: boolean): void;
|
|
28
31
|
setLanguage(language: LanguageType): void;
|
|
32
|
+
setIsPublic(value: boolean): void;
|
|
29
33
|
addAdmin(userId: number): void;
|
|
30
34
|
removeAdmin(userId: number): void;
|
|
31
35
|
addNewParticipant(userId: number, isAdmin?: boolean, initialRating?: number): boolean;
|
package/dist/domain/group.js
CHANGED
|
@@ -4,18 +4,19 @@ exports.Group = void 0;
|
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
6
|
class Group {
|
|
7
|
-
constructor(groupId, groupName, participants, timezone = "UTC+0", isMessageLast = false, language = "en") {
|
|
7
|
+
constructor(groupId, groupName, participants, timezone = "UTC+0", isMessageLast = false, language = "en", isPublic = false) {
|
|
8
8
|
this.groupId = groupId;
|
|
9
9
|
this.groupName = groupName;
|
|
10
10
|
this.participants = participants;
|
|
11
11
|
this.timezone = timezone;
|
|
12
12
|
this.isMessageLast = isMessageLast;
|
|
13
13
|
this.language = language;
|
|
14
|
+
this.isPublic = isPublic;
|
|
14
15
|
}
|
|
15
16
|
static create(params) {
|
|
16
17
|
if (!params.groupName)
|
|
17
18
|
throw new Error("Group name is required");
|
|
18
|
-
return new Group(params.groupId, params.groupName, (params.participants ?? []).map(p => ({ ...p, ratingHistory: [...p.ratingHistory] })), params.timezone ?? "UTC+0", params.isMessageLast ?? false, params.language ?? "en");
|
|
19
|
+
return new Group(params.groupId, params.groupName, (params.participants ?? []).map(p => ({ ...p, ratingHistory: [...p.ratingHistory] })), params.timezone ?? "UTC+0", params.isMessageLast ?? false, params.language ?? "en", params.isPublic ?? false);
|
|
19
20
|
}
|
|
20
21
|
getGroupId() { return this.groupId; }
|
|
21
22
|
getGroupName() { return this.groupName; }
|
|
@@ -23,6 +24,7 @@ class Group {
|
|
|
23
24
|
getIsMessageLast() { return this.isMessageLast; }
|
|
24
25
|
getLanguage() { return this.language; }
|
|
25
26
|
getParticipants() { return this.participants; }
|
|
27
|
+
getIsPublic() { return this.isPublic; }
|
|
26
28
|
getAdmins() {
|
|
27
29
|
return this.participants.filter(p => p.isAdmin);
|
|
28
30
|
}
|
|
@@ -38,6 +40,9 @@ class Group {
|
|
|
38
40
|
setLanguage(language) {
|
|
39
41
|
this.language = language;
|
|
40
42
|
}
|
|
43
|
+
setIsPublic(value) {
|
|
44
|
+
this.isPublic = value;
|
|
45
|
+
}
|
|
41
46
|
addAdmin(userId) {
|
|
42
47
|
const p = this.participants.find(x => x.userId === userId);
|
|
43
48
|
if (p) {
|
package/dist/domain/index.d.ts
CHANGED
package/dist/domain/index.js
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare class StatGroup {
|
|
2
|
+
private readonly groupId;
|
|
3
|
+
private readonly groupName;
|
|
4
|
+
private readonly seasonsCount;
|
|
5
|
+
private readonly eventsCount;
|
|
6
|
+
private readonly matchesCount;
|
|
7
|
+
private readonly participantsCount;
|
|
8
|
+
private readonly updatedAt;
|
|
9
|
+
private constructor();
|
|
10
|
+
static create(params: {
|
|
11
|
+
groupId: number;
|
|
12
|
+
groupName: string;
|
|
13
|
+
seasonsCount: number;
|
|
14
|
+
eventsCount: number;
|
|
15
|
+
matchesCount: number;
|
|
16
|
+
participantsCount: number;
|
|
17
|
+
updatedAt?: Date;
|
|
18
|
+
}): StatGroup;
|
|
19
|
+
getGroupId(): number;
|
|
20
|
+
getGroupName(): string;
|
|
21
|
+
getSeasonsCount(): number;
|
|
22
|
+
getEventsCount(): number;
|
|
23
|
+
getMatchesCount(): number;
|
|
24
|
+
getParticipantsCount(): number;
|
|
25
|
+
getUpdatedAt(): Date;
|
|
26
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StatGroup = void 0;
|
|
4
|
+
class StatGroup {
|
|
5
|
+
constructor(groupId, groupName, seasonsCount, eventsCount, matchesCount, participantsCount, updatedAt) {
|
|
6
|
+
this.groupId = groupId;
|
|
7
|
+
this.groupName = groupName;
|
|
8
|
+
this.seasonsCount = seasonsCount;
|
|
9
|
+
this.eventsCount = eventsCount;
|
|
10
|
+
this.matchesCount = matchesCount;
|
|
11
|
+
this.participantsCount = participantsCount;
|
|
12
|
+
this.updatedAt = updatedAt;
|
|
13
|
+
}
|
|
14
|
+
static create(params) {
|
|
15
|
+
if (!params.groupName)
|
|
16
|
+
throw new Error("Group name is required");
|
|
17
|
+
if (params.seasonsCount < 0)
|
|
18
|
+
throw new Error("Seasons count cannot be negative");
|
|
19
|
+
if (params.eventsCount < 0)
|
|
20
|
+
throw new Error("Events count cannot be negative");
|
|
21
|
+
if (params.matchesCount < 0)
|
|
22
|
+
throw new Error("Matches count cannot be negative");
|
|
23
|
+
if (params.participantsCount < 0)
|
|
24
|
+
throw new Error("Participants count cannot be negative");
|
|
25
|
+
return new StatGroup(params.groupId, params.groupName, params.seasonsCount, params.eventsCount, params.matchesCount, params.participantsCount, params.updatedAt ?? new Date());
|
|
26
|
+
}
|
|
27
|
+
getGroupId() { return this.groupId; }
|
|
28
|
+
getGroupName() { return this.groupName; }
|
|
29
|
+
getSeasonsCount() { return this.seasonsCount; }
|
|
30
|
+
getEventsCount() { return this.eventsCount; }
|
|
31
|
+
getMatchesCount() { return this.matchesCount; }
|
|
32
|
+
getParticipantsCount() { return this.participantsCount; }
|
|
33
|
+
getUpdatedAt() { return this.updatedAt; }
|
|
34
|
+
}
|
|
35
|
+
exports.StatGroup = StatGroup;
|
package/dist/mongo/index.d.ts
CHANGED
|
@@ -2,3 +2,8 @@ export * from "./schemas/user.schema";
|
|
|
2
2
|
export * from "./schemas/event-template.schema";
|
|
3
3
|
export * from "./schemas/event.schema";
|
|
4
4
|
export * from "./schemas/group.schema";
|
|
5
|
+
export * from "./schemas/stat-group.schema";
|
|
6
|
+
export * from "./schemas/stat-group-profile.schema";
|
|
7
|
+
export * from "./schemas/stat-group-season.schema";
|
|
8
|
+
export * from "./schemas/stat-group-last-100-games.schema";
|
|
9
|
+
export * from "./schemas/stat-group-activity-chart.schema";
|
package/dist/mongo/index.js
CHANGED
|
@@ -18,3 +18,8 @@ __exportStar(require("./schemas/user.schema"), exports);
|
|
|
18
18
|
__exportStar(require("./schemas/event-template.schema"), exports);
|
|
19
19
|
__exportStar(require("./schemas/event.schema"), exports);
|
|
20
20
|
__exportStar(require("./schemas/group.schema"), exports);
|
|
21
|
+
__exportStar(require("./schemas/stat-group.schema"), exports);
|
|
22
|
+
__exportStar(require("./schemas/stat-group-profile.schema"), exports);
|
|
23
|
+
__exportStar(require("./schemas/stat-group-season.schema"), exports);
|
|
24
|
+
__exportStar(require("./schemas/stat-group-last-100-games.schema"), exports);
|
|
25
|
+
__exportStar(require("./schemas/stat-group-activity-chart.schema"), exports);
|
|
@@ -7,6 +7,9 @@ export interface GroupDoc {
|
|
|
7
7
|
timezone: string;
|
|
8
8
|
isMessageLast: boolean;
|
|
9
9
|
language: LanguageType;
|
|
10
|
+
isPublic?: boolean;
|
|
11
|
+
createdAt?: Date;
|
|
12
|
+
updatedAt?: Date;
|
|
10
13
|
}
|
|
11
14
|
export declare function createRatingPointSchema(): Schema<RatingPoint, import("mongoose").Model<RatingPoint, any, any, any, import("mongoose").Document<unknown, any, RatingPoint> & RatingPoint & {
|
|
12
15
|
_id: import("mongoose").Types.ObjectId;
|
|
@@ -30,6 +30,9 @@ function createGroupSchema() {
|
|
|
30
30
|
timezone: { type: String, default: "UTC+0" },
|
|
31
31
|
isMessageLast: { type: Boolean, default: false },
|
|
32
32
|
language: { type: String, enum: ['en', 'ru', 'ua'], default: 'en' },
|
|
33
|
+
isPublic: { type: Boolean, default: false, index: true },
|
|
34
|
+
}, {
|
|
35
|
+
timestamps: true, // Adds createdAt and updatedAt automatically
|
|
33
36
|
});
|
|
34
37
|
return GroupSchema;
|
|
35
38
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Schema } from "mongoose";
|
|
2
|
+
/**
|
|
3
|
+
* Mongoose document interface for StatGroupActivityChart data point
|
|
4
|
+
*/
|
|
5
|
+
export interface StatGroupActivityDataPointDoc {
|
|
6
|
+
monthYear: string;
|
|
7
|
+
displayName: string;
|
|
8
|
+
matches: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Mongoose document interface for StatGroupActivityChart
|
|
12
|
+
*/
|
|
13
|
+
export interface StatGroupActivityChartDoc {
|
|
14
|
+
groupId: number;
|
|
15
|
+
timespan: 6 | 12;
|
|
16
|
+
data: StatGroupActivityDataPointDoc[];
|
|
17
|
+
updatedAt: Date;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Factory function to create StatGroupActivityChart schema
|
|
21
|
+
* Collection: stat_group_activity_charts
|
|
22
|
+
*/
|
|
23
|
+
export declare function createStatGroupActivityChartSchema(): Schema<StatGroupActivityChartDoc, import("mongoose").Model<StatGroupActivityChartDoc, any, any, any, import("mongoose").Document<unknown, any, StatGroupActivityChartDoc> & StatGroupActivityChartDoc & {
|
|
24
|
+
_id: import("mongoose").Types.ObjectId;
|
|
25
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, StatGroupActivityChartDoc, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<StatGroupActivityChartDoc>> & import("mongoose").FlatRecord<StatGroupActivityChartDoc> & {
|
|
26
|
+
_id: import("mongoose").Types.ObjectId;
|
|
27
|
+
}>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createStatGroupActivityChartSchema = createStatGroupActivityChartSchema;
|
|
4
|
+
const mongoose_1 = require("mongoose");
|
|
5
|
+
/**
|
|
6
|
+
* Factory function to create StatGroupActivityChart schema
|
|
7
|
+
* Collection: stat_group_activity_charts
|
|
8
|
+
*/
|
|
9
|
+
function createStatGroupActivityChartSchema() {
|
|
10
|
+
const DataPointSchema = new mongoose_1.Schema({
|
|
11
|
+
monthYear: { type: String, required: true }, // Format: "2024-10"
|
|
12
|
+
displayName: { type: String, required: true }, // Format: "Oct 2024"
|
|
13
|
+
matches: { type: Number, required: true, min: 0, default: 0 },
|
|
14
|
+
}, { _id: false });
|
|
15
|
+
const StatGroupActivityChartSchema = new mongoose_1.Schema({
|
|
16
|
+
groupId: { type: Number, required: true, index: true },
|
|
17
|
+
timespan: { type: Number, enum: [6, 12], required: true },
|
|
18
|
+
data: { type: [DataPointSchema], default: [] },
|
|
19
|
+
updatedAt: { type: Date, default: Date.now },
|
|
20
|
+
}, {
|
|
21
|
+
collection: 'stat_group_activity_charts',
|
|
22
|
+
versionKey: false,
|
|
23
|
+
});
|
|
24
|
+
// Composite unique index for groupId + timespan
|
|
25
|
+
StatGroupActivityChartSchema.index({ groupId: 1, timespan: 1 }, { unique: true });
|
|
26
|
+
return StatGroupActivityChartSchema;
|
|
27
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Schema } from "mongoose";
|
|
2
|
+
/**
|
|
3
|
+
* Mongoose document interface for StatGroupLast100Games player
|
|
4
|
+
*/
|
|
5
|
+
export interface StatGroupLast100GamesPlayerDoc {
|
|
6
|
+
userId: number;
|
|
7
|
+
playerName: string;
|
|
8
|
+
skillRating: number;
|
|
9
|
+
games: number;
|
|
10
|
+
wins: number;
|
|
11
|
+
draws: number;
|
|
12
|
+
losses: number;
|
|
13
|
+
winPercentage: number;
|
|
14
|
+
achievementsCount: number;
|
|
15
|
+
score: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Mongoose document interface for StatGroupLast100Games
|
|
19
|
+
*/
|
|
20
|
+
export interface StatGroupLast100GamesDoc {
|
|
21
|
+
groupId: number;
|
|
22
|
+
players: StatGroupLast100GamesPlayerDoc[];
|
|
23
|
+
updatedAt: Date;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Factory function to create StatGroupLast100Games schema
|
|
27
|
+
* Collection: stat_group_last_100_games
|
|
28
|
+
*/
|
|
29
|
+
export declare function createStatGroupLast100GamesSchema(): Schema<StatGroupLast100GamesDoc, import("mongoose").Model<StatGroupLast100GamesDoc, any, any, any, import("mongoose").Document<unknown, any, StatGroupLast100GamesDoc> & StatGroupLast100GamesDoc & {
|
|
30
|
+
_id: import("mongoose").Types.ObjectId;
|
|
31
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, StatGroupLast100GamesDoc, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<StatGroupLast100GamesDoc>> & import("mongoose").FlatRecord<StatGroupLast100GamesDoc> & {
|
|
32
|
+
_id: import("mongoose").Types.ObjectId;
|
|
33
|
+
}>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createStatGroupLast100GamesSchema = createStatGroupLast100GamesSchema;
|
|
4
|
+
const mongoose_1 = require("mongoose");
|
|
5
|
+
/**
|
|
6
|
+
* Factory function to create StatGroupLast100Games schema
|
|
7
|
+
* Collection: stat_group_last_100_games
|
|
8
|
+
*/
|
|
9
|
+
function createStatGroupLast100GamesSchema() {
|
|
10
|
+
const PlayerSchema = new mongoose_1.Schema({
|
|
11
|
+
userId: { type: Number, required: true },
|
|
12
|
+
playerName: { type: String, required: true },
|
|
13
|
+
skillRating: { type: Number, required: true, min: 0, default: 0 },
|
|
14
|
+
games: { type: Number, required: true, min: 0, max: 100, default: 0 },
|
|
15
|
+
wins: { type: Number, required: true, min: 0, default: 0 },
|
|
16
|
+
draws: { type: Number, required: true, min: 0, default: 0 },
|
|
17
|
+
losses: { type: Number, required: true, min: 0, default: 0 },
|
|
18
|
+
winPercentage: { type: Number, required: true, min: 0, max: 100, default: 0 },
|
|
19
|
+
achievementsCount: { type: Number, required: true, min: 0, default: 0 },
|
|
20
|
+
score: { type: Number, required: true, min: 0, default: 0 },
|
|
21
|
+
}, { _id: false });
|
|
22
|
+
const StatGroupLast100GamesSchema = new mongoose_1.Schema({
|
|
23
|
+
groupId: { type: Number, required: true, unique: true, index: true },
|
|
24
|
+
players: { type: [PlayerSchema], default: [] },
|
|
25
|
+
updatedAt: { type: Date, default: Date.now },
|
|
26
|
+
}, {
|
|
27
|
+
collection: 'stat_group_last_100_games',
|
|
28
|
+
versionKey: false,
|
|
29
|
+
});
|
|
30
|
+
return StatGroupLast100GamesSchema;
|
|
31
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Schema } from "mongoose";
|
|
2
|
+
/**
|
|
3
|
+
* Mongoose document interface for StatGroupProfile
|
|
4
|
+
*/
|
|
5
|
+
export interface StatGroupProfileDoc {
|
|
6
|
+
groupId: number;
|
|
7
|
+
groupName: string;
|
|
8
|
+
establishedDate: Date;
|
|
9
|
+
totalMembers: number;
|
|
10
|
+
activePlayers: number;
|
|
11
|
+
totalGames: number;
|
|
12
|
+
averageSkillRating: number;
|
|
13
|
+
currentSeason: {
|
|
14
|
+
seasonName: string;
|
|
15
|
+
status: 'in_progress' | 'completed';
|
|
16
|
+
} | null;
|
|
17
|
+
updatedAt: Date;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Factory function to create StatGroupProfile schema
|
|
21
|
+
* Collection: stat_group_profiles
|
|
22
|
+
*/
|
|
23
|
+
export declare function createStatGroupProfileSchema(): Schema<StatGroupProfileDoc, import("mongoose").Model<StatGroupProfileDoc, any, any, any, import("mongoose").Document<unknown, any, StatGroupProfileDoc> & StatGroupProfileDoc & {
|
|
24
|
+
_id: import("mongoose").Types.ObjectId;
|
|
25
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, StatGroupProfileDoc, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<StatGroupProfileDoc>> & import("mongoose").FlatRecord<StatGroupProfileDoc> & {
|
|
26
|
+
_id: import("mongoose").Types.ObjectId;
|
|
27
|
+
}>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createStatGroupProfileSchema = createStatGroupProfileSchema;
|
|
4
|
+
const mongoose_1 = require("mongoose");
|
|
5
|
+
/**
|
|
6
|
+
* Factory function to create StatGroupProfile schema
|
|
7
|
+
* Collection: stat_group_profiles
|
|
8
|
+
*/
|
|
9
|
+
function createStatGroupProfileSchema() {
|
|
10
|
+
const CurrentSeasonSchema = new mongoose_1.Schema({
|
|
11
|
+
seasonName: { type: String, required: true },
|
|
12
|
+
status: { type: String, enum: ['in_progress', 'completed'], required: true },
|
|
13
|
+
}, { _id: false });
|
|
14
|
+
const StatGroupProfileSchema = new mongoose_1.Schema({
|
|
15
|
+
groupId: { type: Number, required: true, unique: true, index: true },
|
|
16
|
+
groupName: { type: String, required: true },
|
|
17
|
+
establishedDate: { type: Date, required: true },
|
|
18
|
+
totalMembers: { type: Number, required: true, min: 0, default: 0 },
|
|
19
|
+
activePlayers: { type: Number, required: true, min: 0, default: 0 },
|
|
20
|
+
totalGames: { type: Number, required: true, min: 0, default: 0 },
|
|
21
|
+
averageSkillRating: { type: Number, required: true, min: 0, default: 0 },
|
|
22
|
+
currentSeason: { type: CurrentSeasonSchema, default: null },
|
|
23
|
+
updatedAt: { type: Date, default: Date.now },
|
|
24
|
+
}, {
|
|
25
|
+
collection: 'stat_group_profiles',
|
|
26
|
+
versionKey: false,
|
|
27
|
+
});
|
|
28
|
+
return StatGroupProfileSchema;
|
|
29
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Schema } from "mongoose";
|
|
2
|
+
/**
|
|
3
|
+
* Mongoose document interface for StatGroupSeason participant
|
|
4
|
+
*/
|
|
5
|
+
export interface StatGroupSeasonParticipantDoc {
|
|
6
|
+
userId: number;
|
|
7
|
+
playerName: string;
|
|
8
|
+
achievementsCount: number;
|
|
9
|
+
games: number;
|
|
10
|
+
wins: number;
|
|
11
|
+
losses: number;
|
|
12
|
+
draws: number;
|
|
13
|
+
winPercentage: number;
|
|
14
|
+
skillRating: number;
|
|
15
|
+
score: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Mongoose document interface for StatGroupSeason
|
|
19
|
+
*/
|
|
20
|
+
export interface StatGroupSeasonDoc {
|
|
21
|
+
groupId: number;
|
|
22
|
+
seasonName: string;
|
|
23
|
+
participants: StatGroupSeasonParticipantDoc[];
|
|
24
|
+
startDate: Date;
|
|
25
|
+
endDate: Date | null;
|
|
26
|
+
status: 'in_progress' | 'completed';
|
|
27
|
+
updatedAt: Date;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Factory function to create StatGroupSeason schema
|
|
31
|
+
* Collection: stat_group_seasons
|
|
32
|
+
*/
|
|
33
|
+
export declare function createStatGroupSeasonSchema(): Schema<StatGroupSeasonDoc, import("mongoose").Model<StatGroupSeasonDoc, any, any, any, import("mongoose").Document<unknown, any, StatGroupSeasonDoc> & StatGroupSeasonDoc & {
|
|
34
|
+
_id: import("mongoose").Types.ObjectId;
|
|
35
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, StatGroupSeasonDoc, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<StatGroupSeasonDoc>> & import("mongoose").FlatRecord<StatGroupSeasonDoc> & {
|
|
36
|
+
_id: import("mongoose").Types.ObjectId;
|
|
37
|
+
}>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createStatGroupSeasonSchema = createStatGroupSeasonSchema;
|
|
4
|
+
const mongoose_1 = require("mongoose");
|
|
5
|
+
/**
|
|
6
|
+
* Factory function to create StatGroupSeason schema
|
|
7
|
+
* Collection: stat_group_seasons
|
|
8
|
+
*/
|
|
9
|
+
function createStatGroupSeasonSchema() {
|
|
10
|
+
const ParticipantSchema = new mongoose_1.Schema({
|
|
11
|
+
userId: { type: Number, required: true },
|
|
12
|
+
playerName: { type: String, required: true },
|
|
13
|
+
achievementsCount: { type: Number, required: true, min: 0, default: 0 },
|
|
14
|
+
games: { type: Number, required: true, min: 0, default: 0 },
|
|
15
|
+
wins: { type: Number, required: true, min: 0, default: 0 },
|
|
16
|
+
losses: { type: Number, required: true, min: 0, default: 0 },
|
|
17
|
+
draws: { type: Number, required: true, min: 0, default: 0 },
|
|
18
|
+
winPercentage: { type: Number, required: true, min: 0, max: 100, default: 0 },
|
|
19
|
+
skillRating: { type: Number, required: true, min: 0, default: 0 },
|
|
20
|
+
score: { type: Number, required: true, min: 0, default: 0 },
|
|
21
|
+
}, { _id: false });
|
|
22
|
+
const StatGroupSeasonSchema = new mongoose_1.Schema({
|
|
23
|
+
groupId: { type: Number, required: true, index: true },
|
|
24
|
+
seasonName: { type: String, required: true },
|
|
25
|
+
participants: { type: [ParticipantSchema], default: [] },
|
|
26
|
+
startDate: { type: Date, required: true },
|
|
27
|
+
endDate: { type: Date, default: null },
|
|
28
|
+
status: { type: String, enum: ['in_progress', 'completed'], required: true },
|
|
29
|
+
updatedAt: { type: Date, default: Date.now },
|
|
30
|
+
}, {
|
|
31
|
+
collection: 'stat_group_seasons',
|
|
32
|
+
versionKey: false,
|
|
33
|
+
});
|
|
34
|
+
// Composite unique index for groupId + seasonName
|
|
35
|
+
StatGroupSeasonSchema.index({ groupId: 1, seasonName: 1 }, { unique: true });
|
|
36
|
+
// Index for listing seasons by group (newest first will be done in query)
|
|
37
|
+
StatGroupSeasonSchema.index({ groupId: 1, updatedAt: -1 });
|
|
38
|
+
return StatGroupSeasonSchema;
|
|
39
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Schema } from "mongoose";
|
|
2
|
+
export interface StatGroupDoc {
|
|
3
|
+
groupId: number;
|
|
4
|
+
groupName: string;
|
|
5
|
+
seasonsCount: number;
|
|
6
|
+
eventsCount: number;
|
|
7
|
+
matchesCount: number;
|
|
8
|
+
participantsCount: number;
|
|
9
|
+
updatedAt: Date;
|
|
10
|
+
}
|
|
11
|
+
export declare function createStatGroupSchema(): Schema<StatGroupDoc, import("mongoose").Model<StatGroupDoc, any, any, any, import("mongoose").Document<unknown, any, StatGroupDoc> & StatGroupDoc & {
|
|
12
|
+
_id: import("mongoose").Types.ObjectId;
|
|
13
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, StatGroupDoc, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<StatGroupDoc>> & import("mongoose").FlatRecord<StatGroupDoc> & {
|
|
14
|
+
_id: import("mongoose").Types.ObjectId;
|
|
15
|
+
}>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createStatGroupSchema = createStatGroupSchema;
|
|
4
|
+
const mongoose_1 = require("mongoose");
|
|
5
|
+
function createStatGroupSchema() {
|
|
6
|
+
const StatGroupSchema = new mongoose_1.Schema({
|
|
7
|
+
groupId: { type: Number, required: true, unique: true, index: true },
|
|
8
|
+
groupName: { type: String, required: true },
|
|
9
|
+
seasonsCount: { type: Number, required: true, min: 0 },
|
|
10
|
+
eventsCount: { type: Number, required: true, min: 0 },
|
|
11
|
+
matchesCount: { type: Number, required: true, min: 0 },
|
|
12
|
+
participantsCount: { type: Number, required: true, min: 0 },
|
|
13
|
+
updatedAt: { type: Date, default: Date.now },
|
|
14
|
+
}, {
|
|
15
|
+
collection: 'stat_group',
|
|
16
|
+
versionKey: false, // убирает поле __v
|
|
17
|
+
});
|
|
18
|
+
return StatGroupSchema;
|
|
19
|
+
}
|
package/dist/ports/index.d.ts
CHANGED
|
@@ -2,3 +2,8 @@ export * from "./users.repository";
|
|
|
2
2
|
export * from "./groups.repository";
|
|
3
3
|
export * from "./events.repository";
|
|
4
4
|
export * from "./event-templates.repository";
|
|
5
|
+
export * from "./stat-group.repository";
|
|
6
|
+
export * from "./stat-group-profile.repository";
|
|
7
|
+
export * from "./stat-group-season.repository";
|
|
8
|
+
export * from "./stat-group-last-100-games.repository";
|
|
9
|
+
export * from "./stat-group-activity-chart.repository";
|
package/dist/ports/index.js
CHANGED
|
@@ -18,3 +18,8 @@ __exportStar(require("./users.repository"), exports);
|
|
|
18
18
|
__exportStar(require("./groups.repository"), exports);
|
|
19
19
|
__exportStar(require("./events.repository"), exports);
|
|
20
20
|
__exportStar(require("./event-templates.repository"), exports);
|
|
21
|
+
__exportStar(require("./stat-group.repository"), exports);
|
|
22
|
+
__exportStar(require("./stat-group-profile.repository"), exports);
|
|
23
|
+
__exportStar(require("./stat-group-season.repository"), exports);
|
|
24
|
+
__exportStar(require("./stat-group-last-100-games.repository"), exports);
|
|
25
|
+
__exportStar(require("./stat-group-activity-chart.repository"), exports);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { StatGroupActivityChart } from "../types/stat-group-activity-chart.types";
|
|
2
|
+
/**
|
|
3
|
+
* Repository interface for StatGroupActivityChart
|
|
4
|
+
* Provides pre-aggregated time-series data for the group activity chart
|
|
5
|
+
*/
|
|
6
|
+
export interface StatGroupActivityChartRepository {
|
|
7
|
+
/**
|
|
8
|
+
* Finds activity chart data for a group within a timespan
|
|
9
|
+
* @param groupId - The group ID
|
|
10
|
+
* @param months - Number of months to look back (6 or 12)
|
|
11
|
+
* @returns Array of monthly activity data points
|
|
12
|
+
*/
|
|
13
|
+
findByGroupId(groupId: number, months: 6 | 12): Promise<StatGroupActivityChart | null>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { StatGroupLast100Games } from "../types/stat-group-last-100-games.types";
|
|
2
|
+
/**
|
|
3
|
+
* Repository interface for StatGroupLast100Games
|
|
4
|
+
* Provides enriched statistics for players' last 100 games in a group
|
|
5
|
+
*/
|
|
6
|
+
export interface StatGroupLast100GamesRepository {
|
|
7
|
+
/**
|
|
8
|
+
* Finds enriched last 100 games statistics for all players in a group
|
|
9
|
+
* @param groupId - The group ID
|
|
10
|
+
* @returns Array of enriched statistics pre-sorted by score (descending)
|
|
11
|
+
*/
|
|
12
|
+
findByGroupId(groupId: number): Promise<StatGroupLast100Games | null>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { StatGroupProfile } from "../types/stat-group-profile.types";
|
|
2
|
+
/**
|
|
3
|
+
* Repository interface for StatGroupProfile
|
|
4
|
+
* Provides pre-aggregated group profile data including header info,
|
|
5
|
+
* current season, and aggregate statistics
|
|
6
|
+
*/
|
|
7
|
+
export interface StatGroupProfileRepository {
|
|
8
|
+
/**
|
|
9
|
+
* Finds pre-aggregated group profile data by group ID
|
|
10
|
+
* @param groupId - The group ID
|
|
11
|
+
* @returns Group profile data or null if not found
|
|
12
|
+
*/
|
|
13
|
+
findByGroupId(groupId: number): Promise<StatGroupProfile | null>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { StatGroupSeason } from "../types/stat-group-season.types";
|
|
2
|
+
/**
|
|
3
|
+
* Repository interface for StatGroupSeason
|
|
4
|
+
* Provides pre-aggregated season statistics including participant rankings
|
|
5
|
+
* and performance data
|
|
6
|
+
*/
|
|
7
|
+
export interface StatGroupSeasonRepository {
|
|
8
|
+
/**
|
|
9
|
+
* Finds all season statistics for a group
|
|
10
|
+
* @param groupId - The group ID
|
|
11
|
+
* @returns Array of season statistics ordered by season (newest first)
|
|
12
|
+
*/
|
|
13
|
+
findByGroupId(groupId: number): Promise<StatGroupSeason[]>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { StatGroup } from "../domain/stat-group";
|
|
2
|
+
export interface FindPublicGroupsOptions {
|
|
3
|
+
page: number;
|
|
4
|
+
limit: number;
|
|
5
|
+
search?: string;
|
|
6
|
+
sort: 'lastActivity' | 'name' | 'members' | 'games';
|
|
7
|
+
}
|
|
8
|
+
export interface PublicGroupsWithStatsResult {
|
|
9
|
+
groups: Array<{
|
|
10
|
+
groupId: number;
|
|
11
|
+
groupName: string;
|
|
12
|
+
updatedAt: Date;
|
|
13
|
+
statistics: {
|
|
14
|
+
seasonsCount: number;
|
|
15
|
+
eventsCount: number;
|
|
16
|
+
matchesCount: number;
|
|
17
|
+
participantsCount: number;
|
|
18
|
+
};
|
|
19
|
+
}>;
|
|
20
|
+
totalCount: number;
|
|
21
|
+
}
|
|
22
|
+
export interface StatGroupRepository {
|
|
23
|
+
/**
|
|
24
|
+
* Find statistics for a specific group
|
|
25
|
+
* @param groupId The group ID
|
|
26
|
+
* @returns Group statistics or null if not found
|
|
27
|
+
*/
|
|
28
|
+
findByGroupId(groupId: number): Promise<StatGroup | null>;
|
|
29
|
+
/**
|
|
30
|
+
* Find public groups with their statistics using aggregation
|
|
31
|
+
* @param options Query options for filtering, pagination, and sorting
|
|
32
|
+
* @returns Paginated list of public groups with statistics
|
|
33
|
+
*/
|
|
34
|
+
findPublicGroupsWithStats(options: FindPublicGroupsOptions): Promise<PublicGroupsWithStatsResult>;
|
|
35
|
+
/**
|
|
36
|
+
* Create or update group statistics
|
|
37
|
+
* @param stats The statistics to save
|
|
38
|
+
* @returns The saved statistics
|
|
39
|
+
*/
|
|
40
|
+
upsert(stats: StatGroup): Promise<StatGroup>;
|
|
41
|
+
}
|
|
@@ -2,3 +2,8 @@ export * from "./mongo/user.repository";
|
|
|
2
2
|
export * from "./mongo/group.repository";
|
|
3
3
|
export * from "./mongo/event.repository";
|
|
4
4
|
export * from "./mongo/event-template.repository";
|
|
5
|
+
export * from "./mongo/stat-group.repository";
|
|
6
|
+
export * from "./mongo/stat-group-profile.repository";
|
|
7
|
+
export * from "./mongo/stat-group-season.repository";
|
|
8
|
+
export * from "./mongo/stat-group-last-100-games.repository";
|
|
9
|
+
export * from "./mongo/stat-group-activity-chart.repository";
|