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)
committerBill Erickson <berick@esilibrary.com>
Wed, 6 Jul 2011 18:50:50 +0000 (14:50 -0400)
Open-ILS/src/sql/Pg/012.schema.vandelay.sql

index f98f6ca..61b49c2 100644 (file)
@@ -1301,7 +1301,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';