implemented a lot of features

This commit is contained in:
Daan Meijer committed 2026-09-29 00:32:01 +02:00
1 parent 62f1767df3
commit bcb9be5da9
141 files changed
+10705 -385

No files matched your search

@@ -0,0 +1,41 @@
import { BaseSchema } from '@adonisjs/lucid/schema'
/**
* Spot listings (CONCEPT.md D29): old spots become a release without files
* (source `spot`), whose NZB is fetched when first downloaded. Search shows
* releases with files or spot listings, so the partial release indexes
* cover both. Spots are verified from their overview when fetched.
*/
const VISIBLE = `(file_count > 0 OR source = 'spot')`
const INDEXES: [name: string, definition: string][] = [
['releases_name_trgm', `USING gin (name gin_trgm_ops)`],
['releases_contents_trgm', `USING gin ((contents::text) gin_trgm_ops)`],
['releases_posted_at_idx', `(posted_at DESC NULLS LAST)`],
['releases_size_index', `(size)`],
['releases_file_count_index', `(file_count)`],
['releases_complete_idx', `(complete)`],
['releases_category_idx', `(category)`],
]
export default class extends BaseSchema {
static disableTransactions = true
async up() {
await this.db.rawQuery(`ALTER TABLE spots ADD COLUMN IF NOT EXISTS verified boolean`)
await this.swap(VISIBLE)
}
async down() {
await this.swap('file_count > 0')
await this.db.rawQuery(`ALTER TABLE spots DROP COLUMN IF EXISTS verified`)
}
private async swap(predicate: string) {
for (const [name, definition] of INDEXES) {
await this.db.rawQuery(`DROP INDEX CONCURRENTLY IF EXISTS ${name}_next`)
await this.db.rawQuery(`CREATE INDEX CONCURRENTLY ${name}_next ON releases ${definition} WHERE ${predicate}`)
await this.db.rawQuery(`DROP INDEX CONCURRENTLY IF EXISTS ${name}`)
await this.db.rawQuery(`ALTER INDEX ${name}_next RENAME TO ${name}`)
}
}
}