From 8c4bbd946d2247c2e239cbbf8773d2d31c1a57aa Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 10 Jan 2023 11:09:30 +0100 Subject: Refactor model utils --- .../models/video/sql/comment/video-comment-list-query-builder.ts | 2 +- .../models/video/sql/video/shared/abstract-video-query-builder.ts | 2 +- server/models/video/sql/video/videos-id-list-query-builder.ts | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'server/models/video/sql') diff --git a/server/models/video/sql/comment/video-comment-list-query-builder.ts b/server/models/video/sql/comment/video-comment-list-query-builder.ts index 49b41b6d8..3960f6b13 100644 --- a/server/models/video/sql/comment/video-comment-list-query-builder.ts +++ b/server/models/video/sql/comment/video-comment-list-query-builder.ts @@ -1,7 +1,7 @@ import { Model, Sequelize, Transaction } from 'sequelize' import { AbstractRunQuery, ModelBuilder } from '@server/models/shared' -import { createSafeIn, getCommentSort, parseRowCountResult } from '@server/models/utils' import { ActorImageType, VideoPrivacy } from '@shared/models' +import { createSafeIn, getCommentSort, parseRowCountResult } from '../../../shared' import { VideoCommentTableAttributes } from './video-comment-table-attributes' export interface ListVideoCommentsOptions { diff --git a/server/models/video/sql/video/shared/abstract-video-query-builder.ts b/server/models/video/sql/video/shared/abstract-video-query-builder.ts index f0ce69501..cbd57ad8c 100644 --- a/server/models/video/sql/video/shared/abstract-video-query-builder.ts +++ b/server/models/video/sql/video/shared/abstract-video-query-builder.ts @@ -1,9 +1,9 @@ import { Sequelize } from 'sequelize' import validator from 'validator' -import { createSafeIn } from '@server/models/utils' import { MUserAccountId } from '@server/types/models' import { ActorImageType } from '@shared/models' import { AbstractRunQuery } from '../../../../shared/abstract-run-query' +import { createSafeIn } from '../../../../shared' import { VideoTableAttributes } from './video-table-attributes' /** diff --git a/server/models/video/sql/video/videos-id-list-query-builder.ts b/server/models/video/sql/video/videos-id-list-query-builder.ts index 7c864bf27..62f1855c7 100644 --- a/server/models/video/sql/video/videos-id-list-query-builder.ts +++ b/server/models/video/sql/video/videos-id-list-query-builder.ts @@ -2,11 +2,12 @@ import { Sequelize, Transaction } from 'sequelize' import validator from 'validator' import { exists } from '@server/helpers/custom-validators/misc' import { WEBSERVER } from '@server/initializers/constants' -import { buildDirectionAndField, createSafeIn, parseRowCountResult } from '@server/models/utils' +import { buildSortDirectionAndField } from '@server/models/shared' import { MUserAccountId, MUserId } from '@server/types/models' +import { forceNumber } from '@shared/core-utils' import { VideoInclude, VideoPrivacy, VideoState } from '@shared/models' +import { createSafeIn, parseRowCountResult } from '../../../shared' import { AbstractRunQuery } from '../../../shared/abstract-run-query' -import { forceNumber } from '@shared/core-utils' /** * @@ -665,7 +666,7 @@ export class VideosIdListQueryBuilder extends AbstractRunQuery { } private buildOrder (value: string) { - const { direction, field } = buildDirectionAndField(value) + const { direction, field } = buildSortDirectionAndField(value) if (field.match(/^[a-zA-Z."]+$/) === null) throw new Error('Invalid sort column ' + field) if (field.toLowerCase() === 'random') return 'ORDER BY RANDOM()' -- cgit v1.2.3