(20260310) Modified the work computation to label the event as "In" or "Out" by even considering the label of the device.
This commit is contained in:
+7
-2
@@ -577,8 +577,13 @@ def compute_work_done(
|
|||||||
punch_ts = punch_dt.timestamp()
|
punch_ts = punch_dt.timestamp()
|
||||||
punch_loc = row[" Device/Source Detail"]
|
punch_loc = row[" Device/Source Detail"]
|
||||||
|
|
||||||
|
# Figure out the event type:
|
||||||
|
loc_event_type = None
|
||||||
|
if punch_loc.lower().find("out") >= 0: loc_event_type = "Out"
|
||||||
|
io_event_type = row["I/O Type"] if loc_event_type is None else loc_event_type
|
||||||
|
|
||||||
# Handle the first in time:
|
# Handle the first in time:
|
||||||
if row["I/O Type"] == "In":
|
if io_event_type == "In":
|
||||||
if work_reports[user_id][punch_date].get("first_in") is None:
|
if work_reports[user_id][punch_date].get("first_in") is None:
|
||||||
work_reports[user_id][punch_date]["first_in"] = punch_ts
|
work_reports[user_id][punch_date]["first_in"] = punch_ts
|
||||||
work_reports[user_id][punch_date]["first_in_loc"] = punch_loc
|
work_reports[user_id][punch_date]["first_in_loc"] = punch_loc
|
||||||
@@ -589,7 +594,7 @@ def compute_work_done(
|
|||||||
work_reports[user_id][punch_date]["last_in_loc"] = punch_loc
|
work_reports[user_id][punch_date]["last_in_loc"] = punch_loc
|
||||||
|
|
||||||
# Handle the last out time:
|
# Handle the last out time:
|
||||||
if row["I/O Type"] == "Out":
|
if io_event_type == "Out":
|
||||||
if work_reports[user_id][punch_date].get("first_in") is not None:
|
if work_reports[user_id][punch_date].get("first_in") is not None:
|
||||||
work_reports[user_id][punch_date]["last_out"] = punch_ts
|
work_reports[user_id][punch_date]["last_out"] = punch_ts
|
||||||
work_reports[user_id][punch_date]["last_out_loc"] = punch_loc
|
work_reports[user_id][punch_date]["last_out_loc"] = punch_loc
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ if __name__ == "__main__":
|
|||||||
import argparse
|
import argparse
|
||||||
ap = argparse.ArgumentParser()
|
ap = argparse.ArgumentParser()
|
||||||
ap.add_argument(
|
ap.add_argument(
|
||||||
"--test",
|
"--test", "--test-mode",
|
||||||
action = "store_true",
|
action = "store_true",
|
||||||
default = False,
|
default = False,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user