gws.plugin.qfieldcloud.delta¶
Storage of the deltas sent by QField, with their status.
Source code: gws.plugin.qfieldcloud.delta
Module Contents¶
- gws.plugin.qfieldcloud.delta.cleanup(db: gws.lib.sqlitex.Object, life_time: int)¶
Remove delta records older than
life_timeseconds, and the payload links to them.
- gws.plugin.qfieldcloud.delta.extract_changes(drs: list[Record]) list[gws.plugin.qfieldcloud.patcher.Change]¶
Convert delta records to patcher changes.
- gws.plugin.qfieldcloud.delta.get_for_payload(db: gws.lib.sqlitex.Object, payload_id: str, user_name: str) list[Record]¶
Load the delta records of a payload sent by a user, empty if not found.
- gws.plugin.qfieldcloud.delta.get_history(db: gws.lib.sqlitex.Object, user_name: str, limit: int, offset: int) list[tuple[Record, str]]¶
Load delta records of a user, newest first, each with the id of the last payload it was sent with.
- gws.plugin.qfieldcloud.delta.get_one(db: gws.lib.sqlitex.Object, uid: str, user_name: str) Record | None¶
Load a delta record of a user,
Noneif not found.
- gws.plugin.qfieldcloud.delta.link_payload(db: gws.lib.sqlitex.Object, payload_id: str, delta_uids: list[str], user_name: str)¶
Link a payload to its delta records, replacing the links stored for the same payload and user.
- gws.plugin.qfieldcloud.delta.new_record(uid: str, d: gws.plugin.qfieldcloud.api.Delta, user_name: str) Record¶
Create a pending delta record for a delta.
- gws.plugin.qfieldcloud.delta.parse_payload(text: str) gws.plugin.qfieldcloud.api.DeltasPayload¶
Parse the content of a delta file, raise
gws.BadRequestErrorif it is invalid.
- gws.plugin.qfieldcloud.delta.PENDING_TIMEOUT = 300¶
Time in seconds after which a pending delta is considered failed.
- class gws.plugin.qfieldcloud.delta.Record¶
Bases:
gws.DataA delta as stored on the server, with its status.
- content: gws.plugin.qfieldcloud.api.Delta¶
Delta as sent by QField.
- status: gws.plugin.qfieldcloud.api.DeltaStatusType¶
Delta status.
- gws.plugin.qfieldcloud.delta.set_status_for_all(db: gws.lib.sqlitex.Object, drs: list[Record], status: gws.plugin.qfieldcloud.api.DeltaStatusType, output: str = '')¶
Set the status and output of delta records, in the objects and in the database.
- gws.plugin.qfieldcloud.delta.status(dr: Record, payload_id: str) gws.plugin.qfieldcloud.core.DeltaStatus¶
Convert a delta record to the status returned for a payload, reporting a stale pending delta as failed.
- gws.plugin.qfieldcloud.delta.STORAGE_DDL = Multiline-String¶
Show Value
""" CREATE TABLE IF NOT EXISTS deltas ( uid TEXT PRIMARY KEY, created_by TEXT NOT NULL, id TEXT NOT NULL, client_id TEXT, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, status TEXT NOT NULL, output TEXT, content TEXT NOT NULL ); CREATE INDEX IF NOT EXISTS deltas_created_at ON deltas (created_at); CREATE INDEX IF NOT EXISTS deltas_created_by_created_at ON deltas (created_by, created_at); CREATE TABLE IF NOT EXISTS payloads ( created_by TEXT NOT NULL, payload_id TEXT NOT NULL, delta_uid TEXT NOT NULL, PRIMARY KEY (created_by, payload_id, delta_uid) ); CREATE INDEX IF NOT EXISTS payloads_delta_uid ON payloads (delta_uid); """
- gws.plugin.qfieldcloud.delta.store_all(db: gws.lib.sqlitex.Object, drs: list[Record])¶
Store delta records, replacing the stored ones with the same uid.