From 556ddc319242aafef51bae9301423ecf8701a3af Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 25 Aug 2017 18:36:49 +0200 Subject: Upgrade common server dependencies --- server/models/pod/pod-interface.ts | 2 +- server/models/pod/pod.ts | 6 ++---- server/models/user/user-video-rate-interface.ts | 2 ++ server/models/user/user-video-rate.ts | 2 +- server/models/user/user.ts | 5 +++-- server/models/video/video-interface.ts | 2 +- server/models/video/video.ts | 4 ++-- 7 files changed, 12 insertions(+), 11 deletions(-) (limited to 'server/models') diff --git a/server/models/pod/pod-interface.ts b/server/models/pod/pod-interface.ts index 8b0b72167..fc763acac 100644 --- a/server/models/pod/pod-interface.ts +++ b/server/models/pod/pod-interface.ts @@ -42,6 +42,7 @@ export interface PodClass { } export interface PodAttributes { + id?: number host?: string publicKey?: string score?: number | Sequelize.literal // Sequelize literal for 'score +' + value @@ -49,7 +50,6 @@ export interface PodAttributes { } export interface PodInstance extends PodClass, PodAttributes, Sequelize.Instance { - id: number createdAt: Date updatedAt: Date diff --git a/server/models/pod/pod.ts b/server/models/pod/pod.ts index 56918e358..df6412721 100644 --- a/server/models/pod/pod.ts +++ b/server/models/pod/pod.ts @@ -143,7 +143,7 @@ list = function () { } listAllIds = function (transaction: Sequelize.Transaction) { - const query: Sequelize.FindOptions = { + const query = { attributes: [ 'id' ], transaction } @@ -170,9 +170,7 @@ listRandomPodIdsWithRequest = function (limit: number, tableWithPods: string, ta limit: limit, where: { id: { - $in: [ - Sequelize.literal(`SELECT DISTINCT "${tableWithPods}"."podId" FROM "${tableWithPods}" ${tableWithPodsJoins}`) - ] + $in: Sequelize.literal(`(SELECT DISTINCT "${tableWithPods}"."podId" FROM "${tableWithPods}" ${tableWithPodsJoins})`) } } } diff --git a/server/models/user/user-video-rate-interface.ts b/server/models/user/user-video-rate-interface.ts index 4e6efc01a..ea0fdc4d9 100644 --- a/server/models/user/user-video-rate-interface.ts +++ b/server/models/user/user-video-rate-interface.ts @@ -13,6 +13,8 @@ export interface UserVideoRateClass { export interface UserVideoRateAttributes { type: VideoRateType + userId: number + videoId: number } export interface UserVideoRateInstance extends UserVideoRateClass, UserVideoRateAttributes, Sequelize.Instance { diff --git a/server/models/user/user-video-rate.ts b/server/models/user/user-video-rate.ts index c14598650..7d6dd7281 100644 --- a/server/models/user/user-video-rate.ts +++ b/server/models/user/user-video-rate.ts @@ -66,7 +66,7 @@ function associate (models) { } load = function (userId: number, videoId: number, transaction: Sequelize.Transaction) { - const options: Sequelize.FindOptions = { + const options: Sequelize.FindOptions = { where: { userId, videoId diff --git a/server/models/user/user.ts b/server/models/user/user.ts index e1b933988..d481fa13c 100644 --- a/server/models/user/user.ts +++ b/server/models/user/user.ts @@ -198,7 +198,7 @@ loadById = function (id: number) { loadByUsername = function (username: string) { const query = { where: { - username: username + username } } @@ -212,5 +212,6 @@ loadByUsernameOrEmail = function (username: string, email: string) { } } - return User.findOne(query) + // FIXME: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/18387 + return (User as any).findOne(query) } diff --git a/server/models/video/video-interface.ts b/server/models/video/video-interface.ts index cc214fd60..fb31c6a8f 100644 --- a/server/models/video/video-interface.ts +++ b/server/models/video/video-interface.ts @@ -121,6 +121,7 @@ export interface VideoClass { } export interface VideoAttributes { + id?: number uuid?: string name: string category: number @@ -140,7 +141,6 @@ export interface VideoAttributes { } export interface VideoInstance extends VideoClass, VideoAttributes, Sequelize.Instance { - id: number createdAt: Date updatedAt: Date diff --git a/server/models/video/video.ts b/server/models/video/video.ts index b3ca1e668..7dfea8ac9 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -643,7 +643,7 @@ list = function () { } listForApi = function (start: number, count: number, sort: string) { - // Exclude Blakclisted videos from the list + // Exclude blacklisted videos from the list const query = { distinct: true, offset: start, @@ -807,7 +807,7 @@ searchAndPopulateAuthorAndPodAndTags = function (value: string, field: string, s model: Video['sequelize'].models.VideoFile } - const query: Sequelize.FindOptions = { + const query: Sequelize.FindOptions = { distinct: true, where: createBaseVideosWhere(), offset: start, -- cgit v1.2.3