feat(inventory): photo-first drafts + on-device OCR (digitization R2+R4)
Lower the bulk-digitization cliff with two more routes on top of the already-landed CSV import and "save and add another": - Photo-first drafts (capture now, catalogue later): burst-capture photos (camera or multi-gallery) into unnamed draft varieties, shown in a "to catalogue" tray, hidden from the main list until named. Adds Variety.isDraft (schema), addDraftVariety/watchDrafts/nameDraft, the triage sheet and the inventory banner. - On-device OCR label suggestion (Tesseract, offline, no Google): a "Suggest name from photo" button in the naming dialog behind a LabelTextExtractor interface (Tesseract on Android/iOS, no-op elsewhere). Reads the largest print via hOCR bounding boxes, drops boilerplate/low-confidence noise, preprocesses (grayscale, contrast, upscale) and sweeps rotations (0-315 deg) so tilted packets still read. Bundles tessdata_fast eng+spa; validated on-device against real packets. The photo is written to a temp file deleted immediately in a finally block (the plugin needs a path) - a bounded, documented exception to no-plaintext-at-rest. This commit also carries the co-developed schema evolution v5 to v8 that shares these files (organic flag, species viability years, crop calendar, lot provenance/abundance/preservation format, condition checks) plus their exports/migrations and i18n. Tests: CSV/draft/OCR unit + widget + migration green in isolation. Note: the full widget suite currently hangs (>10 min) - under investigation.
This commit is contained in:
parent
12a2ee2d64
commit
6809dc6143
89 changed files with 17141 additions and 228 deletions
|
|
@ -12,6 +12,35 @@ class Varieties extends Table with SyncColumns {
|
|||
TextColumn get category =>
|
||||
text().nullable()(); // free text, prefilled from family
|
||||
TextColumn get notes => text().nullable()();
|
||||
|
||||
/// A draft captured photo-first ("capture now, catalogue later"): it holds a
|
||||
/// photo but not yet a real name, and lives in the "to catalogue" tray until
|
||||
/// the user labels it. A plain LWW scalar, so it merges like any other field.
|
||||
BoolColumn get isDraft => boolean().withDefault(const Constant(false))();
|
||||
|
||||
/// Grower-declared organic ("eco") provenance. A self-declaration, not a
|
||||
/// third-party certification (that would be a separate flag). Surfaced as a
|
||||
/// badge and an inventory filter. A plain LWW scalar.
|
||||
BoolColumn get isOrganic => boolean().withDefault(const Constant(false))();
|
||||
|
||||
/// A stewardship intent set by the grower: "regrow this variety this season"
|
||||
/// before its stock or vitality runs out. Complements the automatic viability
|
||||
/// warning (which is age-derived) with an explicit human decision. Surfaced
|
||||
/// as a badge and an inventory filter. A plain LWW scalar.
|
||||
BoolColumn get needsReproduction =>
|
||||
boolean().withDefault(const Constant(false))();
|
||||
|
||||
/// Advisory crop-calendar months, typical for this variety — when to sow,
|
||||
/// transplant, expect flowers/fruit, and harvest seed. Each phase usually
|
||||
/// spans several months (e.g. sow in spring *and* autumn), so each is a set
|
||||
/// of months packed as a 12-bit mask (see `domain/crop_calendar.dart`), an
|
||||
/// optional LWW scalar; null means "not recorded". Guidance, not a per-year
|
||||
/// actuals log (that path stays available via Movements).
|
||||
IntColumn get sowMonths => integer().nullable()();
|
||||
IntColumn get transplantMonths => integer().nullable()();
|
||||
IntColumn get floweringMonths => integer().nullable()();
|
||||
IntColumn get fruitingMonths => integer().nullable()();
|
||||
IntColumn get seedHarvestMonths => integer().nullable()();
|
||||
}
|
||||
|
||||
/// The multiple common names of a Variety (separate table so concurrent adds
|
||||
|
|
@ -30,6 +59,13 @@ class Species extends Table with SyncColumns {
|
|||
IntColumn get gbifKey => integer().nullable()();
|
||||
TextColumn get family => text().nullable()();
|
||||
BoolColumn get isBundled => boolean().withDefault(const Constant(false))();
|
||||
|
||||
/// Typical seed longevity in years under normal home storage — public-domain
|
||||
/// reference data bundled with the catalog (agricultural-extension viability
|
||||
/// tables). Drives the "expiring / past viability" warning on aging lots by
|
||||
/// comparing against a lot's [Lots.harvestYear]. Nullable: unknown for
|
||||
/// species without a bundled figure.
|
||||
IntColumn get viabilityYears => integer().nullable()();
|
||||
}
|
||||
|
||||
/// Localized common names for the catalog (bundled).
|
||||
|
|
@ -56,6 +92,23 @@ class Lots extends Table with SyncColumns {
|
|||
TextColumn get offerStatus =>
|
||||
textEnum<OfferStatus>().withDefault(const Constant('private'))();
|
||||
TextColumn get seedbankId => text().nullable()();
|
||||
|
||||
/// Provenance of this batch, kept as lightweight free text so it needs no
|
||||
/// Party/Movement to record (the rigorous exchange path stays via Movements).
|
||||
/// [originName] = who grew or gave the seeds; [originPlace] = where they come
|
||||
/// from (with region/province). Both optional LWW scalars.
|
||||
TextColumn get originName => text().nullable()();
|
||||
TextColumn get originPlace => text().nullable()();
|
||||
|
||||
/// Optional coarse "how much I have" for this lot — see [Abundance]. An
|
||||
/// offline alternative to the precise Quantity columns; either, both, or
|
||||
/// neither may be set.
|
||||
TextColumn get abundance => textEnum<Abundance>().nullable()();
|
||||
|
||||
/// How the (seed) lot is physically conserved — see [PreservationFormat].
|
||||
/// Distinct from [storageLocation]. Optional.
|
||||
TextColumn get preservationFormat =>
|
||||
textEnum<PreservationFormat>().nullable()();
|
||||
}
|
||||
|
||||
/// Optional germination history for a Lot; percent is derived in code.
|
||||
|
|
@ -67,6 +120,17 @@ class GerminationTests extends Table with SyncColumns {
|
|||
TextColumn get notes => text().nullable()();
|
||||
}
|
||||
|
||||
/// Optional storage-condition history for a seed Lot: periodic physical checks
|
||||
/// of how many containers hold it and the state of the drying agent. Mirrors
|
||||
/// [GerminationTests] — a dated log under a Lot, newest shown first.
|
||||
class ConditionChecks extends Table with SyncColumns {
|
||||
TextColumn get lotId => text()();
|
||||
IntColumn get checkedOn => integer().nullable()(); // date, ms since epoch
|
||||
IntColumn get containerCount => integer().nullable()(); // "botes"
|
||||
TextColumn get desiccantState => textEnum<DesiccantState>().nullable()();
|
||||
TextColumn get notes => text().nullable()();
|
||||
}
|
||||
|
||||
/// The append-only event log on a Lot — history + provenance DAG.
|
||||
class Movements extends Table with AppendOnlyColumns {
|
||||
TextColumn get lotId => text()();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue