feat(scum): rebuild plugin-owned management data
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
SELECT
|
||||
CAST(round.event_id AS TEXT) || ':' || CAST(round.id AS TEXT) || ':' || COALESCE(CAST(stats.user_profile_id AS TEXT), 'summary') AS eventRecordId,
|
||||
CAST(round.event_id AS TEXT) AS eventId,
|
||||
CAST(round.id AS TEXT) AS roundId,
|
||||
CAST(stats.user_profile_id AS TEXT) AS userProfileId,
|
||||
round.start_time AS startTime,
|
||||
round.end_time AS endTime,
|
||||
CASE WHEN round.end_time IS NULL OR round.end_time = '' THEN 'active' ELSE 'finished' END AS state,
|
||||
stats.score AS score,
|
||||
stats.enemy_kills AS enemyKills,
|
||||
stats.team_kills AS teamKills,
|
||||
stats.deaths AS deaths,
|
||||
stats.assists AS assists,
|
||||
stats.headshots AS headshots
|
||||
FROM event_round round
|
||||
LEFT JOIN event_round_stats stats ON stats.round_id = round.id
|
||||
WHERE (:eventId IS NULL OR CAST(round.event_id AS TEXT) = :eventId)
|
||||
AND (:userProfileId IS NULL OR CAST(stats.user_profile_id AS TEXT) = :userProfileId)
|
||||
ORDER BY round.id DESC, stats.score DESC
|
||||
LIMIT COALESCE(:limit, 500)
|
||||
@@ -0,0 +1,23 @@
|
||||
SELECT
|
||||
CAST(flag.element_id AS TEXT) AS flagId,
|
||||
CAST(flag.element_id AS TEXT) AS entityId,
|
||||
CAST(element.base_id AS TEXT) AS baseId,
|
||||
CAST(element.owner_profile_id AS TEXT) AS ownerProfileId,
|
||||
CAST(owner.prisoner_id AS TEXT) AS ownerPlayerId,
|
||||
CAST(owner_member.squad_id AS TEXT) AS ownerSquadId,
|
||||
owner_squad.name AS ownerSquadName,
|
||||
CAST(flag.overtaker_user_profile_id AS TEXT) AS overtakerProfileId,
|
||||
strftime('%Y-%m-%dT%H:%M:%SZ', flag.overtake_end_time, 'unixepoch') AS overtakeEndTime,
|
||||
CASE WHEN element.owner_profile_id IS NULL THEN 'unknown' ELSE 'direct' END AS ownershipConfidence,
|
||||
element.location_x AS x,
|
||||
element.location_y AS y,
|
||||
element.location_z AS z
|
||||
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
|
||||
LEFT JOIN squad_member owner_member ON owner_member.user_profile_id = element.owner_profile_id
|
||||
LEFT JOIN squad owner_squad ON owner_squad.id = owner_member.squad_id
|
||||
WHERE (:flagId IS NULL OR CAST(flag.element_id AS TEXT) = :flagId)
|
||||
AND (:ownerProfileId IS NULL OR CAST(element.owner_profile_id AS TEXT) = :ownerProfileId)
|
||||
ORDER BY flag.element_id
|
||||
LIMIT COALESCE(:limit, 500)
|
||||
@@ -0,0 +1,47 @@
|
||||
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,
|
||||
CAST(entity.id AS TEXT) AS entityId,
|
||||
NULL AS baseId,
|
||||
entity.location_x AS x,
|
||||
entity.location_y AS y,
|
||||
entity.location_z AS z,
|
||||
strftime('%Y-%m-%dT%H:%M:%SZ', 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')
|
||||
AND (:subjectId IS NULL OR CAST(profile.id AS TEXT) = :subjectId)
|
||||
UNION ALL
|
||||
SELECT
|
||||
'vehicle', CAST(spawner.vehicle_entity_id AS TEXT), NULL, NULL,
|
||||
CAST(spawner.vehicle_entity_id AS TEXT), CAST(entity.id AS TEXT), NULL,
|
||||
entity.location_x, entity.location_y, entity.location_z,
|
||||
strftime('%Y-%m-%dT%H:%M:%SZ', spawner.vehicle_last_access_time, 'unixepoch')
|
||||
FROM vehicle_spawner spawner
|
||||
JOIN entity ON entity.id = spawner.vehicle_entity_id
|
||||
WHERE (:subjectType IS NULL OR :subjectType = 'vehicle')
|
||||
AND (:subjectId IS NULL OR CAST(spawner.vehicle_entity_id AS TEXT) = :subjectId)
|
||||
UNION ALL
|
||||
SELECT
|
||||
'base', CAST(base.id AS TEXT), CAST(base.owner_user_profile_id AS TEXT), NULL,
|
||||
NULL, NULL, CAST(base.id AS TEXT), base.location_x, base.location_y, 0, NULL
|
||||
FROM base
|
||||
WHERE (:subjectType IS NULL OR :subjectType = 'base')
|
||||
AND (:subjectId IS NULL OR CAST(base.id AS TEXT) = :subjectId)
|
||||
UNION ALL
|
||||
SELECT
|
||||
'flag', CAST(flag.element_id AS TEXT), CAST(element.owner_profile_id AS TEXT), CAST(owner.prisoner_id AS TEXT),
|
||||
NULL, CAST(flag.element_id AS TEXT), CAST(element.base_id AS TEXT),
|
||||
element.location_x, element.location_y, element.location_z,
|
||||
strftime('%Y-%m-%dT%H:%M:%SZ', flag.overtake_end_time, 'unixepoch')
|
||||
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')
|
||||
AND (:subjectId IS NULL OR CAST(flag.element_id AS TEXT) = :subjectId)
|
||||
LIMIT COALESCE(:limit, 500)
|
||||
@@ -0,0 +1,10 @@
|
||||
SELECT
|
||||
'native:' || CAST(gift.rowid AS TEXT) || ':' || COALESCE(CAST(gift.user_profile_id AS TEXT), 'unknown') || ':' || COALESCE(CAST(gift.map_id AS TEXT), 'unknown') || ':' || COALESCE(CAST(gift.spawn_time AS TEXT), 'unknown') AS timedGiftId,
|
||||
CAST(gift.user_profile_id AS TEXT) AS userProfileId,
|
||||
CAST(gift.map_id AS TEXT) AS mapId,
|
||||
gift.spawn_time AS spawnTime,
|
||||
strftime('%Y-%m-%dT%H:%M:%SZ', gift.spawn_time, 'unixepoch') AS spawnAt
|
||||
FROM finished_timed_gift_spawner gift
|
||||
WHERE (:userProfileId IS NULL OR CAST(gift.user_profile_id AS TEXT) = :userProfileId)
|
||||
ORDER BY gift.spawn_time DESC
|
||||
LIMIT COALESCE(:limit, 500)
|
||||
@@ -0,0 +1,15 @@
|
||||
SELECT
|
||||
CAST(member.squad_id AS TEXT) AS squadId,
|
||||
CAST(member.user_profile_id AS TEXT) AS userProfileId,
|
||||
CAST(profile.prisoner_id AS TEXT) AS gamePlayerId,
|
||||
account.id AS steamId,
|
||||
COALESCE(profile.name, account.name, '') AS displayName,
|
||||
CAST(member.rank AS TEXT) AS rank,
|
||||
CASE WHEN member.rank = 4 THEN 1 ELSE 0 END AS isLeader
|
||||
FROM squad_member member
|
||||
JOIN user_profile profile ON profile.id = member.user_profile_id
|
||||
LEFT JOIN user account ON account.id = profile.user_id
|
||||
WHERE (:squadId IS NULL OR CAST(member.squad_id AS TEXT) = :squadId)
|
||||
AND (:userProfileId IS NULL OR CAST(member.user_profile_id AS TEXT) = :userProfileId)
|
||||
ORDER BY member.squad_id, member.rank DESC, profile.name
|
||||
LIMIT COALESCE(:limit, 500)
|
||||
@@ -0,0 +1,20 @@
|
||||
SELECT
|
||||
CAST(squad.id AS TEXT) AS squadId,
|
||||
COALESCE(squad.name, '') AS name,
|
||||
CAST(leader.user_profile_id AS TEXT) AS leaderProfileId,
|
||||
CAST(leader_profile.prisoner_id AS TEXT) AS leaderPlayerId,
|
||||
COUNT(member.id) AS memberCount,
|
||||
squad.score AS score,
|
||||
squad.member_limit AS memberLimit,
|
||||
squad.message AS message,
|
||||
squad.information AS info,
|
||||
squad.last_member_login_time AS lastMemberLoginTime
|
||||
FROM squad
|
||||
LEFT JOIN squad_member member ON member.squad_id = squad.id
|
||||
LEFT JOIN squad_member leader ON leader.squad_id = squad.id AND leader.rank = 4
|
||||
LEFT JOIN user_profile leader_profile ON leader_profile.id = leader.user_profile_id
|
||||
WHERE (:squadId IS NULL OR CAST(squad.id AS TEXT) = :squadId)
|
||||
AND (:search IS NULL OR COALESCE(squad.name, '') LIKE '%' || :search || '%')
|
||||
GROUP BY squad.id
|
||||
ORDER BY squad.score DESC, squad.id
|
||||
LIMIT COALESCE(:limit, 500)
|
||||
@@ -0,0 +1,32 @@
|
||||
SELECT
|
||||
'active-quest:' || CAST(quest.id AS TEXT) AS taskRecordId,
|
||||
'active-quest' AS taskKind,
|
||||
CAST(quest.user_profile_id AS TEXT) AS userProfileId,
|
||||
CAST(quest.map_id AS TEXT) AS mapId,
|
||||
CAST(quest.id AS TEXT) AS trackingDataSetId,
|
||||
quest.quest_data_asset_path AS dataAssetPath,
|
||||
tracking.sequence_index AS sequenceIndex,
|
||||
CASE WHEN EXISTS (SELECT 1 FROM tracked_quest tracked WHERE tracked.quest_id = quest.id) THEN 1 ELSE 0 END AS isTracked,
|
||||
'active' AS state,
|
||||
quest.completion_deadline AS completionDeadline
|
||||
FROM active_quest quest
|
||||
JOIN tracking_data_set tracking ON tracking.id = quest.id
|
||||
WHERE (:userProfileId IS NULL OR CAST(quest.user_profile_id AS TEXT) = :userProfileId)
|
||||
UNION ALL
|
||||
SELECT
|
||||
'active-task:' || CAST(task.id AS TEXT), 'active-task', CAST(task.user_profile_id AS TEXT), CAST(task.map_id AS TEXT),
|
||||
CAST(task.id AS TEXT), available.task_data_asset_path, tracking.sequence_index,
|
||||
CASE WHEN EXISTS (SELECT 1 FROM tracked_quest tracked WHERE tracked.quest_id = task.id) THEN 1 ELSE 0 END,
|
||||
'active', NULL
|
||||
FROM active_task task
|
||||
JOIN tracking_data_set tracking ON tracking.id = task.id
|
||||
JOIN available_task available ON available.id = task.available_task_id
|
||||
WHERE (:userProfileId IS NULL OR CAST(task.user_profile_id AS TEXT) = :userProfileId)
|
||||
UNION ALL
|
||||
SELECT
|
||||
'available-task:' || CAST(available.id AS TEXT), 'available-task', CAST(available.user_profile_id AS TEXT), CAST(available.map_id AS TEXT),
|
||||
NULL, available.task_data_asset_path, NULL, 0,
|
||||
CASE WHEN available.was_ever_completed = 1 THEN 'completed-before' ELSE 'available' END, NULL
|
||||
FROM available_task available
|
||||
WHERE (:userProfileId IS NULL OR CAST(available.user_profile_id AS TEXT) = :userProfileId)
|
||||
LIMIT COALESCE(:limit, 500)
|
||||
@@ -0,0 +1,30 @@
|
||||
SELECT
|
||||
CAST(profile.id AS TEXT) AS userProfileId,
|
||||
account.id AS steamId,
|
||||
CAST(prisoner.id AS TEXT) AS gamePlayerId,
|
||||
COALESCE(profile.name, account.name, '') AS displayName,
|
||||
CAST(member.squad_id AS TEXT) AS squadId,
|
||||
squad.name AS squadName,
|
||||
profile.fame_points AS famePoints,
|
||||
MAX(CASE WHEN currency.currency_type = 1 THEN currency.account_balance END) AS normalBalance,
|
||||
MAX(CASE WHEN currency.currency_type = 2 THEN currency.account_balance END) AS goldBalance,
|
||||
entity.location_x AS x,
|
||||
entity.location_y AS y,
|
||||
entity.location_z AS z,
|
||||
profile.last_login_time AS lastLoginTime,
|
||||
strftime('%Y-%m-%dT%H:%M:%SZ', prisoner.last_save_time, 'unixepoch') AS lastSaveTime
|
||||
FROM user_profile profile
|
||||
JOIN user account ON account.id = profile.user_id
|
||||
LEFT JOIN prisoner ON prisoner.id = profile.prisoner_id
|
||||
LEFT JOIN prisoner_entity ON prisoner_entity.prisoner_id = prisoner.id
|
||||
LEFT JOIN entity ON entity.id = prisoner_entity.entity_id
|
||||
LEFT JOIN squad_member member ON member.user_profile_id = profile.id
|
||||
LEFT JOIN squad ON squad.id = member.squad_id
|
||||
LEFT JOIN bank_account_registry bank ON bank.account_owner_user_profile_id = profile.id
|
||||
LEFT JOIN bank_account_registry_currencies currency ON currency.bank_account_id = bank.id
|
||||
WHERE (:userProfileId IS NULL OR CAST(profile.id AS TEXT) = :userProfileId)
|
||||
AND (:steamId IS NULL OR account.id = :steamId)
|
||||
AND (:search IS NULL OR COALESCE(profile.name, account.name, '') LIKE '%' || :search || '%')
|
||||
GROUP BY profile.id
|
||||
ORDER BY profile.last_login_time DESC
|
||||
LIMIT COALESCE(:limit, 500)
|
||||
@@ -0,0 +1,16 @@
|
||||
SELECT
|
||||
CAST(spawner.vehicle_entity_id AS TEXT) AS vehicleId,
|
||||
CAST(spawner.vehicle_entity_id AS TEXT) AS entityId,
|
||||
entity.class AS className,
|
||||
spawner.vehicle_alias AS label,
|
||||
entity.location_x AS x,
|
||||
entity.location_y AS y,
|
||||
entity.location_z AS z,
|
||||
strftime('%Y-%m-%dT%H:%M:%SZ', spawner.vehicle_last_access_time, 'unixepoch') AS lastAccessTime,
|
||||
spawner.is_vehicle_functional AS isFunctional
|
||||
FROM vehicle_spawner spawner
|
||||
JOIN entity ON entity.id = spawner.vehicle_entity_id
|
||||
WHERE (:vehicleId IS NULL OR CAST(spawner.vehicle_entity_id AS TEXT) = :vehicleId)
|
||||
AND (:search IS NULL OR spawner.vehicle_alias LIKE '%' || :search || '%' OR entity.class LIKE '%' || :search || '%')
|
||||
ORDER BY spawner.vehicle_last_access_time DESC
|
||||
LIMIT COALESCE(:limit, 500)
|
||||
Reference in New Issue
Block a user