Skip to content

Commit 0bc0e75

Browse files
authored
Merge pull request #484 from CodingFactory-Repos/develop-G7
Develop g7
2 parents 07ad8c7 + 79a0bd5 commit 0bc0e75

62 files changed

Lines changed: 2661 additions & 266 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

back-end/package-lock.json

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

back-end/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"@nestjs/websockets": "^9.4.2",
3636
"argon2": "^0.30.3",
3737
"axios": "^1.4.0",
38+
"chart.js": "^4.3.0",
3839
"class-transformer": "^0.5.1",
3940
"class-validator": "^0.14.0",
4041
"cookie-parser": "^1.4.6",

back-end/src/base/articles/articles.controller.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,24 @@ export class ArticlesController {
5353
return res.status(201).json(article);
5454
}
5555

56+
@Get('/stats/participant')
57+
async getArticleWithMostParticipants(@Req() req: Request, @Res() res: Response) {
58+
const articleId = await this.articlesService.getArticleWithMostParticipants();
59+
return res.status(201).json(articleId);
60+
}
61+
62+
@Get('/stats/topcreateur')
63+
async getTopCreateur(@Req() req: Request, @Res() res: Response) {
64+
const articleId = await this.articlesService.getTopCreateur();
65+
return res.status(201).json(articleId);
66+
}
67+
68+
@Get('/stats/topparticipant')
69+
async getTopParticipant(@Req() req: Request, @Res() res: Response) {
70+
const articleId = await this.articlesService.getTopParticipant();
71+
return res.status(201).json(articleId);
72+
}
73+
5674
// remove participant from the array of participants in article in the database
5775
@Put('/removeParticipant/:id')
5876
async removeParticipant(@Req() req: Request, @Res() res: Response) {

back-end/src/base/articles/articles.service.ts

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class ArticlesService {
2222
// add new object id to id
2323
queryArticle._id = new ObjectId();
2424

25-
queryArticle.owner = new ObjectId(queryArticle.owner);
25+
queryArticle.owner._id = new ObjectId(queryArticle.owner._id);
2626
queryArticle.date = new Date(queryArticle.date);
2727
queryArticle.updatedAt = new Date();
2828

@@ -75,6 +75,85 @@ export class ArticlesService {
7575
return await this.articlesRepository.updateOneArticle({ _id: new ObjectId(id) }, update);
7676
}
7777

78+
async getArticleWithMostParticipants() {
79+
const res = await this.articlesRepository.articles
80+
.aggregate([
81+
{
82+
$match: {
83+
participants: { $exists: true, $ne: [] },
84+
},
85+
},
86+
{
87+
$project: {
88+
_id: 1,
89+
title: 1,
90+
participants: 1,
91+
numParticipants: { $size: '$participants' },
92+
},
93+
},
94+
{
95+
$sort: { numParticipants: -1 },
96+
},
97+
{
98+
$limit: 5,
99+
},
100+
])
101+
.toArray();
102+
return res;
103+
}
104+
async getTopCreateur() {
105+
const res = await this.articlesRepository.articles
106+
.aggregate([
107+
{
108+
$unwind: '$owner',
109+
},
110+
{
111+
$group: {
112+
_id: '$owner',
113+
firstName: { $first: '$owner.firstName' },
114+
lastName: { $first: '$owner.lastName' },
115+
count: { $sum: 1 },
116+
},
117+
},
118+
{
119+
$sort: { count: -1 },
120+
},
121+
{
122+
$limit: 10,
123+
},
124+
])
125+
.toArray();
126+
return res;
127+
}
128+
129+
async getTopParticipant() {
130+
const res = await this.articlesRepository.articles
131+
.aggregate([
132+
{
133+
$match: { type: 'Evenement' },
134+
},
135+
{
136+
$unwind: '$participants',
137+
},
138+
{
139+
$group: {
140+
_id: '$participants._id',
141+
firstName: { $first: '$participants.firstName' },
142+
lastName: { $first: '$participants.lastName' },
143+
count: { $sum: 1 },
144+
},
145+
},
146+
{
147+
$sort: { count: -1 },
148+
},
149+
{
150+
$limit: 10,
151+
},
152+
])
153+
.toArray();
154+
return res;
155+
}
156+
78157
// remove participant from the array of participants in article in the database
79158
async removeParticipant(id, queryParticipant) {
80159
queryParticipant._id = new ObjectId(queryParticipant._id);

back-end/src/base/users/dto/users.dto.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ class UserProfileDTO {
5757

5858
@IsOptional()
5959
@IsString({ message: 'Invalid type format' })
60-
@Length(0, 80, { message: 'Profile picture link must be between 0 and 80 characters' })
60+
@Length(0, 120, { message: 'Profile picture link must be between 0 and 120 characters' })
6161
@Matches(STRICT_API_URL, { message: 'Your profile picture must be a valid url' })
6262
picture: string;
6363

6464
@IsOptional()
6565
@IsString({ message: 'Invalid type format' })
66-
@Length(0, 80, { message: 'Profile background link be between 0 and 80 characters' })
66+
@Length(0, 120, { message: 'Profile background link be between 0 and 120 characters' })
6767
@Matches(STRICT_API_URL, { message: 'Your profile background must be a valid url' })
6868
background: string;
6969

@@ -118,7 +118,7 @@ class UserBusinessProfileDTO {
118118
@IsOptional()
119119
@IsString({ message: 'Invalid type format' })
120120
@Matches(STRICT_API_URL, { message: 'Your company logo must be a valid url' })
121-
@Length(0, 80, { message: 'Company logo link be between 0 and 80 characters' })
121+
@Length(0, 120, { message: 'Company logo link be between 0 and 120 characters' })
122122
companyLogo: string;
123123

124124
@IsOptional()
65.4 KB
Loading

front-end/public/empathy_map.webp

202 KB
Loading
53.6 KB
Loading

front-end/public/persona.webp

668 KB
Loading
260 KB
Loading

0 commit comments

Comments
 (0)