* Get the count of PENDING (never-attempted) references without loading * them into memory. Rows marked status='failed' — attempted by a completed * pass, no match — are excluded: they are not outstanding work, only retry * candidates for the #1240 sweep, so they must not trip the #1187 orp
()
| 4947 | * sweep or the `status` pending-refs warning. |
| 4948 | */ |
| 4949 | getUnresolvedReferencesCount(): number { |
| 4950 | if (!this.stmts.getUnresolvedCount) { |
| 4951 | // An index built before schema v8 (1.4.0 and older) has no `status`, |
| 4952 | // and the v8 migration marks every one of its rows pending. A read-only |
| 4953 | // open migrates nothing (`codegraph status`, #2913), so count them all |
| 4954 | // until a writer's open has migrated it. |
| 4955 | if (!this.hasSchema('unresolved_refs', 'status')) { |
| 4956 | return (this.db.prepare('SELECT COUNT(*) as count FROM unresolved_refs').get() as { count: number }).count; |
| 4957 | } |
| 4958 | this.stmts.getUnresolvedCount = this.db.prepare( |
| 4959 | "SELECT COUNT(*) as count FROM unresolved_refs WHERE status = 'pending'" |
| 4960 | ); |
| 4961 | } |
| 4962 | const row = this.stmts.getUnresolvedCount.get() as { count: number }; |
| 4963 | return row.count; |
| 4964 | } |
| 4965 | |
| 4966 | /** |
| 4967 | * Get a batch of PENDING unresolved references using LIMIT/OFFSET |
no test coverage detected