]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/server/server-blocklist.ts
Implement avatar miniatures (#4639)
[github/Chocobozzz/PeerTube.git] / server / models / server / server-blocklist.ts
index 9f64eeb7f9a97affe25a4067a4492b7e5897f1ea..9752dfbc3f0a0c3330cd17364194decd765146b9 100644 (file)
@@ -1,8 +1,8 @@
 import { Op, QueryTypes } from 'sequelize'
 import { BelongsTo, Column, CreatedAt, ForeignKey, Model, Scopes, Table, UpdatedAt } from 'sequelize-typescript'
 import { MServerBlocklist, MServerBlocklistAccountServer, MServerBlocklistFormattable } from '@server/types/models'
-import { AttributesOnly } from '@shared/typescript-utils'
 import { ServerBlock } from '@shared/models'
+import { AttributesOnly } from '@shared/typescript-utils'
 import { AccountModel } from '../account/account'
 import { createSafeIn, getSort, searchAttribute } from '../utils'
 import { ServerModel } from './server'
@@ -169,16 +169,15 @@ export class ServerBlocklistModel extends Model<Partial<AttributesOnly<ServerBlo
       order: getSort(sort),
       where: {
         accountId,
+
         ...searchAttribute(search, '$BlockedServer.host$')
       }
     }
 
-    return ServerBlocklistModel
-      .scope([ ScopeNames.WITH_ACCOUNT, ScopeNames.WITH_SERVER ])
-      .findAndCountAll<MServerBlocklistAccountServer>(query)
-      .then(({ rows, count }) => {
-        return { total: count, data: rows }
-      })
+    return Promise.all([
+      ServerBlocklistModel.scope(ScopeNames.WITH_SERVER).count(query),
+      ServerBlocklistModel.scope([ ScopeNames.WITH_ACCOUNT, ScopeNames.WITH_SERVER ]).findAll<MServerBlocklistAccountServer>(query)
+    ]).then(([ total, data ]) => ({ total, data }))
   }
 
   toFormattedJSON (this: MServerBlocklistFormattable): ServerBlock {