Revert thinko on single calc of bib record quality; store matchiness in a new match_s...
authorMike Rylander <mrylander@gmail.com>
Fri, 22 Apr 2011 16:40:27 +0000 (12:40 -0400)
committerMike Rylander <mrylander@gmail.com>
Fri, 22 Apr 2011 16:40:27 +0000 (12:40 -0400)
Open-ILS/src/sql/Pg/012.schema.vandelay.sql

index 65f87c8..8f1e2d6 100644 (file)
@@ -715,10 +715,10 @@ BEGIN
         vandelay.match_set_test_marcxml(my_bib_queue.match_set, NEW.marc) LOOP
 
         INSERT INTO vandelay.bib_match (
-            matched_set, queued_record, eg_record, quality
+            matched_set, queued_record, eg_record, match_score, quality
         ) VALUES (
             my_bib_queue.match_set, NEW.id, test_result.record,
-            test_result.quality
+            test_result.quality, vandelay.incoming_record_quality(NEW.marc)
         );
 
     END LOOP;
@@ -1292,12 +1292,9 @@ CREATE OR REPLACE FUNCTION vandelay.auto_overlay_bib_record_with_best ( import_i
 DECLARE
     eg_id           BIGINT;
     match_count     INT;
-    existing_qual   INT;
     match_attr      vandelay.bib_attr_definition%ROWTYPE;
 BEGIN
 
-    existing_qual := COALESCE(NULLIF(vandelay.incoming_record_quality(r.marc),0),1);
-
     IF lwm_ratio_value IS NULL THEN
         lwm_ratio_value := 0.0;
     END IF;
@@ -1314,7 +1311,7 @@ BEGIN
             JOIN biblio.record_entry r
       WHERE m.queued_record = import_id
             AND r.id = m.eg_record
-            AND m.quality::NUMERIC / existing_qual::NUMERIC >= lwm_ratio_value
+            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;
 
     IF eg_id IS NULL THEN