-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GO-130 Migrate tags from MessageDraft to associated Message #477
Conversation
app/models/govbox/message.rb
Outdated
@@ -27,6 +27,8 @@ class Govbox::Message < ApplicationRecord | |||
|
|||
def self.create_message_with_thread!(govbox_message) | |||
message = nil | |||
message_draft = Upvs::MessageDraft.where(uuid: govbox_message.message_id).joins(:thread).where(thread: { box_id: govbox_message.box.id }).take | |||
tags_to_migrate = message_draft&.tags_to_migrate_to_message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tato migracia tagov sa mi zda taka "rozbita". Nevieme to nejako zabalit do metody, ktora tu urobi v ramci toho advisory_lock?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hej, nebolo to dobre. Ten deferred constraint pomohol a zbavili sme sa tych skaredych casti podla mna.
app/models/govbox/message.rb
Outdated
|
||
MessageThread.with_advisory_lock!(govbox_message.correlation_id, transaction: true, timeout_seconds: 10) do | ||
message = create_message(govbox_message) | ||
|
||
message.thread = govbox_message.box.message_threads.find_or_create_by_merge_uuid!( | ||
message.thread = (message_draft.thread if message_draft) || govbox_message.box.message_threads.find_or_create_by_merge_uuid!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nerozdelime to na dva riadky?
message.thread = (message_draft.thread if message_draft) || govbox_message.box.message_threads.find_or_create_by_merge_uuid!( | |
message.thread = message_draft&.thread | |
message.thread ||= govbox_message.box.message_threads.find_or_create_by_merge_uuid!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
upravene
app/models/govbox/message.rb
Outdated
add_upvs_related_tags(message, govbox_message) | ||
end | ||
migrate_tags_from_draft(message, message_draft) if message_draft |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Toto ked posunieme o riadok nizsie, tak to vieme zabalit do jedneho if?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
upravene
app/models/govbox/message.rb
Outdated
@@ -140,6 +145,15 @@ def self.add_upvs_related_tags(message, govbox_message) | |||
add_delivery_notification_tag(message) if message.can_be_authorized? | |||
end | |||
|
|||
def self.migrate_tags_from_draft(message, message_draft) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
migrate znie divne, skor copy_tags_from_message
(asi je jedno ci to je draft alebo nie nie?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
premenovala som
No description provided.