Sure, here it is
def get_timelog_last_day(sg):
return sg.find(
"TimeLog",
[["created_at", "in_last", 1, "DAY"]],
[
"created_at",
"description",
"duration",
"project",
"entity",
"entity.Task.entity",
"user",
"user.HumanUser.login"
]
)
def get_active_users(sg):
return sg.find(
"HumanUser",
[["sg_status_list", "is", "act"],
["department", "is_not", None]],
["login", "name"]
)
def get_users_without_timelog_today(sg):
logged_today_logins = [u["user.HumanUser.login"]
for u in get_timelog_last_day(sg)]
active_users = get_active_users(sg)
missing_users = [u for u in active_users if u["login"] not in logged_today_logins]
return missing_users
The missing_users
list comprehension is the thing that performs the “subtraction”.
So you just call get_users_without_timelog_today
and decide whether to print this somewhere, store it in shotgun, or whatever. We also automatically create timelogs based on this data.
Edit: This returns users without logs from yesterday. Change the filter in get_timelog_last_day
to get what you need.