refactor: use min value
This commit is contained in:
parent
3f7e260985
commit
c3233a0d29
3 changed files with 5 additions and 4 deletions
|
@ -68,7 +68,7 @@ db:
|
|||
# # <sparseTimelineDays> determines how many days ScyllaDB searches posts within
|
||||
# # one pagination when user's timelines are "sparse". As the user follows more
|
||||
# # accounts and more posts appear in the feeds, user's timelines will no longer
|
||||
# # be sparse. The bigger this value is, the slower the responses of timeline
|
||||
# # be sparse. The larger this value is, the slower the responses of timeline
|
||||
# # APIs would be.
|
||||
# #
|
||||
# # Let's say <sparseTimelineDays> is 14 and a user signed up and only created one
|
||||
|
@ -80,7 +80,7 @@ db:
|
|||
# sparseTimelineDays: 14
|
||||
#
|
||||
# # <queryLimit> determines the number of maximum rows read within one pagination.
|
||||
# # You may need to make [max_clustering_key_restrictions_per_query] bigger for ScyllaDB
|
||||
# # You may need to make [max_clustering_key_restrictions_per_query] larger for ScyllaDB
|
||||
# # if you want to set this value larger than 100.
|
||||
# # (default 100, max 5000, min 1)
|
||||
# queryLimit: 100
|
||||
|
|
|
@ -468,7 +468,7 @@ export async function execPaginationQuery(
|
|||
params.push(sinceDate);
|
||||
}
|
||||
|
||||
const fetchLimit = kind === "list" && ps.limit < 100 ? ps.limit : queryLimit;
|
||||
const fetchLimit = kind === "list" ? Math.min(ps.limit, queryLimit) : queryLimit;
|
||||
params.push(fetchLimit);
|
||||
|
||||
const result = await scyllaClient.execute(query, params, {
|
||||
|
|
|
@ -25,6 +25,7 @@ import {
|
|||
} from "@/misc/cache.js";
|
||||
import { Between, MoreThan, LessThan, FindOptionsWhere } from "typeorm";
|
||||
import type { ClipNote } from "@/models/entities/clip-note.js";
|
||||
import config from "@/config/index.js";
|
||||
|
||||
export const meta = {
|
||||
tags: ["account", "notes", "clips"],
|
||||
|
@ -92,7 +93,7 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
const noteIds = await ClipNotes.find({
|
||||
where: whereOpt,
|
||||
order: { noteId: "DESC" },
|
||||
take: ps.limit * 5,
|
||||
take: Math.min(ps.limit * 2, config.scylla?.queryLimit ?? 100),
|
||||
}).then((clips) => clips.map(({ noteId }) => noteId));
|
||||
|
||||
if (noteIds.length === 0) {
|
||||
|
|
Loading…
Reference in a new issue