refactor: add config value

This commit is contained in:
Namekuji 2023-08-10 04:22:05 -04:00
parent 19c00e00f7
commit 742c41558a
No known key found for this signature in database
GPG key ID: 1D62332C07FBA532
3 changed files with 17 additions and 2 deletions

View file

@ -64,6 +64,20 @@ db:
# keyspace: firefish
# replicationFactor: 1
# localDataCentre: "datacenter1"
#
# # <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
# # APIs would be.
# #
# # Let's say <sparseTimelineDays> is 14 and a user signed up and only created one
# # post. Suppose that this user follows no accounts, and created the second post
# # 15 days after signing up. In this case, the user's first post does not
# # appear in their home timeline.
# #
# # (default: 14)
# sparseTimelineDays: 14
# ┌─────────────────────┐
#───┘ Redis configuration └─────────────────────────────────────

View file

@ -22,6 +22,7 @@ export type Source = {
keyspace: string;
replicationFactor: number;
localDataCentre: string;
sparseTimelineDays?: number;
};
redis: {
host: string;

View file

@ -238,7 +238,7 @@ export interface ScyllaNoteReaction extends NoteReaction {
emoji: PopulatedEmoji;
}
const QUERY_LIMIT = 1000;
const QUERY_LIMIT = 1000; // TODO: should this be configurable?
export function parseScyllaReaction(row: types.Row): ScyllaNoteReaction {
return {
@ -303,7 +303,7 @@ export async function execNotePaginationQuery(
noteId?: string;
},
filter?: (_: ScyllaNote[]) => Promise<ScyllaNote[]>,
maxPartitions = 30,
maxPartitions = config.scylla?.sparseTimelineDays ?? 14,
): Promise<ScyllaNote[]> {
if (!scyllaClient) return [];