Skip to main content

maps

One row per map (site plan, floor plan, or other spatial reference). Identified by id; lives on a single project. Carries metadata about the map file — the image itself is not stored here.

Source Mapping

CouchDB document type: a "map" document (see asyncconvert.py's maps(obj) handler).

ColumnCouchDB sourceNotes
ididMap identifier; unique within the dataset across projects (project-scoped semantics — see Pitfalls).
namenameHuman-readable map name. Free text.
groupidgroupIdThe map_groups.id this map belongs to. May be empty when the map is ungrouped.
groupnamegroupDenormalized group name from source — convenient but can drift from map_groups.name.
authorcontent.authorEmail of the user who uploaded / authored the map.
creationdatedates.creationDateParsed via parseDate(...).
lastmodifieddatedates.lastModifiedDateParsed via parseDate(...).
archivedarchivedParsed via parseDate(...). NULL for active maps.
projectiddatabaseThe project this map belongs to.
couchdbidcouchDbIdLegacy CouchDB document identifier.

The maps table does not carry pixel or geographic coordinates. Spatial positioning of tickets on a map is captured on tickets.x, tickets.y, tickets.latitude, and tickets.longitude.

Column Reference

ColumnTypeNullableDescription
archivedDATETIMEyesArchive timestamp; NULL for active maps.
authorVARCHAR(255)yesEmail of the user who authored / uploaded the map.
creationdateDATETIMEyesWhen the map was created upstream.
lastmodifieddateDATETIMEyesWhen the upstream map was last edited.
groupidVARCHAR(255)yesForeign-key reference to map_groups.id.
groupnameVARCHAR(255)yesDenormalized group name; convenience copy of map_groups.name from source.
nameTEXTyesHuman-readable map name (free text).
idVARCHAR(255)noPrimary key. Map identifier; project-scoped (see Pitfalls).
projectidVARCHAR(255)yesThe project this map belongs to.
couchdbidVARCHAR(255)yesLegacy CouchDB identifier.

Keys

  • Primary key: id

Indexes

  • idx_project on projectid

Relationships

DirectionOther tableJoinCardinality
outgoingmap_groupsmaps.groupid = map_groups.idmany maps → one group
outgoingprojectsmaps.projectid = projects.idmany maps → one project
outgoingusers (author)maps.author = users.emailmany maps → one author
incomingaudits_mapsaudits_maps.mapid = maps.idone map → many audit links
incomingticketstickets.map = maps.idone map → many tickets placed on it

None of these are foreign-keyed in MariaDB; joins are by string match.

Refresh Semantics

A row is upserted when its map document is observed in source data, and replaced on subsequent observations. Archive is a soft state: the archived DATETIME is set when the map is archived upstream, but the row is not removed and existing tickets and audits that reference it continue to resolve.

A reindex with type=map (or a full reindex) drops the maps table and rebuilds it from source. See backend/services/sql.py for the drop and setup paths.

Common Queries

List active maps on a project

SELECT id, name, groupname, creationdate
FROM maps
WHERE projectid = 'your_project_id'
AND archived IS NULL
ORDER BY name;

Find archived maps

SELECT id, name, groupname, archived
FROM maps
WHERE projectid = 'your_project_id'
AND archived IS NOT NULL
ORDER BY archived DESC;

Maps by author

SELECT
author,
COUNT(*) AS maps_uploaded
FROM maps
WHERE archived IS NULL
GROUP BY author
ORDER BY maps_uploaded DESC;

Cross-table queries (audits per map, tickets per map, maps grouped by their map group) live on the Maps domain landing.

Pitfalls

  • id is project-scoped, not global. Two projects each with a "Ground Floor" map produce two maps rows with two different id values. Joining on id does not give you cross-project usage — group by name for that, with the usual free-text caveats.
  • groupname can drift from map_groups.name. It is a denormalized copy from source. If the group is renamed, the authoritative value is map_groups.name; groupname may lag until the map document is re-synced.
  • No spatial data on this table. The map's pixel and geo coordinates do not live here. Tickets carry (x, y) and (latitude, longitude) for their position on the map.
  • No FK constraints. groupid, projectid, and author are joined by string match. If an upstream group is deleted without maps being re-synced, groupid may point to a missing map_groups row.