Remove SCUM sqlite user projections

This commit is contained in:
npc0-hue
2026-09-14 13:41:44 +08:00
parent b1f102bafb
commit ecdca8e28b
76 changed files with 2264 additions and 1558 deletions
@@ -1,20 +0,0 @@
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)
@@ -1,23 +0,0 @@
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)
@@ -1,51 +0,0 @@
SELECT
'player' AS subjectType,
account.id AS subjectId,
CAST(profile.id AS TEXT) AS userProfileId,
CAST(prisoner.id AS TEXT) AS gamePlayerId,
CAST(mount.vehicle_entity_id AS TEXT) 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 user account ON account.id = profile.user_id
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
LEFT JOIN prisoner_vehicle_mountee_info mount ON mount.prisoner_id = prisoner.id
WHERE (:subjectType IS NULL OR :subjectType = 'player')
AND (:subjectId IS NULL OR account.id = :subjectId)
AND (:activeWithinSeconds IS NULL OR profile.last_logout_time IS NULL OR profile.last_login_time > profile.last_logout_time OR prisoner.last_save_time >= CAST(strftime('%s', 'now') AS INTEGER) - :activeWithinSeconds OR profile.last_login_time >= strftime('%Y-%m-%dT%H:%M:%fZ', 'now', printf('-%d seconds', :activeWithinSeconds)))
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)
AND (:activeWithinSeconds IS NULL OR spawner.vehicle_last_access_time >= CAST(strftime('%s', 'now') AS INTEGER) - :activeWithinSeconds)
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)
@@ -1,10 +0,0 @@
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)
@@ -1,15 +0,0 @@
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
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)
@@ -1,19 +0,0 @@
SELECT
CAST(squad.id AS TEXT) AS squadId,
COALESCE(squad.name, '') AS name,
MAX(CASE WHEN member.rank = 4 THEN CAST(member.user_profile_id AS TEXT) END) AS leaderProfileId,
MAX(CASE WHEN member.rank = 4 THEN CAST(member_profile.prisoner_id AS TEXT) END) 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 user_profile member_profile ON member_profile.id = member.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)
@@ -1,32 +0,0 @@
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)
@@ -1,35 +0,0 @@
SELECT
CAST(profile.id AS TEXT) AS userProfileId,
account.id AS steamId,
CAST(prisoner.id AS TEXT) AS gamePlayerId,
COALESCE(NULLIF(profile.name, ''), NULLIF(account.name, ''), account.id) AS displayName,
account.last_direct_connection_address AS lastLoginIp,
account.creation_time AS registeredAt,
CAST(member.squad_id AS TEXT) AS squadId,
squad.name AS squadName,
profile.fame_points AS famePoints,
profile.money_balance AS moneyBalance,
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,
profile.last_logout_time AS lastLogoutTime,
strftime('%Y-%m-%dT%H:%M:%SZ', prisoner.last_save_time, 'unixepoch') AS lastSaveTime
FROM user account
LEFT JOIN user_profile profile ON profile.user_id = account.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(NULLIF(profile.name, ''), NULLIF(account.name, ''), account.id) LIKE '%' || :search || '%')
AND (:activeWithinSeconds IS NULL OR profile.last_logout_time IS NULL OR profile.last_login_time > profile.last_logout_time OR profile.last_login_time >= strftime('%Y-%m-%dT%H:%M:%fZ', 'now', printf('-%d seconds', :activeWithinSeconds)) OR prisoner.last_save_time >= CAST(strftime('%s', 'now') AS INTEGER) - :activeWithinSeconds)
GROUP BY account.id
ORDER BY profile.last_login_time DESC
LIMIT COALESCE(:limit, 500)
@@ -1,25 +0,0 @@
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,
1 AS existsInGame,
group_concat(DISTINCT CAST(mount.prisoner_id AS TEXT)) AS mountedPrisonerIds,
group_concat(DISTINCT CAST(mounted_profile.id AS TEXT)) AS mountedUserProfileIds,
group_concat(DISTINCT mounted_profile.user_id) AS mountedSteamIds
FROM vehicle_spawner spawner
JOIN entity ON entity.id = spawner.vehicle_entity_id
LEFT JOIN prisoner_vehicle_mountee_info mount ON mount.vehicle_entity_id = spawner.vehicle_entity_id
LEFT JOIN prisoner mounted_prisoner ON mounted_prisoner.id = mount.prisoner_id
LEFT JOIN user_profile mounted_profile ON mounted_profile.prisoner_id = mounted_prisoner.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 || '%')
AND (:activeWithinSeconds IS NULL OR spawner.vehicle_last_access_time >= CAST(strftime('%s', 'now') AS INTEGER) - :activeWithinSeconds)
GROUP BY spawner.vehicle_entity_id
ORDER BY spawner.vehicle_last_access_time DESC
LIMIT COALESCE(:limit, 500)