2022-03-30 16:54:55 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class HideRepositoryRemindersJob < ApplicationJob
|
|
|
|
queue_as :high_priority
|
|
|
|
|
2023-08-11 21:31:29 +08:00
|
|
|
def perform(repository, user_id)
|
|
|
|
user = User.find(user_id)
|
2022-03-30 16:54:55 +08:00
|
|
|
hidden_reminder_repository_cell_ids =
|
|
|
|
HiddenRepositoryCellReminder.joins(repository_cell: { repository_row: :repository })
|
|
|
|
.where(user: user)
|
|
|
|
.where(repositories: { id: repository.id })
|
|
|
|
.select(:id)
|
|
|
|
|
|
|
|
repository_cell_ids =
|
|
|
|
RepositoryCell.joins(repository_row: :repository)
|
|
|
|
.where.not(id: hidden_reminder_repository_cell_ids)
|
|
|
|
.with_active_reminder(user).where(repositories: { id: repository.id })
|
|
|
|
.pluck(:id)
|
|
|
|
|
|
|
|
HiddenRepositoryCellReminder.import(
|
|
|
|
repository_cell_ids.map { |rid| { repository_cell_id: rid, user_id: user.id } }
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|