|
@@ -6,6 +6,7 @@ import {
|
|
|
PaginationConnection,
|
|
|
} from 'sequelize-cursor-pagination'
|
|
|
import { TiktokData } from '../../db/models/Tiktok'
|
|
|
+import { PaginationData, PaginationOptions } from '../types'
|
|
|
|
|
|
const STATE = 'banana'
|
|
|
|
|
@@ -134,9 +135,9 @@ let paginate: (
|
|
|
queryOptions: PaginateOptions<Tiktok>
|
|
|
) => Promise<PaginationConnection<Tiktok>>
|
|
|
|
|
|
-async function paginateTweetByOrder(
|
|
|
+async function paginateTiktokByOrder(
|
|
|
after?: string,
|
|
|
- limit = 24
|
|
|
+ limit = 20
|
|
|
): Promise<PaginationConnection<TiktokData>> {
|
|
|
if (!paginate) {
|
|
|
paginate = makePaginate(Tiktok)
|
|
@@ -165,6 +166,29 @@ async function paginateTweetByOrder(
|
|
|
return ret
|
|
|
}
|
|
|
|
|
|
+async function pageTiktok(
|
|
|
+ option: Partial<PaginationOptions> = {}
|
|
|
+): Promise<PaginationData<TiktokData>> {
|
|
|
+ const opt = { page: 1, count: 20, ...option }
|
|
|
+ const result = await Tiktok.findAndCountAll({
|
|
|
+ order: [
|
|
|
+ ['order', 'DESC'],
|
|
|
+ ['id', 'DESC'],
|
|
|
+ ],
|
|
|
+ limit: opt.count,
|
|
|
+ offset: (opt.page - 1) * opt.count,
|
|
|
+ where: {
|
|
|
+ disabled: false,
|
|
|
+ },
|
|
|
+ })
|
|
|
+
|
|
|
+ return {
|
|
|
+ data: result.rows.map((row) => row.getData()),
|
|
|
+ total: result.count,
|
|
|
+ ...opt,
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
export interface GenerateTiktokResult {
|
|
|
url: string
|
|
|
success: boolean
|
|
@@ -310,7 +334,8 @@ async function bulkImportShot(
|
|
|
const tiktokService = {
|
|
|
STATE,
|
|
|
generateTweetByPublishAPI,
|
|
|
- paginateTweetByOrder,
|
|
|
+ paginateTiktokByOrder,
|
|
|
+ pageTiktok,
|
|
|
bulkGenerateTiktokByPublishAPI,
|
|
|
makeTweetTop,
|
|
|
makeTweetDisabled,
|