Skip to content
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

Adds find_student method to search for students #46

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions ladok_lib/ladok3.nw
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,26 @@ def get_student(self, id):
return Student(ladok=self, id=id)
@

Sometimes we might want to search for a students using other attributes.
The [[kwargs]] dictionary contains keys that match the attributes of
[[Student]] objects.
The function will then return all students that match on all attributes
(conjunction\footnote{%
We can achieve a disjunction by calling [[find_student]] several times and
merge the results.
}).
<<LadokSession data methods>>=
@cachetools.cachedmethod(
operator.attrgetter("cache"),
key=functools.partial(cachetools.keys.hashkey, "find_student"))
def find_student(self, /, **kwargs):
"""Search for a student by non-unique Student attributes,
returns a list of Student objects"""
students = []
<<filter students by attributes>>
return students
@


\subsection{Courses}

Expand Down