Order tag conditionals alphabetically, improve logic

This commit is contained in:
Alex Gleason 2023-08-11 12:14:39 -05:00
parent 48343c8035
commit 9cca801c80
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 4 additions and 3 deletions

View File

@ -7,11 +7,12 @@ type TagCondition = ({ event, count }: { event: SignedEvent; count: number }) =>
/** Conditions for when to index certain tags. */ /** Conditions for when to index certain tags. */
const tagConditions: Record<string, TagCondition> = { const tagConditions: Record<string, TagCondition> = {
't': ({ count }) => count < 5,
'p': ({ event }) => event.kind === 3,
'd': ({ event, count }) => 30000 <= event.kind && event.kind < 40000 && count === 0, 'd': ({ event, count }) => 30000 <= event.kind && event.kind < 40000 && count === 0,
'q': ({ event, count }) => event.kind === 1 && count === 0, 'e': ({ count }) => count < 15,
'p': ({ event, count }) => event.kind === 3 || count < 15,
'proxy': ({ count }) => count === 0, 'proxy': ({ count }) => count === 0,
'q': ({ event, count }) => event.kind === 1 && count === 0,
't': ({ count }) => count < 5,
}; };
function insertEvent(event: SignedEvent): Promise<void> { function insertEvent(event: SignedEvent): Promise<void> {