Commit 8b445ba28c9021ad6afbba224d2036bead6cb023

Authored by Andrew Kane
1 parent 9ae83f7b

Updated example [skip ci]

Showing 1 changed file with 7 additions and 5 deletions   Show diff stats
README.md
... ... @@ -1630,16 +1630,18 @@ Create a job to update the column and reindex records with new conversions.
1630 1630 class ReindexConversionsJob < ApplicationJob
1631 1631 def perform(class_name, since)
1632 1632 # get records that have a recent conversion
1633   - recently_converted_ids =
1634   - Searchjoy::Search.where(convertable_type: class_name).where(converted_at: since..)
  1633 + recently_converted_ids = Searchjoy::Search
  1634 + .where(convertable_type: class_name).where(converted_at: since..)
1635 1635 .order(:convertable_id).distinct.pluck(:convertable_id)
1636 1636  
1637 1637 # split into groups
1638 1638 recently_converted_ids.in_groups_of(1000, false) do |ids|
1639 1639 # fetch conversions
1640   - conversions =
1641   - Searchjoy::Search.where(convertable_id: ids, convertable_type: class_name).where.not(user_id: nil)
1642   - .group(:convertable_id, :query).distinct.count(:user_id)
  1640 + conversions = Searchjoy::Search
  1641 + .where(convertable_id: ids, convertable_type: class_name)
  1642 + .where.not(user_id: nil)
  1643 + .group(:convertable_id, :query)
  1644 + .distinct.count(:user_id)
1643 1645  
1644 1646 # group conversions by record
1645 1647 conversions_by_record = {}
... ...