Skip to content

Commit

Permalink
refactor getting fact check project media
Browse files Browse the repository at this point in the history
  • Loading branch information
vasconsaurus committed Feb 15, 2024
1 parent 1f335ed commit b2784c9
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,9 @@ def populate_projects

def publish_fact_checks
users.each_value do |user|
project_medias = fact_checks_project_medias(user)
project_medias.each { |pm| verify_fact_check_and_publish_report(pm)}
fact_checks = FactCheck.where(user: user)
# publish only half of fact checks
fact_checks[0, fact_checks.size/2].each { |fact_check| verify_fact_check_and_publish_report(fact_check.project_media)}
end
end

Expand Down Expand Up @@ -347,11 +348,6 @@ def get_url_for_some_fact_checks(index)
index % 4 == 0 ? "https://www.thespruceeats.com/step-by-step-basic-cake-recipe-304553?timestamp=#{Time.now.to_f}" : nil
end

def fact_checks_project_medias(user)
facts = FactCheck.where(user: user)
facts[0, facts.size/2].map { |f| ProjectMedia.find_by(claim_description: f[:claim_description_id]) }
end

def verify_fact_check_and_publish_report(project_media)
status = ['verified', 'false'].sample

Expand Down

0 comments on commit b2784c9

Please sign in to comment.