kopia lustrzana https://github.com/cloudflare/wildebeest
commit
059b4bbbdc
|
@ -21,6 +21,10 @@ const qb: QueryBuilder = {
|
|||
insertOrIgnore(q: string): string {
|
||||
return `INSERT OR IGNORE ${q}`
|
||||
},
|
||||
|
||||
psqlOnly(): string {
|
||||
return ''
|
||||
},
|
||||
}
|
||||
|
||||
export default function make({ DATABASE }: Pick<Env, 'DATABASE'>): Database {
|
||||
|
|
|
@ -31,6 +31,7 @@ export interface QueryBuilder {
|
|||
set(array: string): string
|
||||
epoch(): string
|
||||
insertOrIgnore(q: string): string
|
||||
psqlOnly(raw: string): string
|
||||
}
|
||||
|
||||
export async function getDatabase(env: Pick<Env, 'DATABASE' | 'NEON_DATABASE_URL'>): Promise<Database> {
|
||||
|
|
|
@ -30,6 +30,10 @@ const qb: QueryBuilder = {
|
|||
insertOrIgnore(q: string): string {
|
||||
return `INSERT ${q} ON CONFLICT DO NOTHING`
|
||||
},
|
||||
|
||||
psqlOnly(q: string): string {
|
||||
return q
|
||||
},
|
||||
}
|
||||
|
||||
export default async function make(env: Pick<Env, 'NEON_DATABASE_URL'>): Promise<Database> {
|
||||
|
|
|
@ -63,7 +63,7 @@ WHERE
|
|||
AND outbox_objects.actor_id IN ${db.qb.set('?2')}
|
||||
AND ${db.qb.jsonExtractIsNull('objects.properties', 'inReplyTo')}
|
||||
AND (outbox_objects.target = '${PUBLIC_GROUP}' OR outbox_objects.target IN ${db.qb.set('?3')})
|
||||
GROUP BY objects.id
|
||||
GROUP BY objects.id ${db.qb.psqlOnly(', actors.id, outbox_objects.actor_id, outbox_objects.published_date')}
|
||||
ORDER by outbox_objects.published_date DESC
|
||||
LIMIT ?4
|
||||
`
|
||||
|
@ -139,7 +139,9 @@ WHERE objects.type='Note'
|
|||
AND ${db.qb.jsonExtractIsNull('objects.properties', 'inReplyTo')}
|
||||
AND outbox_objects.target = '${PUBLIC_GROUP}'
|
||||
${hashtagFilter}
|
||||
GROUP BY objects.id
|
||||
GROUP BY objects.id ${db.qb.psqlOnly(
|
||||
', actors.id, actors.cdate, actors.properties, outbox_objects.actor_id, outbox_objects.published_date'
|
||||
)}
|
||||
ORDER by outbox_objects.published_date DESC
|
||||
LIMIT ?1 OFFSET ?2
|
||||
`
|
||||
|
|
|
@ -143,7 +143,7 @@ WHERE objects.type='Note'
|
|||
${withReplies ? '' : 'AND ' + db.qb.jsonExtractIsNull('objects.properties', 'inReplyTo')}
|
||||
AND outbox_objects.target = '${PUBLIC_GROUP}'
|
||||
AND outbox_objects.actor_id = ?1
|
||||
AND outbox_objects.cdate > ?2
|
||||
AND outbox_objects.cdate > ?2${db.qb.psqlOnly('::timestamp')}
|
||||
ORDER by outbox_objects.published_date DESC
|
||||
LIMIT ?3 OFFSET ?4
|
||||
`
|
||||
|
|
Ładowanie…
Reference in New Issue