mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-07 12:36:57 +00:00
add relations from abuse_user_report->user_profile to speed up admin/abuse-user-reports endpoint
This commit is contained in:
parent
23302fe7d8
commit
b05ccbc3ac
2 changed files with 31 additions and 1 deletions
|
@ -5,6 +5,7 @@
|
|||
|
||||
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
|
||||
import { MiInstance } from '@/models/Instance.js';
|
||||
import { MiUserProfile } from '@/models/UserProfile.js';
|
||||
import { id } from './util/id.js';
|
||||
import { MiUser } from './User.js';
|
||||
|
||||
|
@ -25,6 +26,13 @@ export class MiAbuseUserReport {
|
|||
@JoinColumn()
|
||||
public targetUser: MiUser | null;
|
||||
|
||||
@ManyToOne(() => MiUserProfile, {
|
||||
onDelete: 'CASCADE',
|
||||
createForeignKeyConstraints: false,
|
||||
})
|
||||
@JoinColumn({ name: 'targetUserId', referencedColumnName: 'userId' })
|
||||
public targetUserProfile: MiUserProfile | null;
|
||||
|
||||
@Index()
|
||||
@Column(id())
|
||||
public reporterId: MiUser['id'];
|
||||
|
@ -35,6 +43,13 @@ export class MiAbuseUserReport {
|
|||
@JoinColumn()
|
||||
public reporter: MiUser | null;
|
||||
|
||||
@ManyToOne(() => MiUserProfile, {
|
||||
onDelete: 'CASCADE',
|
||||
createForeignKeyConstraints: false,
|
||||
})
|
||||
@JoinColumn({ name: 'reporterId', referencedColumnName: 'userId' })
|
||||
public reporterProfile: MiUserProfile | null;
|
||||
|
||||
@Column({
|
||||
...id(),
|
||||
nullable: true,
|
||||
|
@ -47,6 +62,13 @@ export class MiAbuseUserReport {
|
|||
@JoinColumn()
|
||||
public assignee: MiUser | null;
|
||||
|
||||
@ManyToOne(() => MiUserProfile, {
|
||||
onDelete: 'CASCADE',
|
||||
createForeignKeyConstraints: false,
|
||||
})
|
||||
@JoinColumn({ name: 'assigneeId', referencedColumnName: 'userId' })
|
||||
public assigneeProfile: MiUserProfile | null;
|
||||
|
||||
@Index()
|
||||
@Column('boolean', {
|
||||
default: false,
|
||||
|
|
|
@ -120,7 +120,15 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
private queryService: QueryService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
const query = this.queryService.makePaginationQuery(this.abuseUserReportsRepository.createQueryBuilder('report'), ps.sinceId, ps.untilId);
|
||||
const query = this.queryService.makePaginationQuery(this.abuseUserReportsRepository.createQueryBuilder('report'), ps.sinceId, ps.untilId)
|
||||
.leftJoinAndSelect('report.targetUser', 'targetUser')
|
||||
.leftJoinAndSelect('report.targetUserProfile', 'targetUserProfile')
|
||||
.leftJoinAndSelect('report.targetUserInstance', 'targetUserInstance')
|
||||
.leftJoinAndSelect('report.reporter', 'reporter')
|
||||
.leftJoinAndSelect('report.reporterUserProfile', 'reporterUserProfile')
|
||||
.leftJoinAndSelect('report.assignee', 'assignee')
|
||||
.leftJoinAndSelect('report.assigneeUserProfile', 'assigneeUserProfile')
|
||||
;
|
||||
|
||||
switch (ps.state) {
|
||||
case 'resolved': query.andWhere('report.resolved = TRUE'); break;
|
||||
|
|
Loading…
Add table
Reference in a new issue