Every group is tiled from article 1 now: one range with status 'ancient' covers what had expired on the server before the group was planned. Nothing selects it (leases, prefetcher, corpus fill, tail merger all take 'planned'), the status panel reports it apart, the search's history stats leave it out. Migration 6700 adds it for the groups planned before; Planner.historyRows (now a pure function, unit-tested) for new groups. The status bands are ordered by an explicit key: the ancient row at priority 0 tied "history 0-999" with "window 0". Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
21 lines
845 B
TypeScript
21 lines
845 B
TypeScript
import { BaseSchema } from '@adonisjs/lucid/schema'
|
||
|
||
/**
|
||
* One "ancient" range a group, articles 1 … (its first range − 1): what had expired on the server before the
|
||
* group was planned (the planner cuts from the low watermark). Status 'ancient': nothing to fetch, never leased,
|
||
* so the tiling is complete from article 1 and the span below the low watermark is on record (user, 2026-10-28).
|
||
* Planner.historyRows adds it for groups planned from now on.
|
||
*/
|
||
export default class extends BaseSchema {
|
||
async up() {
|
||
this.schema.raw(
|
||
`INSERT INTO ranges (group_id, start_id, end_id, next_id, priority, status)
|
||
SELECT group_id, 1, min(start_id) - 1, 1, 0, 'ancient' FROM ranges GROUP BY group_id HAVING min(start_id) > 1`
|
||
)
|
||
}
|
||
|
||
async down() {
|
||
this.schema.raw(`DELETE FROM ranges WHERE status = 'ancient'`)
|
||
}
|
||
}
|