-
Notifications
You must be signed in to change notification settings - Fork 339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add some functionality for filtering attendances records #137
Open
agn-7
wants to merge
16
commits into
fananimi:master
Choose a base branch
from
agn-7:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 15 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
008ab95
ignore vscode
benyamin-7 7294573
init user history and add __call__ method
benyamin-7 daf8d14
add status and punch to the user history as well
benyamin-7 d0d09ef
limit user history by mentioning their ID
benyamin-7 2554bf0
fix sorting user history
benyamin-7 fff6f71
add sorted attendance and method doc string
agn-7 5d919f4
add property methods for each attendance's property
agn-7 39f3f4e
add filter by user utility
agn-7 7e64921
add filter by date utility
agn-7 a69e3a0
add get_limited_attendance
agn-7 c0b807e
fix test error caused by hinting type newer version (python 3.9) redu…
agn-7 f0f2943
add more get_attendances methods
agn-7 ba224bc
fix typo
agn-7 61b7933
complete get_user_history method
agn-7 99f1bd1
update with get_user_history
agn-7 25fb679
Update README.md
agn-7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -158,3 +158,6 @@ venv.bak/ | |
|
||
# mypy | ||
.mypy_cache/ | ||
|
||
# VScode | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
class Utility(object): | ||
"""Utility Class""" | ||
|
||
def __init__(self): | ||
pass | ||
|
||
@staticmethod | ||
def filter_by_date(attendances_list, start=None, end=None): | ||
""" | ||
Select only desire attendances records by datetime condition. | ||
|
||
:param attendances_list: The list of attendances records. | ||
:param start: The filter of starting datetime | ||
:param end: The filter of ending datetime | ||
:return: Limited list of attendances records. | ||
""" | ||
filtered = [] | ||
|
||
if start is not None: | ||
for d in attendances_list: | ||
if d.timestamp >= start: | ||
filtered.append(d) | ||
|
||
if end is not None: | ||
for d in attendances_list: | ||
if d.timestamp <= end: | ||
filtered.append(d) | ||
|
||
return filtered | ||
|
||
@staticmethod | ||
def filter_by_user(attendances_list, users_list): | ||
""" | ||
Select only desire attendances records by user condition. | ||
|
||
:param attendances_list: The list of attendances records. | ||
:param users_list: The list of desire users to be select. | ||
:return: Limited list of attendances records. | ||
""" | ||
return [ | ||
item | ||
for item in attendances_list | ||
if item.user_id in list(map(str, users_list)) | ||
] |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_limited_attendance accepts start_date & end_date not start & end, please fix it in the README, thanks!!
def get_limited_attendance(
self, users: list = [],
start_date=None, end_date=None
) -> list:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's done!