refactor: Split objects just once
Co-authored-by: Ritwik Puri <ritwikpuri5678@gmail.com>
This commit is contained in:
parent
d357af1533
commit
e75bfd0e73
3 changed files with 8 additions and 10 deletions
|
|
@ -357,13 +357,8 @@ def get_events(start, end, user=None, for_reminder=False, filters=None) -> list[
|
|||
|
||||
if e.repeat_on == "Monthly":
|
||||
# creates a string with date (27) and month (07) and year (2019) eg: 2019-07-27
|
||||
date = (
|
||||
start.split("-", maxsplit=1)[0]
|
||||
+ "-"
|
||||
+ start.split("-", maxsplit=2)[1]
|
||||
+ "-"
|
||||
+ event_start.split("-", maxsplit=3)[2]
|
||||
)
|
||||
year, month = start.split("-", maxsplit=2)[:2]
|
||||
date = f"{year}-{month}-" + event_start.split("-", maxsplit=3)[2]
|
||||
|
||||
# last day of month issue, start from prev month!
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -462,7 +462,8 @@ def parse_field(field: str) -> tuple[str | None, str]:
|
|||
raise ValueError
|
||||
|
||||
if "." in key:
|
||||
return key.split(".", 1)[0][4:-1], key.split(".", 2)[1].strip("`")
|
||||
table, column = key.split(".", 2)[:2]
|
||||
return table[4:-1], column.strip("`")
|
||||
|
||||
return None, key.strip("`")
|
||||
|
||||
|
|
|
|||
|
|
@ -897,8 +897,9 @@ class DatabaseQuery:
|
|||
# will covert to
|
||||
# `tabItem`.`idx` desc, `tabItem`.`modified` desc
|
||||
args.order_by = ", ".join(
|
||||
f"`tab{self.doctype}`.`{f.split(maxsplit=1)[0].strip()}` {f.split(maxsplit=2)[1].strip()}"
|
||||
f"`tab{self.doctype}`.`{f_split[0].strip()}` {f_split[1].strip()}"
|
||||
for f in meta.sort_field.split(",")
|
||||
if (f_split := f.split(maxsplit=2))
|
||||
)
|
||||
else:
|
||||
sort_field = meta.sort_field or "modified"
|
||||
|
|
@ -1029,8 +1030,9 @@ def get_order_by(doctype, meta):
|
|||
# will covert to
|
||||
# `tabItem`.`idx` desc, `tabItem`.`modified` desc
|
||||
order_by = ", ".join(
|
||||
f"`tab{doctype}`.`{f.split(maxsplit=1)[0].strip()}` {f.split(maxsplit=2)[1].strip()}"
|
||||
f"`tab{doctype}`.`{f_split[0].strip()}` {f_split[1].strip()}"
|
||||
for f in meta.sort_field.split(",")
|
||||
if (f_split := f.split(maxsplit=2))
|
||||
)
|
||||
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue