You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Returns a list of candidate filesets for glk engines that can be merged
1304
+
"""
1305
+
withconn.cursor() ascursor:
1306
+
# Returns those filesets which have all detection files matching in the set fileset filtered by engine, file name and file size(if not -1) sorted in descending order of matches
1307
+
1308
+
query="""
1309
+
WITH candidate_fileset AS (
1310
+
SELECT fs.id AS fileset_id, f.size
1311
+
FROM file f
1312
+
JOIN fileset fs ON f.fileset = fs.id
1313
+
JOIN game g ON g.id = fs.game
1314
+
JOIN engine e ON e.id = g.engine
1315
+
JOIN transactions t ON t.fileset = fs.id
1316
+
WHERE fs.id != %s
1317
+
AND e.engineid = %s
1318
+
AND f.detection = 1
1319
+
AND t.transaction != %s
1320
+
AND (g.gameid = %s OR (g.gameid != %s AND g.gameid LIKE %s))
1321
+
),
1322
+
total_detection_files AS (
1323
+
SELECT cf.fileset_id, COUNT(*) AS detection_files_found
1324
+
FROM candidate_fileset cf
1325
+
GROUP BY fileset_id
1326
+
),
1327
+
set_fileset AS (
1328
+
SELECT size FROM file
1329
+
WHERE fileset = %s
1330
+
),
1331
+
matched_detection_files AS (
1332
+
SELECT cf.fileset_id, COUNT(*) AS match_files_count
1333
+
FROM candidate_fileset cf
1334
+
JOIN set_fileset sf ON
1335
+
cf.size = sf.size OR cf.size = 0
1336
+
GROUP BY cf.fileset_id
1337
+
),
1338
+
valid_matched_detection_files AS (
1339
+
SELECT mdf.fileset_id, mdf.match_files_count AS valid_match_files_count
1340
+
FROM matched_detection_files mdf
1341
+
JOIN total_detection_files tdf ON tdf.fileset_id = mdf.fileset_id
1342
+
WHERE tdf.detection_files_found <= mdf.match_files_count
1343
+
),
1344
+
max_match_count AS (
1345
+
SELECT MAX(valid_match_files_count) AS max_count FROM valid_matched_detection_files
1346
+
)
1347
+
SELECT vmdf.fileset_id
1348
+
FROM valid_matched_detection_files vmdf
1349
+
JOIN total_detection_files tdf ON vmdf.fileset_id = tdf.fileset_id
1350
+
JOIN max_match_count mmc ON vmdf.valid_match_files_count = mmc.max_count
0 commit comments