Skip to content

Commit

Permalink
refactor: rename transferred_after -> transfer_completed_after
Browse files Browse the repository at this point in the history
  • Loading branch information
s-aga-r committed Oct 5, 2024
1 parent eee328f commit cbfe8bc
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 16 deletions.
24 changes: 12 additions & 12 deletions mail/mail/doctype/outgoing_mail/outgoing_mail.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"transfer_completed_at",
"column_break_fvyv",
"submitted_after",
"transferred_after",
"transfer_completed_after",
"section_break_aafd",
"tracking_id",
"first_opened_at",
Expand Down Expand Up @@ -203,16 +203,6 @@
"read_only": 1,
"search_index": 1
},
{
"depends_on": "eval: doc.transfer_completed_at",
"description": "Transfer Completed At - Submitted At",
"fieldname": "transferred_after",
"fieldtype": "Int",
"label": "Transferred After (Seconds)",
"no_copy": 1,
"non_negative": 1,
"read_only": 1
},
{
"depends_on": "eval: doc.message_size",
"fieldname": "message_size",
Expand Down Expand Up @@ -426,12 +416,22 @@
"label": "Transfer Completed At",
"no_copy": 1,
"read_only": 1
},
{
"depends_on": "eval: doc.transfer_completed_at",
"description": "Transfer Completed At - Submitted At",
"fieldname": "transfer_completed_after",
"fieldtype": "Int",
"label": "Transfer Completed After (Seconds)",
"no_copy": 1,
"non_negative": 1,
"read_only": 1
}
],
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2024-10-05 10:05:48.765359",
"modified": "2024-10-05 10:15:40.832320",
"modified_by": "Administrator",
"module": "Mail",
"name": "Outgoing Mail",
Expand Down
8 changes: 5 additions & 3 deletions mail/mail/doctype/outgoing_mail/outgoing_mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,11 +695,13 @@ def transfer_now(self) -> None:
rmq.publish(constants.OUTGOING_MAIL_QUEUE, json.dumps(data), priority=3)

transfer_completed_at = now()
transferred_after = time_diff_in_seconds(transfer_completed_at, self.submitted_at)
transfer_completed_after = time_diff_in_seconds(
transfer_completed_at, self.submitted_at
)
self._db_set(
status="Transferred",
transfer_completed_at=transfer_completed_at,
transferred_after=transferred_after,
transfer_completed_after=transfer_completed_after,
commit=True,
)
except Exception:
Expand Down Expand Up @@ -1049,7 +1051,7 @@ def update_outgoing_mails(
status = %s,
error_log = NULL,
transfer_completed_at = %s,
transferred_after = TIMESTAMPDIFF(SECOND, `submitted_at`, `transfer_completed_at`)
transfer_completed_after = TIMESTAMPDIFF(SECOND, `submitted_at`, `transfer_completed_at`)
WHERE
docstatus = 1 AND
status = %s AND
Expand Down
2 changes: 1 addition & 1 deletion mail/mail/report/outbound_delay/outbound_delay.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def get_data(filters=None) -> list:
OM.via_api,
OM.is_newsletter,
OM.submitted_after,
OM.transferred_after,
OM.transfer_completed_after.as_("transferred_after"),
MR.action_after,
OM.agent,
OM.domain_name,
Expand Down
1 change: 1 addition & 0 deletions mail/patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
mail.patches.v1_0.rename_field_dkim_bits
mail.patches.v1_0.create_dkim_key_doc
mail.patches.v1_0.rename_field_transferred_at
mail.patches.v1_0.rename_field_transferred_after
10 changes: 10 additions & 0 deletions mail/patches/v1_0/rename_field_transferred_after.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import frappe
from frappe.model.utils.rename_field import rename_field


def execute():
doctype = "Outgoing Mail"
old_fieldname, new_fieldname = "transferred_after", "transfer_completed_after"

if frappe.db.has_column(doctype, old_fieldname):
rename_field(doctype, old_fieldname, new_fieldname)

0 comments on commit cbfe8bc

Please sign in to comment.