Skip to content

Commit

Permalink
CV2-5011 refactors for making alegre dual purpose on text encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
DGaffney committed Aug 5, 2024
1 parent f3c18a0 commit ac9e627
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions app/models/concerns/alegre_v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,26 @@ def delete_package(project_media, field, params={}, quiet=false)
).merge(params)
end

def generic_package_text(project_media, field, params, fuzzy=false, match_across_content_types=true)
package = generic_package(project_media, field).merge(
params
).merge(
models: self.indexing_models_to_use(project_media),
text: project_media.send(field),
fuzzy: fuzzy == 'true' || fuzzy.to_i == 1,
match_across_content_types: match_across_content_types,
)
team_id = project_media.team_id
language = self.language_for_similarity(team_id)
package[:language] = language if !language.nil?
package[:min_es_score] = self.get_min_es_score(team_id)
package
end

def delete_package_text(project_media, field, params)
generic_package_text(project_media, field, params)
end

def generic_package_media(project_media, params)
generic_package(project_media, nil).merge(
url: media_file_url(project_media),
Expand Down Expand Up @@ -241,6 +261,10 @@ def store_package_audio(project_media, _field, params)
generic_package_audio(project_media, params)
end

def store_package_text(project_media, field, params)
generic_package_text(project_media, field, params)
end

def get_sync(project_media, field=nil, params={})
request_sync(
store_package(project_media, field, params),
Expand Down

0 comments on commit ac9e627

Please sign in to comment.