Skip to content

Commit

Permalink
CV2-4869: keep only clusters with center
Browse files Browse the repository at this point in the history
  • Loading branch information
melsawy committed Aug 21, 2024
1 parent 3534a02 commit fdcdf75
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/tasks/check_khousheh.rake
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ namespace :check do
Cluster.transaction do
# Create clusters
mapping = {} # Media ID => Cluster ID
# Cluster to delete in case there is no center (project_media_id)
cluster_to_delete = []
# Bulk-insert clusters
c_inserted_items = []
clusters.length.times.each_slice(2500) do |rows|
Expand Down Expand Up @@ -278,6 +280,7 @@ namespace :check do
updated_cluster_attributes[:title] = cluster_title
# Update cluster
if updated_cluster_attributes[:project_media_id].blank?
cluster_to_delete << cluster.id
error_logs << {Cluster: "Failed to update Cluster with id #{cluster.id}"}
else
cluster_items[cluster.id] = updated_cluster_attributes
Expand All @@ -303,6 +306,8 @@ namespace :check do
end
search_after = [pm_ids.max]
end
# Delete cluster with no project_media_id
Cluster.where(id: cluster_to_delete).delete_all
Team.current = nil
end
puts "\nRebuilding clusters for feed #{feed.name} took #{Time.now.to_f - started_at} seconds."
Expand Down

0 comments on commit fdcdf75

Please sign in to comment.