Skip to content
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

Merged
merged 8 commits into from
Oct 28, 2024

Conversation

luciajanikova
Copy link
Member

No description provided.

@luciajanikova luciajanikova marked this pull request as ready for review October 1, 2024 11:16
@luciajanikova luciajanikova requested a review from jsuchal October 1, 2024 11:16
@@ -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
Copy link
Member

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?

Copy link
Member Author

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.

@luciajanikova luciajanikova requested a review from jsuchal October 25, 2024 20:09

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!(
Copy link
Member

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?

Suggested change
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!(

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

upravene

add_upvs_related_tags(message, govbox_message)
end
migrate_tags_from_draft(message, message_draft) if message_draft
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

upravene

@@ -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)
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

premenovala som

@luciajanikova luciajanikova requested a review from jsuchal October 28, 2024 13:44
@luciajanikova luciajanikova merged commit 2f187cf into main Oct 28, 2024
3 checks passed
@luciajanikova luciajanikova deleted the GO-130/keep_tags_from_draft branch October 28, 2024 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants