63 lines
2.1 KiB
SQL
63 lines
2.1 KiB
SQL
SELECT
|
|
'player' AS subjectType,
|
|
CAST(profile.id AS TEXT) AS subjectId,
|
|
CAST(profile.id AS TEXT) AS userProfileId,
|
|
CAST(prisoner.id AS TEXT) AS gamePlayerId,
|
|
NULL AS vehicleId,
|
|
NULL AS baseId,
|
|
entity.location_x AS x,
|
|
entity.location_y AS y,
|
|
entity.location_z AS z,
|
|
datetime(prisoner.last_save_time, 'unixepoch') AS observedAt
|
|
FROM user_profile profile
|
|
JOIN prisoner ON prisoner.id = profile.prisoner_id
|
|
JOIN prisoner_entity ON prisoner_entity.prisoner_id = prisoner.id
|
|
JOIN entity ON entity.id = prisoner_entity.entity_id
|
|
WHERE (:subjectType IS NULL OR :subjectType = 'player')
|
|
UNION ALL
|
|
SELECT
|
|
'vehicle' AS subjectType,
|
|
CAST(spawner.vehicle_entity_id AS TEXT) AS subjectId,
|
|
NULL AS userProfileId,
|
|
NULL AS gamePlayerId,
|
|
CAST(spawner.vehicle_entity_id AS TEXT) AS vehicleId,
|
|
NULL AS baseId,
|
|
entity.location_x AS x,
|
|
entity.location_y AS y,
|
|
entity.location_z AS z,
|
|
datetime(spawner.vehicle_last_access_time, 'unixepoch') AS observedAt
|
|
FROM vehicle_spawner spawner
|
|
JOIN entity ON entity.id = spawner.vehicle_entity_id
|
|
WHERE (:subjectType IS NULL OR :subjectType = 'vehicle')
|
|
UNION ALL
|
|
SELECT
|
|
'base' AS subjectType,
|
|
CAST(base.id AS TEXT) AS subjectId,
|
|
CAST(base.owner_user_profile_id AS TEXT) AS userProfileId,
|
|
NULL AS gamePlayerId,
|
|
NULL AS vehicleId,
|
|
CAST(base.id AS TEXT) AS baseId,
|
|
base.location_x AS x,
|
|
base.location_y AS y,
|
|
0 AS z,
|
|
NULL AS observedAt
|
|
FROM base
|
|
WHERE (:subjectType IS NULL OR :subjectType = 'base')
|
|
UNION ALL
|
|
SELECT
|
|
'flag' AS subjectType,
|
|
CAST(flag.element_id AS TEXT) AS subjectId,
|
|
CAST(element.owner_profile_id AS TEXT) AS userProfileId,
|
|
CAST(owner.prisoner_id AS TEXT) AS gamePlayerId,
|
|
NULL AS vehicleId,
|
|
CAST(element.base_id AS TEXT) AS baseId,
|
|
element.location_x AS x,
|
|
element.location_y AS y,
|
|
element.location_z AS z,
|
|
datetime(flag.overtake_end_time, 'unixepoch') AS observedAt
|
|
FROM base_element_flag flag
|
|
JOIN base_element element ON element.element_id = flag.element_id
|
|
LEFT JOIN user_profile owner ON owner.id = element.owner_profile_id
|
|
WHERE (:subjectType IS NULL OR :subjectType = 'flag')
|
|
LIMIT COALESCE(:limit, 500)
|