diff --git a/backend/main.py b/backend/main.py index c4ba8fa..8ade5f6 100644 --- a/backend/main.py +++ b/backend/main.py @@ -1,4 +1,5 @@ - + +import lunchheros from fastapi.encoders import jsonable_encoder from src.lunchheros.db.dbFetcher import get_encoded_data @@ -28,6 +29,7 @@ def load_current_user(userId): def load_current_user(userId: str): userData = getUserWithId(userId) queryList = getAllQueryListData() - #test = get_encoded_data(1,1,userData) + + test = lunchheros.match.match(userData) return { "currentUser" : userData, "query": queryList} \ No newline at end of file diff --git a/backend/src/__init__.py b/backend/src/__init__.py index 577f3a6..fde3f74 100644 --- a/backend/src/__init__.py +++ b/backend/src/__init__.py @@ -1 +1,4 @@ -"""Lunchheros: Backend to match people for lunch based on their interests.""" \ No newline at end of file +"""Lunchheros: Backend to match people for lunch based on their interests.""" +from lunchheros import match + +__all__ = ["match"] \ No newline at end of file diff --git a/backend/src/lunchheros/match/__init__.py b/backend/src/lunchheros/match/__init__.py index 7cecbcd..7233da5 100644 --- a/backend/src/lunchheros/match/__init__.py +++ b/backend/src/lunchheros/match/__init__.py @@ -1 +1,5 @@ """Subpackage related to matching between users into groups.""" + +from lunchheros.match import matching + +__all__ = ["matching"] \ No newline at end of file diff --git a/backend/src/lunchheros/match/_randomize.py b/backend/src/lunchheros/match/_randomize.py index c1a0750..fd05658 100644 --- a/backend/src/lunchheros/match/_randomize.py +++ b/backend/src/lunchheros/match/_randomize.py @@ -1,5 +1,7 @@ import random +from lunchheros.db.dbFetcher import parse_user_id_tolist + def _randomize_groups(group_size: int, users: list[str]) -> list[list]: """Randomize the groups of users. @@ -37,4 +39,16 @@ def _randomize_groups(group_size: int, users: list[str]) -> list[list]: return groups +def match(userids): + + # convert userids to list + userids = parse_user_id_tolist(userids) + # group size + groupsize = 5 + # randomize the groups + groups = _randomize_groups(groupsize, userids) + # return the groups + return groups + +