Skip to content

133 feat people endpoint - #134

Open
SirAntonySir wants to merge 63 commits into
stagingfrom
133-feat-people-endpoint
Open

133 feat people endpoint#134
SirAntonySir wants to merge 63 commits into
stagingfrom
133-feat-people-endpoint

Conversation

@SirAntonySir

Copy link
Copy Markdown
Contributor

Created a GraphQl Endpoint for the People, including People Model, Enums, router, grapgql queries etc.

…d PersonBasicInfo to encapsulate detailed information about individuals.

- Added endpoints for retrieving people lists, filtering by faculty, and fetching individual person details.
- Implemented a data collection service to gather and store people data from the LSF system, including roles and courses.
- Enhanced the database schema with new tables for storing people, their roles, and courses, ensuring a structured approach to data management.
… role, improving data processing efficiency.

- Introduced crawl_single_role method in LSFPersonCrawler to fetch individuals associated with a specific role ID, including detailed logging for better tracking.
- Updated person ID generation to utilize personal.pid from profile URLs for improved uniqueness.
- Refactored upsert methods to prevent duplication of roles and courses in the database.
…and error handling

- Set REQUEST_DELAY to 0 in LSFPersonCrawler to optimize request timing.
- Implemented deduplication for courses and processed people in LSFPersonCrawler to prevent duplicate entries.
- Improved error handling in PeopleService for database operations, specifically for duplicate key violations, ensuring smoother processing of person data.
- Enhanced role and course ID generation to include person-specific identifiers, reducing collision risks.
- Added `faculty_id` field to `Person` and `PersonSummary` models for better identification.
- Updated `get_people` endpoint to filter by `faculty_id` instead of faculty enum.
- Introduced a new endpoint `get_people_by_faculty_id` for retrieving people by specific faculty ID.
- Enhanced `PeopleService` to map faculty ID to German faculty names and retrieve associated IDs from the database.
- Refactored existing faculty filtering logic to accommodate both faculty enum and ID.
…tering

