Skip to content

Commit

Permalink
Issue #147: add insert
Browse files Browse the repository at this point in the history
  • Loading branch information
Francois-Werbrouck committed Oct 2, 2024
1 parent af247a0 commit d05a367
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 3 deletions.
57 changes: 56 additions & 1 deletion datastore/db/bytebase/FertiScan/OLAP/verification_functions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ DECLARE
sub_label_key TEXT;
source_nb int;
target_nb int;
score_value int;
label_info_lev_total int,
label_name_lev int,
label_reg_num_lev int,
Expand Down Expand Up @@ -158,7 +159,6 @@ BEGIN
target_nb := target_nb + 1;
END IF;

metrics_lists_edit:= source_nb != target_nb;
metrics_lists_modif:= target_nb - source_nb;

SELECT levenshtein(source_str, target_str) INTO metrics_lev;
Expand Down Expand Up @@ -341,6 +341,61 @@ BEGIN
END IF;
END IF;
END LOOP;

-- Score the inspection

-- Insert the evaluation into the inspection_evaluation table
INSERT INTO "fertiscan_0.0.12".inspection_evaluation (
inspection_id,
score,
label_info_lev_total,
label_name_lev,
label_reg_num_lev,
label_lot_num_lev,
metrics_lists_edited,
metrics_lists_modif,
metrics_lev,
manufacturer_field_edited,
manufacturer_lev_total,
company_field_edited,
company_lev_total,
org_lev_total,
instructions_lists_modif,
instruction_lists_edit,
instructions_lev,
cautions_lists_modif,
cautions_lists_edit,
cautions_lev,
guaranteeds_en_lists_modif,
guaranteeds_fr_lists_modif,
guaranteeds_en_lev,
guaranteeds_fr_lev
) VALUES (
id,
score_value,
label_info_lev_total,
label_name_lev,
label_reg_num_lev,
label_lot_num_lev,
metrics_lists_edited,
metrics_lists_modif,
metrics_lev,
manufacturer_field_edited,
manufacturer_lev_total,
company_field_edited,
company_lev_total,
org_lev_total,
instructions_lists_modif,
instruction_lists_edit,
instructions_lev,
cautions_lists_modif,
cautions_lists_edit,
cautions_lev,
guaranteeds_en_lists_modif,
guaranteeds_fr_lists_modif,
guaranteeds_en_lev,
guaranteeds_fr_lev
);
RETURN;
END;
$function$;
Expand Down
3 changes: 1 addition & 2 deletions datastore/db/bytebase/FertiScan/schema_0.0.12.sql
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,11 @@ IF (EXISTS (SELECT 1 FROM information_schema.schemata WHERE schema_name = 'ferti
"label_name_lev" int,
"label_reg_num_lev" int,
"label_lot_num_lev" int,
"metrics_lists_edited" boolean,
"metrics_lists_modif" int,
"metrics_lev" int,
"manufacturer_field_edited" int,
"manufacturer_lev_total" int,
"company_field_edited" boolean,
"company_field_edited" int,
"company_lev_total" int,
"instructions_en_lists_modif" int,
"instructions_fr_lists_modif" int,
Expand Down

0 comments on commit d05a367

Please sign in to comment.