Logged User TimesΒΆ
This example uses the User
class to load the logged times
for all users of whom the current user is admin or team-manager.
This example additionally needs the pandas and tabulate packages.
import pandas as pd
import webknossos as wk
def main() -> None:
df = pd.DataFrame()
df.columns = pd.MultiIndex([[], []], [[], []], names=("year", "month"))
df.index.name = "email"
users = wk.User.get_all_managed_users()
for user in users:
for logged_time in user.get_logged_times():
df.loc[user.email, (logged_time.year, logged_time.month)] = (
logged_time.duration_in_seconds
)
df = df.fillna(0).astype("uint")
df = df.sort_index(axis="index").sort_index(axis="columns")
year = 2021
has_logged_times_in_year = df.loc[:, year].sum(axis="columns") != 0
print(f"Logged User Times {year}:\n")
print(df.loc[has_logged_times_in_year, year].to_markdown())
if __name__ == "__main__":
main()
This results in an output similar to
Logged User Times 2021:
| email | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|:-----------------------|-----:|-----:|-----:|-----:|----:|----:|----:|
| abc@mail.com | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| somebody@mail.com | 0 | 0 | 16 | 210 | 0 | 271 | 150 |
| someone@mail.com | 0 | 0 | 553 | 0 | 0 | 0 | 0 |
| taylor.tester@mail.com | 0 | 0 | 0 | 1746 | 0 | 0 | 486 |
| tony.test@mail.com | 36 | 0 | 158 | 0 | 20 | 0 | 452 |
| xyz@mail.com | 0 | 260 | 674 | 903 | 0 | 541 | 0 |
- Get Help
- Community Forums
- Email Support