- Updated `get_people` endpoint to apply pagination only when no faculty filter is provided.
- Enhanced `get_people_by_faculty_enum` to disable pagination, returning all results for a specific faculty.
- Introduced `get_faculty_enum_by_id` method in `PeopleService` to retrieve faculty enums based on faculty ID.
- Improved error handling and query logic in `PeopleService` for better performance and clarity.
…Summary` models, replacing them with a more streamlined approach using `faculty_enum`.

- Updated `get_people_by_faculty_enum` endpoint to accept `faculty_code` instead of `faculty` enum, enhancing clarity and usability.
- Introduced a new endpoint `get_people_by_faculty_id` for retrieving people based on faculty ID.
- Refactored `PeopleService` methods to utilize faculty codes, improving database queries and error handling.
- Adjusted the `FacultyTable` and `FacultyTranslationTable` to use integer IDs instead of strings for better consistency.
…ionality

- Consolidated person-related models by importing from a shared module, enhancing code maintainability.
- Updated `people_router` to utilize a new `PeopleAPIService`, streamlining service interactions.
- Enhanced error handling in faculty filtering logic within the `get_people` endpoint.
- Replaced the deprecated `PeopleCollector` with `PeopleCollectorV2` in the data fetcher, improving data collection efficiency.
- Introduced new logging capabilities for better tracking of data fetching processes.
- Refactored enums for academic titles and roles to improve clarity and consistency across the application.
…sponse models

- Updated `people_router` to utilize `PeopleService`, simplifying data fetching logic.
- Modified `get_people` endpoint to support filtering by faculty code and improved pagination handling.
- Removed deprecated GraphQL mutation and query files, consolidating functionality within the API.
- Enhanced `Person` model to allow optional basic info and introduced new response models for better data structure.
…ctionality

- Updated GraphQL mutations to streamline person creation and updates, enhancing clarity and consistency.
- Removed deprecated queries and consolidated functionality within the API, improving maintainability.
- Introduced new response models for person details, roles, and courses, ensuring a more structured data representation.
- Enhanced the `people_router` to utilize updated models, improving data fetching and response handling.
- Adjusted logging levels and error handling in data collection processes for better tracking and debugging.
…e GraphQL queries and models for consistency

- Deleted the `test_people_cms_service.py` file as it is no longer needed.
- Updated GraphQL mutations and queries to replace `institution` with `institution_name` for clarity.
- Refactored `PeopleService` and related models to ensure consistent naming conventions across the application.
- Enhanced error handling in the DirectusService for improved logging of GraphQL errors.
…data normalization

- Updated GraphQL mutations and queries to include courses in person details, streamlining data representation.
- Refactored `PeopleCollectorV2` to remove test mode and improve logging for data collection processes.
- Simplified course mapping in `PeopleModelMapper` to store course numbers directly, enhancing data structure.
- Improved error handling in `PeopleService` for person creation and updates, ensuring robust data processing.
- Consolidated course handling in person details, allowing for better integration with the overall data model.
…ectorV2 for async processing

- Added new GraphQL mutations for updating and deleting person roles, improving role management capabilities.
- Refactored `PeopleCollectorV2` to streamline character processing and introduced asynchronous crawling for better performance.
- Enhanced logging for role processing and character crawling, providing clearer insights into data collection activities.
- Improved error handling in role processing to ensure robust data management.
… handling

- Simplified the creation of `PersonDetails` in `PeopleModelMapper`, consolidating fields and improving clarity.
- Updated the `PersonComplete` model to include properties for email, phone, address, profile URL, office hours, status, and note, allowing for easier access to these details from the `PersonDetails`.
- Enhanced role mapping to store all institutions associated with a role, improving data representation and integrity.
…details

- Introduced `get_people_by_faculty` and `get_person_with_details` endpoints to fetch data using GraphQL queries, improving data retrieval capabilities.
- Updated `DirectusService` to enhance error handling and logging for GraphQL requests, ensuring better tracking of API interactions.
- Retained legacy endpoints for backward compatibility while refactoring the data fetching logic for improved clarity and maintainability.
…QL queries for improved consistency

- Deleted `test_api_endpoints.py` and `reset_people_duplicates.py` as they are no longer needed.
- Modified GraphQL queries in `new_people_queries.graphql` to remove unnecessary `limit` parameters, enhancing clarity and consistency.
- Updated various service files to reflect the removal of `limit` parameters, streamlining data fetching logic.
…ing service logic

- Deleted `new_people_queries.graphql` as it contained outdated GraphQL queries.
- Updated `people_router.py` to utilize the new `PeopleService`, enhancing data fetching logic.
- Removed `people_directus_service.py` to streamline service architecture and improve maintainability.
- Enhanced `people_service.py` with comprehensive methods for fetching and managing people data, ensuring better integration with the CMS.
- Renamed service methods to private (e.g., `get_people_roles` to `_get_people_roles`) to indicate internal usage.
- Simplified course data handling by directly using the course list instead of converting course data.
- Updated person details fetching method to align with the new naming convention, enhancing code maintainability.
… organization. and keep directus service untouched.

- Removed outdated comments and simplified GraphQL query handling in `people_queries.graphql`.
- Renamed query files in `people_service.py` for better clarity and consistency.
- Updated method calls to eliminate unnecessary operation names, enhancing code readability and maintainability.
@SirAntonySir
SirAntonySir requested a review from rpgraffi August 2, 2025 14:30
@SirAntonySir SirAntonySir linked an issue Aug 2, 2025 that may be closed by this pull request
4 tasks


# Legacy endpoints (keeping for backward compatibility)
@router.get("/", response_model=PeopleResponse)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete endpoint

@router.get("/faculty/{faculty_id}")
async def get_people_by_faculty(
faculty_id: int = Path(..., description="Faculty ID to filter by"),
offset: int = Query(0, ge=0, description="Number of people to skip")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove offset parameter

offset=offset
)

return {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return only people as list

"offset": offset
}

except Exception as e:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error handling in Service

Comment thread shared/src/models/people_model.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nothing should be in shared

- Updated `get_person_by_id.graphql` to include faculty details as an object instead of a string.
- Refactored `get_people_by_faculty` endpoint in `people_router.py` to return a list of people without offset handling.
- Simplified `get_all_people` method in `people_service.py` to support faculty filtering and improved query handling.
- Adjusted `Person` model to remove title and faculty_enum fields for better alignment with the updated data structure.
- Enhanced academic title handling in `people_enums.py` for more flexible matching.
- Updated Dockerfile to include the API folder for GraphQL file access.
…ality

- Removed the legacy `PersonBasic` and `PersonComplete` models, consolidating into a single `Person` model.
- Updated `get_all_people` method in `people_service.py` to return a list of `PersonSummary` instead of `PeopleResponse`.
- Enhanced data handling in `people_router.py` to streamline faculty filtering and response formatting.
- Adjusted properties in the `Person` model to directly access details, improving data encapsulation.
- Cleaned up unused imports and comments across various files for better code maintainability.
rpgraffi and others added 30 commits October 22, 2025 19:04
Bumps [urllib3](https://github.com/urllib3/urllib3) from 2.2.2 to 2.5.0.
- [Release notes](https://github.com/urllib3/urllib3/releases)
- [Changelog](https://github.com/urllib3/urllib3/blob/main/CHANGES.rst)
- [Commits](urllib3/urllib3@2.2.2...2.5.0)

---
updated-dependencies:
- dependency-name: urllib3
  dependency-version: 2.5.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* feat: generate recurring events relative to today

* fix: remove redundant fix

* fix: relativedelta

* refactor: simplify, use offset as recurrence_id

* refactor: remove useless helper func
…ructure (#145)

- Deleted wishlist models, services, and routers to streamline the API.
- Updated link resource handling by changing types from LinkType to string.
- Refactored database relationships and imports for links and benefits.
- Removed deprecated link collector and constants related to benefits and resources.
…unnecessary code (#147)

* renamed all symbols, tables and files from class and lecture to course

* removed deadcode and removed unessary commit in database insertion
* feat: more robust and improved exception system

* fix: add missing log message

* refactor: cleanup router

* refactor: change log level

* refactor: update calendar API endpoints and clean up static file mounts

* feat: more safety checks

* fix: endpoint names

* fix: typo

* fix: iCal link

* refactor: minor cleanup

* refactor: cleanup and safety check for iCal link

---------

Co-authored-by: raffi.git <51893700+rpgraffi@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT]: people endpoint

4 participants