perf(inventory): lazy list, photo thumbnails, indexes, debounced reload
Scale the local inventory to 10k+ varieties: - Render the list with ListView.builder over a flattened header/item model instead of building every tile upfront. - Store a small regenerable JPEG thumbnail per photo (schema v14) and use it for the 48px list avatar; full bytes stay for offer image hosting. Existing photos are backfilled lazily at startup. Thumbnail is local-only (excluded from CRDT sync and backups by the JSON codec). - Add indexes on varieties(is_deleted,is_draft), attachments(parent_type, parent_id,kind), lots(variety_id) via @TableIndex. - Debounce watchInventoryView (~250ms) so a burst of table writes triggers one reload, not seven. - cacheWidth/cacheHeight on the list avatar decode. - Scale test raised 3k -> 10k; migration test v13 -> v14.
This commit is contained in:
parent
2884ddd3c7
commit
3de01bd948
12 changed files with 5114 additions and 34 deletions
|
|
@ -5,6 +5,10 @@ import 'sync_columns.dart';
|
|||
|
||||
/// The identity/accession — one row per distinct thing in the inventory.
|
||||
/// Only [label] is mandatory (progressive disclosure).
|
||||
///
|
||||
/// The index covers the inventory list's hot filter — non-deleted, non-draft
|
||||
/// rows — so it stays fast with a large catalogue.
|
||||
@TableIndex(name: 'idx_varieties_deleted_draft', columns: {#isDeleted, #isDraft})
|
||||
class Varieties extends Table with SyncColumns {
|
||||
TextColumn get label => text()();
|
||||
TextColumn get speciesId => text().nullable()(); // → Species
|
||||
|
|
@ -77,6 +81,10 @@ class SpeciesCommonNames extends Table with SyncColumns {
|
|||
|
||||
/// A homogeneous batch held for a Variety — its own year and its own unit.
|
||||
/// Quantity (commons_core value type) is flattened into columns here.
|
||||
///
|
||||
/// Indexed by [varietyId] — the inventory list joins lots per variety (types,
|
||||
/// shared status, viability), so this avoids a full scan per reload.
|
||||
@TableIndex(name: 'idx_lots_variety', columns: {#varietyId})
|
||||
class Lots extends Table with SyncColumns {
|
||||
TextColumn get varietyId => text()();
|
||||
TextColumn get type =>
|
||||
|
|
@ -181,12 +189,26 @@ class Parties extends Table with SyncColumns {
|
|||
/// rest by SQLCipher) via [bytes]; external files use [uri]. Storing bytes here
|
||||
/// keeps the "no plaintext at rest" rule for photos in Block 1; an external
|
||||
/// encrypted file store is a later optimization.
|
||||
///
|
||||
/// Indexed by (parentType, parentId, kind) — the list's "first photo per
|
||||
/// variety" lookup filters on exactly these.
|
||||
@TableIndex(
|
||||
name: 'idx_attachments_parent',
|
||||
columns: {#parentType, #parentId, #kind},
|
||||
)
|
||||
class Attachments extends Table with SyncColumns {
|
||||
TextColumn get parentType => textEnum<ParentType>()();
|
||||
TextColumn get parentId => text()();
|
||||
TextColumn get kind => textEnum<AttachmentKind>()();
|
||||
TextColumn get uri => text().nullable()();
|
||||
BlobColumn get bytes => blob().nullable()();
|
||||
|
||||
/// A small JPEG thumbnail of [bytes] (photos only), decoded once on save so
|
||||
/// the inventory list never has to decode the full-resolution photo for a
|
||||
/// 48px avatar. Purely derived, local and regenerable — it is EXCLUDED from
|
||||
/// CRDT sync payloads and backups (see [SyncColumns] usage); a peer or a
|
||||
/// restored backup regenerates it lazily via `backfillThumbnails`.
|
||||
BlobColumn get thumbnail => blob().nullable()();
|
||||
TextColumn get mimeType => text().nullable()();
|
||||
|
||||
/// Display order among sibling attachments (lower first). The lowest-ordered
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue