Skip to content

Commit

Permalink
Update scope name
Browse files Browse the repository at this point in the history
  • Loading branch information
luciajanikova committed Nov 14, 2024
1 parent 55a89fa commit 40e5a25
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/jobs/fs/download_sent_message_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def perform(fs_message_id, box:, fs_client: FsEnvironment.fs_client)
raise unless box.is_a?(Fs::Box)
return unless box.syncable?

return if box.messages.except_drafts.where("metadata ->> 'fs_message_id' = ?", fs_message_id).any?
return if box.messages.not_drafts.where("metadata ->> 'fs_message_id' = ?", fs_message_id).any?

ActiveRecord::Base.transaction do
fs_api = fs_client.api(api_connection: box.api_connection, box: box)
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/fs/sync_box_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def perform(box, from: Date.today - 1.week, to: Date.tomorrow)
raise unless box.is_a?(Fs::Box)
return unless box.syncable?

box.messages.outbox.except_drafts.find_each do |outbox_message|
box.messages.outbox.not_drafts.find_each do |outbox_message|
DownloadSentMessageRelatedMessagesJob.perform_later(outbox_message, from: from, to: to)
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/govbox/process_message_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class ProcessMessageJob < ApplicationJob
retry_on ::ApplicationRecord::FailedToAcquireLockError, wait: :polynomially_longer, attempts: Float::INFINITY

def perform(govbox_message)
processed_message = ::Message.except_drafts.where(uuid: govbox_message.message_id).joins(:thread).where(thread: { box_id: govbox_message.box.id }).take
processed_message = ::Message.not_drafts.where(uuid: govbox_message.message_id).joins(:thread).where(thread: { box_id: govbox_message.box.id }).take

ActiveRecord::Base.transaction do
message = Govbox::Message.create_message_with_thread!(govbox_message)
Expand Down
4 changes: 2 additions & 2 deletions app/models/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ class Message < ApplicationRecord
delegate :tenant, to: :thread
delegate :box, to: :thread

scope :except_drafts, -> { where(type: [nil, 'Message']) }
scope :not_drafts, -> { where(type: [nil, 'Message']) }
scope :outbox, -> { where(outbox: true) }
scope :inbox, -> { except_drafts.where.not(outbox: true) }
scope :inbox, -> { not_drafts.where.not(outbox: true) }

after_update_commit ->(message) { EventBus.publish(:message_changed, message) }
after_destroy_commit ->(message) { EventBus.publish(:message_destroyed, message) }
Expand Down

0 comments on commit 40e5a25

Please sign in to comment.