Skip to content

Commit

Permalink
feat: add fields transfer_started_at and transfer_started_after i…
Browse files Browse the repository at this point in the history
…n OM
  • Loading branch information
s-aga-r committed Oct 5, 2024
1 parent cbfe8bc commit 3b2097b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
23 changes: 21 additions & 2 deletions mail/mail/doctype/outgoing_mail/outgoing_mail.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@
"section_break_093p",
"created_at",
"submitted_at",
"transfer_started_at",
"transfer_completed_at",
"column_break_fvyv",
"submitted_after",
"transfer_started_after",
"transfer_completed_after",
"section_break_aafd",
"tracking_id",
Expand Down Expand Up @@ -419,19 +421,36 @@
},
{
"depends_on": "eval: doc.transfer_completed_at",
"description": "Transfer Completed At - Submitted At",
"description": "Transfer Completed At - Transfer Started At",
"fieldname": "transfer_completed_after",
"fieldtype": "Int",
"label": "Transfer Completed After (Seconds)",
"no_copy": 1,
"non_negative": 1,
"read_only": 1
},
{
"fieldname": "transfer_started_at",
"fieldtype": "Datetime",
"label": "Transfer Started At",
"no_copy": 1,
"read_only": 1
},
{
"depends_on": "eval: doc.transfer_started_at",
"description": "Transfer Started At - Submitted At",
"fieldname": "transfer_started_after",
"fieldtype": "Int",
"label": "Transfer Started 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:15:40.832320",
"modified": "2024-10-05 12:34:39.544599",
"modified_by": "Administrator",
"module": "Mail",
"name": "Outgoing Mail",
Expand Down
14 changes: 11 additions & 3 deletions mail/mail/doctype/outgoing_mail/outgoing_mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,14 @@ def transfer_now(self) -> None:
if not (self.docstatus == 1 and self.status == "Pending"):
return

self._db_set(status="Transferring", commit=True)
transfer_started_at = now()
transfer_started_after = time_diff_in_seconds(transfer_started_at, self.submitted_at)
self._db_set(
status="Transferring",
transfer_started_at=transfer_started_at,
transfer_started_after=transfer_started_after,
commit=True,
)

recipients = [formataddr((r.display_name, r.email)) for r in self.recipients]
data = {
Expand All @@ -696,7 +703,7 @@ def transfer_now(self) -> None:

transfer_completed_at = now()
transfer_completed_after = time_diff_in_seconds(
transfer_completed_at, self.submitted_at
transfer_completed_at, transfer_started_at
)
self._db_set(
status="Transferred",
Expand Down Expand Up @@ -1021,6 +1028,7 @@ def update_outgoing_mails(
outgoing_mails,
current_status=current_status,
status="Transferring",
transfer_started_at=now(),
error_log=None,
commit=True,
)
Expand Down Expand Up @@ -1051,7 +1059,7 @@ def update_outgoing_mails(
status = %s,
error_log = NULL,
transfer_completed_at = %s,
transfer_completed_after = TIMESTAMPDIFF(SECOND, `submitted_at`, `transfer_completed_at`)
transfer_completed_after = TIMESTAMPDIFF(SECOND, `transfer_started_at`, `transfer_completed_at`)
WHERE
docstatus = 1 AND
status = %s AND
Expand Down

0 comments on commit 3b2097b

Please sign in to comment.