db/events: index "media" tags, rearrange conditionals to optimize processing

This commit is contained in:
Alex Gleason 2023-09-09 15:39:49 -05:00
parent 6e139985ac
commit d24318fd0d
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 6 additions and 5 deletions

View File

@ -14,11 +14,12 @@ type TagCondition = ({ event, count, value }: {
/** Conditions for when to index certain tags. */
const tagConditions: Record<string, TagCondition> = {
'd': ({ event, count }) => isParameterizedReplaceableKind(event.kind) && count === 0,
'e': ({ count, value }) => isNostrId(value) && count < 15,
'p': ({ event, count, value }) => isNostrId(value) && (event.kind === 3 || count < 15),
'proxy': ({ count, value }) => isURL(value) && count === 0,
'q': ({ event, count, value }) => isNostrId(value) && event.kind === 1 && count === 0,
'd': ({ event, count }) => count === 0 && isParameterizedReplaceableKind(event.kind),
'e': ({ count, value }) => count < 15 && isNostrId(value),
'media': ({ count, value }) => count < 4 && isURL(value),
'p': ({ event, count, value }) => (count < 15 || event.kind === 3) && isNostrId(value),
'proxy': ({ count, value }) => count === 0 && isURL(value),
'q': ({ event, count, value }) => count === 0 && event.kind === 1 && isNostrId(value),
't': ({ count, value }) => count < 5 && value.length < 50,
};