-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_datetime.py
More file actions
32 lines (31 loc) · 1.15 KB
/
fix_datetime.py
File metadata and controls
32 lines (31 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env powerscript
from cdb import tools
from cdb.platform.mom.fields import DDDateField
from cdb.progress import ProgressBar
if __name__ == "__main__":
included_classes = [
# NOTE: extend this list as needed.
"cs_ticket_ticket",
"cdbpcs_issue",
"cdbwf_task",
"cdbwf_process_component",
]
fields = DDDateField.Query(DDDateField.with_time != 1)
for field in fields:
if field.classname not in included_classes:
print(f"Skipped {field.classname}.{field.field_name}")
continue
print(f"> {field.classname}.{field.field_name}")
fpyname = field.Entity.getFqpyname()
if fpyname:
print(f" > FQPY {fpyname}")
cls = tools.getObjectByName(fpyname)
progress_bar = ProgressBar()
objs = cls.Query().Execute()
print(f" > {len(objs)} objects")
for o in progress_bar(objs):
attr = getattr(o, field.field_name)
if attr is not None:
o.Update(**{field.field_name: getattr(o, field.field_name)})
else:
print("No FQPY, skipping")