Add `not_allowed` scope for `PreviewCardTrend` (#29599)

main-rebase-security-fix
Matt Jankowski 2024-03-26 09:21:20 -04:00 committed by GitHub
parent cf76380c91
commit 32938dadd7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 2 deletions

View File

@ -15,5 +15,7 @@ class PreviewCardTrend < ApplicationRecord
include RankedTrend
belongs_to :preview_card
scope :allowed, -> { where(allowed: true) }
scope :not_allowed, -> { where(allowed: false) }
end

View File

@ -86,8 +86,8 @@ class Trends::Links < Trends::Base
def request_review
PreviewCardTrend.pluck('distinct language').flat_map do |language|
score_at_threshold = PreviewCardTrend.where(language: language, allowed: true).by_rank.ranked_below(options[:review_threshold]).first&.score || 0
preview_card_trends = PreviewCardTrend.where(language: language, allowed: false).joins(:preview_card)
score_at_threshold = PreviewCardTrend.where(language: language).allowed.by_rank.ranked_below(options[:review_threshold]).first&.score || 0
preview_card_trends = PreviewCardTrend.where(language: language).not_allowed.joins(:preview_card)
preview_card_trends.filter_map do |trend|
preview_card = trend.preview_card