aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-12-21 10:56:57 +0100
committerChocobozzz <me@florianbigard.com>2022-12-21 10:56:57 +0100
commit41027acb0a0c7d59a22f0f56d60928660f576196 (patch)
tree17d930f07437491602347be632b155c60cde69c6
parentd91439648c212f9bca527cbcb05ba2e233b56deb (diff)
parent77f0c0e5dc197729a9255188c210e363b7d90be1 (diff)
downloadPeerTube-41027acb0a0c7d59a22f0f56d60928660f576196.tar.gz
PeerTube-41027acb0a0c7d59a22f0f56d60928660f576196.tar.zst
PeerTube-41027acb0a0c7d59a22f0f56d60928660f576196.zip
Merge branch 'release/5.0.0' into develop
-rw-r--r--client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.html2
-rw-r--r--client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.html2
-rw-r--r--server/models/video/video-channel.ts37
-rw-r--r--server/tests/api/server/stats.ts3
4 files changed, 23 insertions, 21 deletions
diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.html b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.html
index 9b4930b6d..e383e0c75 100644
--- a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.html
+++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.html
@@ -1,6 +1,6 @@
1<my-video-miniature 1<my-video-miniature
2 *ngIf="video" 2 *ngIf="video"
3 [video]="video" [user]="getUser()" [displayAsRow]="false" 3 [video]="video" [user]="getUser()" [displayAsRow]="false"
4 [displayVideoActions]="false" [displayOptions]="displayOptions" 4 [displayVideoActions]="true" [displayOptions]="displayOptions"
5> 5>
6</my-video-miniature> 6</my-video-miniature>
diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.html b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.html
index 15ef9d418..868bda387 100644
--- a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.html
+++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.html
@@ -4,7 +4,7 @@
4 <div class="video-wrapper" *ngFor="let video of videos"> 4 <div class="video-wrapper" *ngFor="let video of videos">
5 <my-video-miniature 5 <my-video-miniature
6 [video]="video" [user]="getUser()" [displayAsRow]="false" 6 [video]="video" [user]="getUser()" [displayAsRow]="false"
7 [displayVideoActions]="false" [displayOptions]="displayOptions" 7 [displayVideoActions]="true" [displayOptions]="displayOptions"
8 > 8 >
9 </my-video-miniature> 9 </my-video-miniature>
10 </div> 10 </div>
diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts
index 9e461b6ca..132c8f021 100644
--- a/server/models/video/video-channel.ts
+++ b/server/models/video/video-channel.ts
@@ -434,42 +434,41 @@ export class VideoChannelModel extends Model<Partial<AttributesOnly<VideoChannel
434 434
435 static async getStats () { 435 static async getStats () {
436 436
437 function getActiveVideoChannels (days: number) { 437 function getLocalVideoChannelStats (days?: number) {
438 const options = { 438 const options = {
439 type: QueryTypes.SELECT as QueryTypes.SELECT, 439 type: QueryTypes.SELECT as QueryTypes.SELECT,
440 raw: true 440 raw: true
441 } 441 }
442 442
443 const videoJoin = days
444 ? `INNER JOIN "video" AS "Videos" ON "VideoChannelModel"."id" = "Videos"."channelId" ` +
445 `AND ("Videos"."publishedAt" > Now() - interval '${days}d')`
446 : ''
447
443 const query = ` 448 const query = `
444SELECT COUNT(DISTINCT("VideoChannelModel"."id")) AS "count" 449 SELECT COUNT(DISTINCT("VideoChannelModel"."id")) AS "count"
445FROM "videoChannel" AS "VideoChannelModel" 450 FROM "videoChannel" AS "VideoChannelModel"
446INNER JOIN "video" AS "Videos" 451 ${videoJoin}
447ON "VideoChannelModel"."id" = "Videos"."channelId" 452 INNER JOIN "account" AS "Account" ON "VideoChannelModel"."accountId" = "Account"."id"
448AND ("Videos"."publishedAt" > Now() - interval '${days}d') 453 INNER JOIN "actor" AS "Account->Actor" ON "Account"."actorId" = "Account->Actor"."id"
449INNER JOIN "account" AS "Account" 454 AND "Account->Actor"."serverId" IS NULL`
450ON "VideoChannelModel"."accountId" = "Account"."id"
451INNER JOIN "actor" AS "Account->Actor"
452ON "Account"."actorId" = "Account->Actor"."id"
453AND "Account->Actor"."serverId" IS NULL
454LEFT OUTER JOIN "server" AS "Account->Actor->Server"
455ON "Account->Actor"."serverId" = "Account->Actor->Server"."id"`
456 455
457 return VideoChannelModel.sequelize.query<{ count: string }>(query, options) 456 return VideoChannelModel.sequelize.query<{ count: string }>(query, options)
458 .then(r => parseInt(r[0].count, 10)) 457 .then(r => parseInt(r[0].count, 10))
459 } 458 }
460 459
461 const totalLocalVideoChannels = await VideoChannelModel.count() 460 const totalLocalVideoChannels = await getLocalVideoChannelStats()
462 const totalLocalDailyActiveVideoChannels = await getActiveVideoChannels(1) 461 const totalLocalDailyActiveVideoChannels = await getLocalVideoChannelStats(1)
463 const totalLocalWeeklyActiveVideoChannels = await getActiveVideoChannels(7) 462 const totalLocalWeeklyActiveVideoChannels = await getLocalVideoChannelStats(7)
464 const totalLocalMonthlyActiveVideoChannels = await getActiveVideoChannels(30) 463 const totalLocalMonthlyActiveVideoChannels = await getLocalVideoChannelStats(30)
465 const totalHalfYearActiveVideoChannels = await getActiveVideoChannels(180) 464 const totalLocalHalfYearActiveVideoChannels = await getLocalVideoChannelStats(180)
466 465
467 return { 466 return {
468 totalLocalVideoChannels, 467 totalLocalVideoChannels,
469 totalLocalDailyActiveVideoChannels, 468 totalLocalDailyActiveVideoChannels,
470 totalLocalWeeklyActiveVideoChannels, 469 totalLocalWeeklyActiveVideoChannels,
471 totalLocalMonthlyActiveVideoChannels, 470 totalLocalMonthlyActiveVideoChannels,
472 totalHalfYearActiveVideoChannels 471 totalLocalHalfYearActiveVideoChannels
473 } 472 }
474 } 473 }
475 474
diff --git a/server/tests/api/server/stats.ts b/server/tests/api/server/stats.ts
index 83b0e73d6..942cbeaa4 100644
--- a/server/tests/api/server/stats.ts
+++ b/server/tests/api/server/stats.ts
@@ -131,6 +131,7 @@ describe('Test stats (excluding redundancy)', function () {
131 { 131 {
132 const data = await server.stats.get() 132 const data = await server.stats.get()
133 133
134 expect(data.totalLocalVideoChannels).to.equal(2)
134 expect(data.totalLocalDailyActiveVideoChannels).to.equal(1) 135 expect(data.totalLocalDailyActiveVideoChannels).to.equal(1)
135 expect(data.totalLocalWeeklyActiveVideoChannels).to.equal(1) 136 expect(data.totalLocalWeeklyActiveVideoChannels).to.equal(1)
136 expect(data.totalLocalMonthlyActiveVideoChannels).to.equal(1) 137 expect(data.totalLocalMonthlyActiveVideoChannels).to.equal(1)
@@ -146,6 +147,7 @@ describe('Test stats (excluding redundancy)', function () {
146 147
147 const data = await server.stats.get() 148 const data = await server.stats.get()
148 149
150 expect(data.totalLocalVideoChannels).to.equal(3)
149 expect(data.totalLocalDailyActiveVideoChannels).to.equal(1) 151 expect(data.totalLocalDailyActiveVideoChannels).to.equal(1)
150 expect(data.totalLocalWeeklyActiveVideoChannels).to.equal(1) 152 expect(data.totalLocalWeeklyActiveVideoChannels).to.equal(1)
151 expect(data.totalLocalMonthlyActiveVideoChannels).to.equal(1) 153 expect(data.totalLocalMonthlyActiveVideoChannels).to.equal(1)
@@ -156,6 +158,7 @@ describe('Test stats (excluding redundancy)', function () {
156 158
157 const data = await server.stats.get() 159 const data = await server.stats.get()
158 160
161 expect(data.totalLocalVideoChannels).to.equal(3)
159 expect(data.totalLocalDailyActiveVideoChannels).to.equal(2) 162 expect(data.totalLocalDailyActiveVideoChannels).to.equal(2)
160 expect(data.totalLocalWeeklyActiveVideoChannels).to.equal(2) 163 expect(data.totalLocalWeeklyActiveVideoChannels).to.equal(2)
161 expect(data.totalLocalMonthlyActiveVideoChannels).to.equal(2) 164 expect(data.totalLocalMonthlyActiveVideoChannels).to.equal(2)