Skip to content

Commit

Permalink
OTWO-7259 Fixed string match for accented character (#1794)
Browse files Browse the repository at this point in the history
  • Loading branch information
Priya5 authored Jul 25, 2024
1 parent 46054a9 commit 67df8b4
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/models/position.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ def language_exp=(language_ids)
private

def find_name_fact_from_project_and_comitter_name
NameFact.joins(:name).find_by('analysis_id = ? AND names.name = ?', project.best_analysis_id, committer_name)
NameFact.joins(:name).find_by('analysis_id = ? AND lower(unaccent(names.name)) = ?', project.best_analysis_id,
ActiveSupport::Inflector.transliterate(committer_name).downcase)
end

def committer_name_and_project?
Expand Down
11 changes: 11 additions & 0 deletions db/migrate/20240724182111_add_unaccent_extension.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

class AddUnaccentExtension < ActiveRecord::Migration[5.2]
def up
execute 'create extension unaccent;'
end

def down
execute 'drop extension unaccent;'
end
end
25 changes: 25 additions & 0 deletions db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,20 @@ CREATE EXTENSION IF NOT EXISTS pg_stat_statements WITH SCHEMA fis;
COMMENT ON EXTENSION pg_stat_statements IS 'track execution statistics of all SQL statements executed';


--
-- Name: unaccent; Type: EXTENSION; Schema: -; Owner: -
--

CREATE EXTENSION IF NOT EXISTS unaccent WITH SCHEMA oh;


--
-- Name: EXTENSION unaccent; Type: COMMENT; Schema: -; Owner: -
--

COMMENT ON EXTENSION unaccent IS 'text search dictionary that removes accents';


--
-- Name: uuid-ossp; Type: EXTENSION; Schema: -; Owner: -
--
Expand Down Expand Up @@ -5467,6 +5481,7 @@ CREATE TABLE oh.countries (
region text
);


--
-- Name: cve_bdsa; Type: TABLE; Schema: oh; Owner: -
--
Expand Down Expand Up @@ -5496,6 +5511,7 @@ CREATE SEQUENCE oh.cve_bdsa_id_seq

ALTER SEQUENCE oh.cve_bdsa_id_seq OWNED BY oh.cve_bdsa.id;


--
-- Name: deleted_accounts; Type: TABLE; Schema: oh; Owner: -
--
Expand Down Expand Up @@ -6568,6 +6584,7 @@ CREATE TABLE oh.links_truncated (
url text
);


--
-- Name: maintenance_routes; Type: TABLE; Schema: oh; Owner: -
--
Expand All @@ -6576,6 +6593,7 @@ CREATE TABLE oh.maintenance_routes (
path character varying
);


--
-- Name: manages; Type: TABLE; Schema: oh; Owner: -
--
Expand Down Expand Up @@ -9478,12 +9496,14 @@ ALTER TABLE ONLY oh.clumps ALTER COLUMN id SET DEFAULT nextval('oh.clumps_id_seq

ALTER TABLE ONLY oh.code_location_scan ALTER COLUMN id SET DEFAULT nextval('oh.code_location_scan_id_seq'::regclass);


--
-- Name: cve_bdsa id; Type: DEFAULT; Schema: oh; Owner: -
--

ALTER TABLE ONLY oh.cve_bdsa ALTER COLUMN id SET DEFAULT nextval('oh.cve_bdsa_id_seq'::regclass);


--
-- Name: deleted_accounts id; Type: DEFAULT; Schema: oh; Owner: -
--
Expand Down Expand Up @@ -10321,13 +10341,15 @@ ALTER TABLE ONLY oh.clumps
ALTER TABLE ONLY oh.code_location_scan
ADD CONSTRAINT code_location_scan_pkey PRIMARY KEY (id);


--
-- Name: cve_bdsa cve_bdsa_pkey; Type: CONSTRAINT; Schema: oh; Owner: -
--

ALTER TABLE ONLY oh.cve_bdsa
ADD CONSTRAINT cve_bdsa_pkey PRIMARY KEY (id);


--
-- Name: deleted_accounts deleted_accounts_pkey; Type: CONSTRAINT; Schema: oh; Owner: -
--
Expand Down Expand Up @@ -19281,6 +19303,8 @@ INSERT INTO oh.schema_migrations (version) VALUES ('20230801115125');

INSERT INTO oh.schema_migrations (version) VALUES ('20240305184511');

INSERT INTO oh.schema_migrations (version) VALUES ('20240724182111');

INSERT INTO oh.schema_migrations (version) VALUES ('21');

INSERT INTO oh.schema_migrations (version) VALUES ('22');
Expand Down Expand Up @@ -19452,3 +19476,4 @@ INSERT INTO oh.schema_migrations (version) VALUES ('97');
INSERT INTO oh.schema_migrations (version) VALUES ('98');

INSERT INTO oh.schema_migrations (version) VALUES ('99');

0 comments on commit 67df8b4

Please sign in to comment.