Rebuild SCUM plugin-owned data flow

This commit is contained in:
npc0-hue
2026-08-18 07:01:17 +08:00
parent 302f1f64b7
commit 98bf944f4c
39 changed files with 1832 additions and 223 deletions
@@ -1,6 +1,6 @@
SELECT
'player' AS subjectType,
CAST(profile.id AS TEXT) AS subjectId,
account.id AS subjectId,
CAST(profile.id AS TEXT) AS userProfileId,
CAST(prisoner.id AS TEXT) AS gamePlayerId,
NULL AS vehicleId,
@@ -11,11 +11,12 @@ SELECT
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
WHERE (:subjectType IS NULL OR :subjectType = 'player')
AND (:subjectId IS NULL OR CAST(profile.id AS TEXT) = :subjectId)
AND (:subjectId IS NULL OR account.id = :subjectId)
UNION ALL
SELECT
'vehicle', CAST(spawner.vehicle_entity_id AS TEXT), NULL, NULL,
@@ -8,7 +8,7 @@ SELECT
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
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
@@ -1,8 +1,8 @@
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,
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,
@@ -11,8 +11,7 @@ SELECT
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
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
@@ -2,7 +2,7 @@ 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,
COALESCE(NULLIF(profile.name, ''), NULLIF(account.name, ''), account.id) AS displayName,
CAST(member.squad_id AS TEXT) AS squadId,
squad.name AS squadName,
profile.fame_points AS famePoints,
@@ -13,8 +13,8 @@ SELECT
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
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
@@ -24,7 +24,7 @@ LEFT JOIN bank_account_registry bank ON bank.account_owner_user_profile_id = pro
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
AND (:search IS NULL OR COALESCE(NULLIF(profile.name, ''), NULLIF(account.name, ''), account.id) LIKE '%' || :search || '%')
GROUP BY account.id
ORDER BY profile.last_login_time DESC
LIMIT COALESCE(:limit, 500)