Secondary sort by quality ratio (higher means incoming is more "good" than existing...
authorMike Rylander <mrylander@gmail.com>
Fri, 22 Apr 2011 16:55:37 +0000 (12:55 -0400)
committerMike Rylander <mrylander@gmail.com>
Fri, 22 Apr 2011 16:55:37 +0000 (12:55 -0400)
Open-ILS/src/sql/Pg/012.schema.vandelay.sql

index 8f1e2d6..94a4f62 100644 (file)
@@ -1312,7 +1312,10 @@ BEGIN
       WHERE m.queued_record = import_id
             AND r.id = m.eg_record
             AND m.quality::NUMERIC / COALESCE(NULLIF(vandelay.incoming_record_quality(r.marc),0),1)::NUMERIC >= lwm_ratio_value
-      ORDER BY m.match_score DESC, m.quality DESC, id limit 1;
+      ORDER BY  m.match_score DESC,
+                m.quality::NUMERIC / COALESCE(NULLIF(vandelay.incoming_record_quality(r.marc),0),1)::NUMERIC DESC,
+                id
+      LIMIT 1;
 
     IF eg_id IS NULL THEN
         -- RAISE NOTICE 'incoming record is not of hight enough quality';