-
Notifications
You must be signed in to change notification settings - Fork 2
Creat 2 serveis per a obtindre llistat de participants clasificats per status #311
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
Creat 2 serveis per a obtindre llistat de participants clasificats per status #311
Conversation
Created two services to return a list of participants with a status. Now we don't need to use 4 services to get accepted, rejected, pending and pendingGrouped. With this two services, the idea is to list ans clasyfy in frontend using status field. function in service_utils is to clasify id fast.
|
@elver5041 El sistema encara no l'he testejat ja que vaig reinstalar WSL i vaig perdre instalacions de llibreries i tal. |
Creada funció amb lambda per tal de retorna de forma directa la estructura a retorna juntament amb el status de cada hacker. Implementat aixo en 1 servei, per a testejar. Si funciona correctament, s'implementarà en el servei restant
S'ha optimitzat el codi utilitzant una lambda function per tal definida al service_utils per tal de retornar la estructura de les dades sense repetirles continuament. S'ha arreglat un error on en ves de crear la estructura a partir de hackers, es creaba a partir de la hacker id buscant atributs que no es podrien trobar. Actualitzat el gitignore per a no incloure el pyproject.toml i el uv.lock
|
En principi funciona perfectament. |
|
IMPORTANT: |
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.
Pull Request Overview
Adds two new endpoints and utility functions to fetch participants with status and grouping for a HackEPS event, replacing Poetry config with PDM.
- Introduce
get_hacker_statusandget_hacker_infohelpers inservice_utils.py - Add
get_hackers_participants_listandget_hackers_participants_gruped_listmethods inEvent/service.pyand register routes inrouter_v1.py - Migrate project config from Poetry to PDM in
pyproject.toml
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/utils/service_utils.py | Added status and info mapping helpers for hackers |
| src/impl/Event/service.py | New service methods to return participants lists |
| src/impl/Event/router_v1.py | New API routes for participants list and grouped list |
| pyproject.toml | Switched build config from Poetry to PDM |
Comments suppressed due to low confidence (4)
src/utils/service_utils.py:77
- [nitpick] Consider renaming
attribute_hacker_listtoHACKER_ATTRIBUTES(uppercase constant) to follow constant naming conventions.
attribute_hacker_list = [
src/impl/Event/service.py:535
- The word 'gruped' is misspelled; rename this function (and its route) to
get_hackers_participants_grouped_listfor consistency.
def get_hackers_participants_gruped_list(self, event_id: int,
src/impl/Event/service.py:57
- The comparison operator is split from its operand, causing a syntax error; move
>= datetime(year, 1, 1)onto the same line asEvent.start_datewithin thefiltercall.
>= datetime(year, 1, 1), Event.end_date
pyproject.toml:1
- [nitpick] The
authorsfield appears both intool.pdm.buildand under[project]; remove any unused or duplicated configuration sections.
[tool.pdm.build]
src/impl/Event/service.py
Outdated
| output_data = [] | ||
|
|
||
| participants_list = [ | ||
| get_hacker_info(hacker, pending_hackers_ids, accepted_hackers_ids, | ||
| rejected_hackers_ids) | ||
| for hacker in registered_hackers | ||
| ] | ||
|
|
||
| output_data.append(participants_list) | ||
| # Combine group and nogroup data into a dictionary | ||
| return {"participants": output_data} |
Copilot
AI
Jun 19, 2025
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.
Wrapping participants_list in another list results in a nested array in the response; return participants_list directly instead of appending it to output_data.
| output_data = [] | |
| participants_list = [ | |
| get_hacker_info(hacker, pending_hackers_ids, accepted_hackers_ids, | |
| rejected_hackers_ids) | |
| for hacker in registered_hackers | |
| ] | |
| output_data.append(participants_list) | |
| # Combine group and nogroup data into a dictionary | |
| return {"participants": output_data} | |
| participants_list = [ | |
| get_hacker_info(hacker, pending_hackers_ids, accepted_hackers_ids, | |
| rejected_hackers_ids) | |
| for hacker in registered_hackers | |
| ] | |
| # Combine group and nogroup data into a dictionary | |
| return {"participants": participants_list} |
src/impl/Event/service.py
Outdated
| subtract_lists( | ||
| pending_hackers_ids + accepted_hackers_ids + | ||
| rejected_hackers_ids, group_users), []) |
Copilot
AI
Jun 19, 2025
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.
The second subtract_lists call against an empty list has no effect; you can remove that extra call to simplify the expression.
| subtract_lists( | |
| pending_hackers_ids + accepted_hackers_ids + | |
| rejected_hackers_ids, group_users), []) | |
| pending_hackers_ids + accepted_hackers_ids + | |
| rejected_hackers_ids, group_users) |
src/impl/Event/service.py
Outdated
| non_group_hackers_ids = subtract_lists( | ||
| subtract_lists( | ||
| pending_hackers_ids + accepted_hackers_ids + | ||
| rejected_hackers_ids, group_users), []) |
Copilot
AI
Jun 19, 2025
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.
Using subtract_lists (which does a list in check) on large lists can be slow; consider using set operations for difference to improve performance.
| non_group_hackers_ids = subtract_lists( | |
| subtract_lists( | |
| pending_hackers_ids + accepted_hackers_ids + | |
| rejected_hackers_ids, group_users), []) | |
| non_group_hackers_ids = list( | |
| set(pending_hackers_ids + accepted_hackers_ids + rejected_hackers_ids) - set(group_users) | |
| ) |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ckers-participants-list-with-status
…ttps://github.com/LleidaHack/LleidaHackBackend into BACK-95-get-hackers-participants-list-with-status
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.
Pull Request Overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Big-Lolo
left a comment
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.
All correct
Els hackers obtinguts, es podran obtindre de forma indivitual amb status( pending, accepted or rejected).
També es podran obtindre amb la forma "grouped" i "nogroup" amb un status per a cada hacker (accepted, rejected, pending)
La idea es que el frontend utilitzi el filte que se li proporciona al lleidahacker per a que filtri resultats. Al mateix temps, l'usuari pot veure el numero de resultats obtinguts (Al admin dashboard)