-
-
Notifications
You must be signed in to change notification settings - Fork 45
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
Rundown api #1129
Rundown api #1129
Conversation
WalkthroughThe recent changes introduce pagination to the rundown retrieval process, add new endpoint functions for retrieving rundown data by ID and paginated data, enhance validation mechanisms, and include new tests. Significant modifications in the Changes
Sequence Diagram(s)New Rundown Retrieval FlowsequenceDiagram
participant Client
participant Router
participant Controller
participant Service
Client->>Router: Request rundown data (paginated)
Router->>Controller: Forward request
Controller->>Service: Fetch paginated rundown data
Service->>Controller: Return paginated data
Controller->>Router: Send response
Router->>Client: Return paginated rundown data
Client->>Router: Request rundown data by ID
Router->>Controller: Forward request
Controller->>Service: Fetch rundown data by ID
Service->>Controller: Return specific rundown data
Controller->>Router: Send response
Router->>Client: Return rundown data by ID
Updated Validation FlowsequenceDiagram
participant Client
participant Router
participant Validation
participant Controller
Client->>Router: Request with query parameters
Router->>Validation: Validate query parameters
Validation->>Router: Validation result
Router->>Controller: Forward request
Controller->>Router: Process request
Router->>Client: Send response
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (2)
packages/types/src/api/ontime-controller/BackendResponse.type.ts
is excluded by none and included by nonepackages/types/src/index.ts
is excluded by none and included by none
Files selected for processing (7)
- apps/server/src/api-data/rundown/rundown.controller.ts (2 hunks)
- apps/server/src/api-data/rundown/rundown.router.ts (3 hunks)
- apps/server/src/api-data/rundown/rundown.validation.ts (2 hunks)
- apps/server/src/services/rundown-service/RundownService.ts (1 hunks)
- apps/server/src/services/rundown-service/tests/rundownUtils.test.ts (1 hunks)
- apps/server/src/services/rundown-service/rundownUtils.ts (3 hunks)
- apps/server/src/services/runtime-service/RuntimeService.ts (5 hunks)
Files skipped from review due to trivial changes (1)
- apps/server/src/services/rundown-service/RundownService.ts
Additional comments not posted (15)
apps/server/src/services/rundown-service/__tests__/rundownUtils.test.ts (3)
13-20
: LGTM! Correctly tests pagination logic.The test case accurately verifies the pagination logic by checking the length and total of the paginated rundown.
22-29
: LGTM! Correctly handles overflows.The test case accurately verifies that the pagination function handles overflows by setting a limit greater than the total number of items and checking the length and total of the paginated rundown.
31-38
: LGTM! Correctly handles out-of-range offsets.The test case accurately verifies that the pagination function handles out-of-range offsets by setting an offset greater than the total number of items and checking the length and total of the paginated rundown.
apps/server/src/api-data/rundown/rundown.router.ts (3)
30-30
: LGTM! Correctly maps to the new function with validation.The route
/
is correctly mapped torundownGetPaginated
and includes the necessary validation for query parameters.
31-31
: LGTM! Correctly maps to the new function with validation.The route
/:eventId
is correctly mapped torundownGetById
and includes the necessary validation for theeventId
parameter.
8-10
: LGTM! Correct function imports.The import changes align with the updated routes and function signatures, correctly importing the new functions and removing the obsolete one.
apps/server/src/api-data/rundown/rundown.validation.ts (1)
79-88
: LGTM! Well-defined validation rules.The validation rules for the
offset
andlimit
query parameters are well-defined and include error handling.apps/server/src/services/rundown-service/rundownUtils.ts (2)
56-58
: LGTM! Correctly updated return type.The function
getEventWithId
has been updated to returnOntimeRundownEntry
instead ofOntimeEvent
, aligning with the new type requirements.
125-135
: LGTM! Efficient pagination logic.The
getPaginated
function correctly returns paginated rundown data using the provided offset and limit, efficiently handling pagination.apps/server/src/api-data/rundown/rundown.controller.ts (3)
29-44
: LGTM!The
rundownGetById
function is correctly implemented with proper error handling.
46-72
: LGTM!The
rundownGetPaginated
function is correctly implemented with proper error handling and query parameter parsing.
1-1
: LGTM!The function signature change for
rundownGetAll
aligns with the new functionality of returning paginated data.apps/server/src/services/runtime-service/RuntimeService.ts (3)
229-231
: LGTM!The usage of
isOntimeEvent
in themaybeUpdate
function ensures type safety and prevents potential runtime errors.
279-281
: LGTM!The usage of
isOntimeEvent
in thestartById
function ensures that only valid events are started, preventing potential runtime errors.
330-332
: LGTM!The usage of
isOntimeEvent
in theloadById
function ensures that only valid events are loaded, preventing potential runtime errors.
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.
Actionable comments posted: 0
Outside diff range, codebase verification and nitpick comments (1)
apps/server/src/api-data/rundown/rundown.validation.ts (1)
79-88
: LGTM! Consider adding a comment for clarity.The validation logic for
offset
andlimit
query parameters looks good. Consider adding a brief comment explaining the purpose of this validation array.+// Validates optional numeric query parameters 'offset' and 'limit' for pagination export const rundownGetPaginatedQueryParams = [ query('offset').isNumeric().optional(), query('limit').isNumeric().optional(), (req: Request, res: Response, next: NextFunction) => { const errors = validationResult(req); if (!errors.isEmpty()) return res.status(422).json({ errors: errors.array() }); next(); }, ];
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (2)
packages/types/src/api/ontime-controller/BackendResponse.type.ts
is excluded by none and included by nonepackages/types/src/index.ts
is excluded by none and included by none
Files selected for processing (6)
- apps/server/src/api-data/rundown/rundown.controller.ts (2 hunks)
- apps/server/src/api-data/rundown/rundown.router.ts (3 hunks)
- apps/server/src/api-data/rundown/rundown.validation.ts (2 hunks)
- apps/server/src/services/rundown-service/tests/rundownUtils.test.ts (1 hunks)
- apps/server/src/services/rundown-service/rundownUtils.ts (3 hunks)
- apps/server/src/services/runtime-service/RuntimeService.ts (5 hunks)
Files skipped from review as they are similar to previous changes (5)
- apps/server/src/api-data/rundown/rundown.controller.ts
- apps/server/src/api-data/rundown/rundown.router.ts
- apps/server/src/services/rundown-service/tests/rundownUtils.test.ts
- apps/server/src/services/rundown-service/rundownUtils.ts
- apps/server/src/services/runtime-service/RuntimeService.ts
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.
I tested the pagination/limit stuff and then fetching by id and everything seemed to behave as expected and return the correct data
This PR exposes the list of changes in the refetch message.
This means that consumers can know which events are affected by a change
In addition, we also add a few endpoints for granular rundown getting