Add language match as possible feed lever (#20211)
This commit is contained in:
parent
d375c6dad0
commit
095894d11c
1 changed files with 12 additions and 0 deletions
|
|
@ -355,6 +355,18 @@ module Articles
|
|||
user_required: false,
|
||||
select_fragment: "articles.score",
|
||||
group_by_fragment: "articles.score")
|
||||
relevancy_lever(:language_match,
|
||||
label: "Weight to give based on whether the language matches any of the user's languages",
|
||||
range: "[0..1]", # 0 for no match, 1 for match
|
||||
user_required: true,
|
||||
select_fragment: "CASE
|
||||
WHEN COUNT(user_languages.language) = 0 THEN 0
|
||||
WHEN articles.language = ANY(array_agg(user_languages.language)) THEN 1
|
||||
ELSE 0
|
||||
END",
|
||||
joins_fragments: ["LEFT OUTER JOIN user_languages
|
||||
ON user_languages.user_id = :user_id"],
|
||||
group_by_fragment: "articles.language")
|
||||
end
|
||||
private_constant :LEVER_CATALOG
|
||||
# rubocop:enable Metrics/BlockLength
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue