aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-04-20 15:15:10 +0200
committerRigel Kent <par@rigelk.eu>2020-05-01 16:41:02 +0200
commitefa012edad6b9b4c38a21a5c7d06ce0f7089d22c (patch)
treeeb80dcf50e2eb745c223f4f40a4a76bdbada0f7b
parent0251197e249cc03b65805ed6805da72bf4573529 (diff)
downloadPeerTube-efa012edad6b9b4c38a21a5c7d06ce0f7089d22c.tar.gz
PeerTube-efa012edad6b9b4c38a21a5c7d06ce0f7089d22c.tar.zst
PeerTube-efa012edad6b9b4c38a21a5c7d06ce0f7089d22c.zip
Add reportee stats for deleted videos
-rw-r--r--client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.html2
-rw-r--r--server/models/video/video-abuse.ts43
2 files changed, 36 insertions, 9 deletions
diff --git a/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.html b/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.html
index 4afa2850b..2f6e12d1c 100644
--- a/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.html
+++ b/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.html
@@ -149,7 +149,7 @@
149 <span class="text-muted">{{ videoAbuse.video.channel.ownerAccount ? createByString(videoAbuse.video.channel.ownerAccount) : '' }}</span> 149 <span class="text-muted">{{ videoAbuse.video.channel.ownerAccount ? createByString(videoAbuse.video.channel.ownerAccount) : '' }}</span>
150 </div> 150 </div>
151 </div> 151 </div>
152 <a [routerLink]="[ '/admin/moderation/video-abuses/list' ]" [queryParams]="{ 'search': videoAbuse.video.channel.ownerAccount.displayName }" class="ml-auto text-muted video-details-links" *ngIf="!videoAbuse.video.deleted" i18n> 152 <a [routerLink]="[ '/admin/moderation/video-abuses/list' ]" [queryParams]="{ 'search': videoAbuse.video.channel.ownerAccount.displayName }" class="ml-auto text-muted video-details-links" i18n>
153 {videoAbuse.countReportsForReportee, plural, =1 {1 report} other {{{ videoAbuse.countReportsForReportee }} reports}}<span class="ml-1 glyphicon glyphicon-flag"></span> 153 {videoAbuse.countReportsForReportee, plural, =1 {1 report} other {{{ videoAbuse.countReportsForReportee }} reports}}<span class="ml-1 glyphicon glyphicon-flag"></span>
154 </a> 154 </a>
155 </span> 155 </span>
diff --git a/server/models/video/video-abuse.ts b/server/models/video/video-abuse.ts
index 71b519cd9..285fb1fbc 100644
--- a/server/models/video/video-abuse.ts
+++ b/server/models/video/video-abuse.ts
@@ -15,7 +15,7 @@ import { VideoAbuseState, VideoDetails } from '../../../shared'
15import { CONSTRAINTS_FIELDS, VIDEO_ABUSE_STATES } from '../../initializers/constants' 15import { CONSTRAINTS_FIELDS, VIDEO_ABUSE_STATES } from '../../initializers/constants'
16import { MUserAccountId, MVideoAbuse, MVideoAbuseFormattable, MVideoAbuseVideo } from '../../typings/models' 16import { MUserAccountId, MVideoAbuse, MVideoAbuseFormattable, MVideoAbuseVideo } from '../../typings/models'
17import * as Bluebird from 'bluebird' 17import * as Bluebird from 'bluebird'
18import { literal, Op, Sequelize } from 'sequelize' 18import { literal, Op } from 'sequelize'
19import { ThumbnailModel } from './thumbnail' 19import { ThumbnailModel } from './thumbnail'
20import { VideoBlacklistModel } from './video-blacklist' 20import { VideoBlacklistModel } from './video-blacklist'
21import { ScopeNames as VideoChannelScopeNames, SummaryOptions, VideoChannelModel } from './video-channel' 21import { ScopeNames as VideoChannelScopeNames, SummaryOptions, VideoChannelModel } from './video-channel'
@@ -75,6 +75,7 @@ export enum ScopeNames {
75 attributes: { 75 attributes: {
76 include: [ 76 include: [
77 [ 77 [
78 // we don't care about this count for deleted videos, so there are not included
78 literal( 79 literal(
79 '(' + 80 '(' +
80 'SELECT count(*) ' + 81 'SELECT count(*) ' +
@@ -85,6 +86,7 @@ export enum ScopeNames {
85 'countReportsForVideo' 86 'countReportsForVideo'
86 ], 87 ],
87 [ 88 [
89 // we don't care about this count for deleted videos, so there are not included
88 literal( 90 literal(
89 '(' + 91 '(' +
90 'SELECT t.nth ' + 92 'SELECT t.nth ' +
@@ -109,7 +111,17 @@ export enum ScopeNames {
109 'WHERE "account"."id" = "VideoAbuseModel"."reporterAccountId" ' + 111 'WHERE "account"."id" = "VideoAbuseModel"."reporterAccountId" ' +
110 ')' 112 ')'
111 ), 113 ),
112 'countReportsForReporter' 114 'countReportsForReporter__video'
115 ],
116 [
117 literal(
118 '(' +
119 'SELECT count(DISTINCT "videoAbuse"."id") ' +
120 'FROM "videoAbuse" ' +
121 `WHERE CAST("deletedVideo"->'channel'->'ownerAccount'->>'id' AS INTEGER) = "VideoAbuseModel"."reporterAccountId" ` +
122 ')'
123 ),
124 'countReportsForReporter__deletedVideo'
113 ], 125 ],
114 [ 126 [
115 literal( 127 literal(
@@ -118,10 +130,23 @@ export enum ScopeNames {
118 'FROM "videoAbuse" ' + 130 'FROM "videoAbuse" ' +
119 'INNER JOIN "video" ON "video"."id" = "videoAbuse"."videoId" ' + 131 'INNER JOIN "video" ON "video"."id" = "videoAbuse"."videoId" ' +
120 'INNER JOIN "videoChannel" ON "videoChannel"."id" = "video"."channelId" ' + 132 'INNER JOIN "videoChannel" ON "videoChannel"."id" = "video"."channelId" ' +
121 'INNER JOIN "account" ON "videoChannel"."accountId" = "Video->VideoChannel"."accountId" ' + 133 'INNER JOIN "account" ON ' +
134 '"videoChannel"."accountId" = "Video->VideoChannel"."accountId" ' +
135 `OR "videoChannel"."accountId" = CAST("VideoAbuseModel"."deletedVideo"->'channel'->'ownerAccount'->>'id' AS INTEGER) ` +
136 ')'
137 ),
138 'countReportsForReportee__video'
139 ],
140 [
141 literal(
142 '(' +
143 'SELECT count(DISTINCT "videoAbuse"."id") ' +
144 'FROM "videoAbuse" ' +
145 `WHERE CAST("deletedVideo"->'channel'->'ownerAccount'->>'id' AS INTEGER) = "Video->VideoChannel"."accountId" ` +
146 `OR CAST("deletedVideo"->'channel'->'ownerAccount'->>'id' AS INTEGER) = CAST("VideoAbuseModel"."deletedVideo"->'channel'->'ownerAccount'->>'id' AS INTEGER) ` +
122 ')' 147 ')'
123 ), 148 ),
124 'countReportsForReportee' 149 'countReportsForReportee__deletedVideo'
125 ] 150 ]
126 ] 151 ]
127 }, 152 },
@@ -270,8 +295,10 @@ export class VideoAbuseModel extends Model<VideoAbuseModel> {
270 toFormattedJSON (this: MVideoAbuseFormattable): VideoAbuse { 295 toFormattedJSON (this: MVideoAbuseFormattable): VideoAbuse {
271 const countReportsForVideo = this.get('countReportsForVideo') as number 296 const countReportsForVideo = this.get('countReportsForVideo') as number
272 const nthReportForVideo = this.get('nthReportForVideo') as number 297 const nthReportForVideo = this.get('nthReportForVideo') as number
273 const countReportsForReporter = this.get('countReportsForReporter') as number 298 const countReportsForReporterVideo = this.get('countReportsForReporter__video') as number
274 const countReportsForReportee = this.get('countReportsForReportee') as number 299 const countReportsForReporterDeletedVideo = this.get('countReportsForReporter__deletedVideo') as number
300 const countReportsForReporteeVideo = this.get('countReportsForReportee__video') as number
301 const countReportsForReporteeDeletedVideo = this.get('countReportsForReportee__deletedVideo') as number
275 302
276 const video = this.Video 303 const video = this.Video
277 ? this.Video 304 ? this.Video
@@ -300,8 +327,8 @@ export class VideoAbuseModel extends Model<VideoAbuseModel> {
300 updatedAt: this.updatedAt, 327 updatedAt: this.updatedAt,
301 count: countReportsForVideo || 0, 328 count: countReportsForVideo || 0,
302 nth: nthReportForVideo || 0, 329 nth: nthReportForVideo || 0,
303 countReportsForReporter: countReportsForReporter || 0, 330 countReportsForReporter: (countReportsForReporterVideo || 0) + (countReportsForReporterDeletedVideo || 0),
304 countReportsForReportee: countReportsForReportee || 0 331 countReportsForReportee: (countReportsForReporteeVideo || 0) + (countReportsForReporteeDeletedVideo || 0)
305 } 332 }
306 } 333 }
307 334