Commit ec847b7f authored by Lukáš Lalinský's avatar Lukáš Lalinský

Make sure the re-used fingerprint_id is always from the re-used track_id

parent fb46b1ee
......@@ -70,21 +70,22 @@ def import_submission(conn, submission):
}
if matches:
match = matches[0]
if match['score'] > const.FINGERPRINT_MERGE_THRESHOLD:
fingerprint['id'] = match['id']
all_track_ids = set()
possible_track_ids = set()
for m in matches:
if m['track_id'] not in all_track_ids:
logger.debug("Fingerprint %d with track %d is %d%% similar", m['id'], m['track_id'], m['score'] * 100)
if can_add_fp_to_track(conn, m['track_id'], submission['fingerprint'], submission['length']):
possible_track_ids.add(m['track_id'])
if not fingerprint['track_id']:
fingerprint['track_id'] = m['track_id']
all_track_ids.add(m['track_id'])
if m['track_id'] in all_track_ids:
continue
all_track_ids.add(m['track_id'])
logger.debug("Fingerprint %d with track %d is %d%% similar", m['id'], m['track_id'], m['score'] * 100)
if can_add_fp_to_track(conn, m['track_id'], submission['fingerprint'], submission['length']):
possible_track_ids.add(m['track_id'])
if not fingerprint['track_id']:
fingerprint['track_id'] = m['track_id']
if m['score'] > const.FINGERPRINT_MERGE_THRESHOLD:
fingerprint['id'] = m['id']
if len(possible_track_ids) > 1:
for group in can_merge_tracks(conn, possible_track_ids):
if match['track_id'] in group and len(group) > 1:
if fingerprint['track_id'] in group and len(group) > 1:
fingerprint['track_id'] = min(group)
group.remove(fingerprint['track_id'])
merge_tracks(conn, fingerprint['track_id'], list(group))
......@@ -94,7 +95,7 @@ def import_submission(conn, submission):
if not fingerprint['id']:
fingerprint['id'] = insert_fingerprint(conn, fingerprint, submission['id'], submission['source_id'])
else:
inc_fingerprint_submission_count(conn, fingerprint['id'])
inc_fingerprint_submission_count(conn, fingerprint['id'], submission['id'], submission['source_id'])
for mbid in mbids:
insert_mbid(conn, fingerprint['track_id'], mbid, submission['id'], submission['source_id'])
if submission['puid'] and submission['puid'] != '00000000-0000-0000-0000-000000000000':
......@@ -110,7 +111,7 @@ def import_queued_submissions(conn, limit=50):
"""
Import the given submission into the main fingerprint database
"""
query = schema.submission.select(schema.submission.c.handled == False).limit(limit)
query = schema.submission.select(sql.and_(schema.submission.c.mbid != None, schema.submission.c.handled == False)).limit(limit)
count = 0
for submission in conn.execute(query):
import_submission(conn, submission)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment