Database / Planning

compact_block

Compact block: a cluster of farmers' plots managed together.

Table factsheetagri_db
Written by
  • Unit data down-sync per VO (UnitDataSetupViewModel, SetupForUnitInChargeLogin -> Repo.saveCompactBlock)
  • Create/edit block (CompactBlockViewModel, CompactBlockFarmersFragment, BridgeSyncHelper -> insertCompactBlock)
  • Response handlers CompactBlockPost/Patch/DeleteRH
Read by
  • Compact block screens (getAllCompactBlockWithAllData)
Filled from
GET gateway/portfolio-service/api/v1/compact-block/filter
GET gateway/portfolio-service/api/v1/compact-block?direction=desc
Sync
appId is a client UUID primary key. syncStatus starts at SYNC_DONE for downloaded rows, becomes SYNC_NOT_INITIALIZED when the row is created or edited on the device, and goes back to SYNC_DONE when the response handler writes the server id. opId holds the id of the last queued library operation. Sync entity COMPACT_BLOCK.
Source
data/src/main/java/org/mindtree/app/agricultor/data/entity/CompactBlock.kt

Columns

ColumnTypeNullKeyMeaning
idINTEGERYesServer id. Null or 0 until the row is synced.
nameTEXTYesBlock name.
compactBlockCreatedAtTEXTYesServer create time.
compactBlockLastUpdateAtTEXTYesServer update time.
titleIdTEXTYesIndexStable business key shared by all versions of the record. Index: unique.
noteTEXTYesFree note.
activeINTEGERYesSoft-delete flag (1 = active).
inActiveReasonTEXTYesReason given when the row was deactivated.
createdByAppINTEGERYesAudit: app that created/last changed the row.
lastModifiedByAppINTEGERYesAudit: app that created/last changed the row.
createdFromDeviceTEXTYesAudit: device id that created/last changed the row.
lastUpdatedFromDeviceTEXTYesAudit: device id that created/last changed the row.
appIdTEXTNoPKClient-side UUID. Defaults to a random UUID when the object is built, including when server JSON is parsed.
opIdTEXTYesId of the last queued operation in the library queue (SYNC_QUEUE_DB).
syncStatusTEXTNoSYNC_NOT_INITIALIZED | IN_SYNC_QUEUE | SYNC_DONE (default).

Notes

  • getAllCompactBlockWithAllData: active blocks, newest first, with members joined by titleId.
  • disabledCompactBlock soft-deletes by titleId.
  • Possible bug · unverified saveCompactBlock uses insert(List) = IGNORE on conflict, so existing blocks are never refreshed from the server.