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

Feature zms 3499 auto refresh queue #816

Merged
merged 4 commits into from
Feb 6, 2025

Conversation

MoDaae
Copy link
Collaborator

@MoDaae MoDaae commented Feb 4, 2025

Pull Request Checklist (Feature Branch to next):

  • Ich habe die neuesten Änderungen aus dem next Branch in meinen Feature-Branch gemergt.
  • Das Code-Review wurde abgeschlossen.
  • Fachliche Tests wurden durchgeführt und sind abgeschlossen.

Summary by CodeRabbit

  • New Features

    • Office listings now display extended details such as alternative names, organization info, and slot duration for clearer scheduling insights.
    • Interface buttons have been updated: the forwarding action is now always visible, while the emergency call option appears only when a valid workstation is active.
  • UI Improvements

    • Page refresh behavior has been streamlined for uninterrupted, continuous data updates.
  • Enhancements

    • Appointment slot cancellations now occur more quickly, providing a more responsive scheduling experience.

Copy link
Contributor

coderabbitai bot commented Feb 4, 2025

Walkthrough

This pull request updates several parts of the application’s configuration, frontend event handling, view templates, service logic, data models, tests, and JSON schemas. Key changes include updating an environment variable to point to a local API endpoint, removing and simplifying UI event handlers for reload timers, adjusting conditional rendering in templates, modifying redirection logic to use an optional queue number, commenting out middleware tests, and expanding the Office entity with additional fields. The changes are spread across JavaScript, PHP, Twig, and JSON schema files.

Changes

File(s) Change Summary
.ddev/.env.template Updates ZMS_API_URL from a remote URL to https://localhost/terminvereinbarung/api/2.
zmsadmin/js/page/counter/index.js, zmsadmin/js/page/workstation/index.js Removes several event handlers (window onblur, mouseenter/leave) that controlled a reload timer.
zmsadmin/templates/block/emergency/emergency.twig, zmsadmin/templates/block/process/info.twig Adds a conditional block to render an emergency button only if workstation.name exists and simplifies the conditional rendering of the "Weiterleiten" button.
zmsapi/.../ProcessRedirect.php Modifies the redirection logic to use process->queue['number'] if available, otherwise falls back to process->id.
zmscitizenapi/bootstrap.php Comments out the addition of SecurityHeadersMiddleware and CorsMiddleware.
zmscitizenapi/src/.../Office.php, zmscitizenapi/src/.../MapperService.php, zmscitizenapi/src/.../ZmsApiFacadeService.php Adds new properties (displayNameAlternatives, organization, organizationUnit, slotTimeInMinutes) to the Office entity with corresponding updates in constructors, serialization, and service methods; enforces a stricter return type in getOffices.
Test files in zmscitizenapi/tests/.../Office Updates expected office response structures to include the four new Office fields.
Test files in zmscitizenapi/tests/.../Middleware Comments out all methods in tests for CorsMiddleware and SecurityHeadersMiddleware.
zmsdb/.../CalculateSlots.php Changes the default $modify parameter in writeCanceledSlots() from '+10 minutes' to '+5 minutes'.
JSON schema files in zmsentities/schema/citizenapi/... Adds new properties (displayNameAlternatives, organization, organizationUnit, slotTimeInMinutes) to office-related schemas.

Sequence Diagram(s)

sequenceDiagram
    participant C as Client
    participant PR as ProcessRedirect
    participant RTS as redirectToScope Service
    C->>PR: Send API request
    PR->>PR: Determine identifier (queue number or process id)
    PR->>RTS: Call redirectToScope(identifier)
    RTS-->>C: Return redirection
Loading
sequenceDiagram
    participant Client as Client
    participant API as ZmsApiFacadeService
    participant Mapper as MapperService
    participant Office as Office Model
    Client->>API: Request offices
    API->>Mapper: Map provider data to offices
    Mapper->>Office: Instantiate Office (with new fields)
    Office-->>Mapper: Office object
    Mapper-->>API: OfficeList
    API-->>Client: Return OfficeList
Loading

Possibly related PRs

Suggested reviewers

  • ThomasAFink
  • manjencic

Poem

I’m a little rabbit, hopping through the code,
With changes so spry, lightening every load.
Endpoints now local, and handlers set free,
New fields in Office, as clear as can be.
Code hops ahead—let’s celebrate with glee!

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (6)
zmsentities/schema/citizenapi/office.json (1)

50-53: Improve the description of organizationUnit.

The description "The name of the organization" is too generic and similar to the organization field's description. Consider making it more specific to clarify the difference between organization and organizationUnit.

Apply this diff to improve the description:

-            "description": "The name of the organization"
+            "description": "The name of the specific unit or department within the organization"
zmsentities/schema/citizenapi/collections/officeList.json (1)

69-72: Improve the description of organizationUnit.

The description "The name of the organization" is too generic and similar to the organization field's description. Consider making it more specific to clarify the difference between organization and organizationUnit.

Apply this diff to improve the description:

-            "description": "The name of the organization"
+            "description": "The name of the specific unit or department within the organization"
zmscitizenapi/src/Zmscitizenapi/Services/Core/ZmsApiFacadeService.php (1)

64-67: Consider extracting the Office creation logic to reduce duplication.

The Office instantiation logic with the new properties is duplicated in both getOffices and getOfficesThatProvideService methods. Consider extracting this into a private helper method.

Here's a suggested implementation:

private static function createOfficeFromProvider($provider, ?ThinnedScope $scope = null): Office
{
    return new Office(
        id: (int) $provider->id,
        name: $provider->displayName ?? $provider->name,
        address: $provider->data['address'] ?? null,
        displayNameAlternatives: $provider->data['displayNameAlternatives'] ?? [],
        organization: $provider->data['organization'] ?? null,
        organizationUnit: $provider->data['organizationUnit'] ?? null,
        slotTimeInMinutes: $provider->data['slotTimeInMinutes'] ?? null,
        geo: $provider->data['geo'] ?? null,
        scope: $scope
    );
}

Then update both methods to use this helper:

// In getOffices method
-$offices[] = new Office(
-    id: (int) $provider->id,
-    name: $provider->displayName ?? $provider->name,
-    address: $provider->data['address'] ?? null,
-    displayNameAlternatives: $provider->data['displayNameAlternatives'] ?? [],
-    organization: $provider->data['organization'] ?? null,
-    organizationUnit: $provider->data['organizationUnit'] ?? null,
-    slotTimeInMinutes: $provider->data['slotTimeInMinutes'] ?? null,
-    geo: $provider->data['geo'] ?? null,
-    scope: $matchingScope ? new ThinnedScope(...) : null
-);
+$offices[] = self::createOfficeFromProvider(
+    $provider,
+    $matchingScope ? new ThinnedScope(...) : null
+);

// In getOfficesThatProvideService method
-$offices[] = new Office(
-    id: (int) $provider->id,
-    name: $provider->displayName ?? $provider->name,
-    address: $provider->data['address'] ?? null,
-    displayNameAlternatives: $provider->data['displayNameAlternatives'] ?? [],
-    organization: $provider->data['organization'] ?? null,
-    organizationUnit: $provider->data['organizationUnit'] ?? null,
-    slotTimeInMinutes: $provider->data['slotTimeInMinutes'] ?? null,
-    geo: $provider->data['geo'] ?? null,
-    scope: $scope instanceof ThinnedScope ? $scope : null
-);
+$offices[] = self::createOfficeFromProvider(
+    $provider,
+    $scope instanceof ThinnedScope ? $scope : null
+);

Also applies to: 374-377

zmsentities/schema/citizenapi/collections/officeServiceAndRelationList.json (3)

66-69: Review of 'displayNameAlternatives' property: Specify array item type if applicable.
The new property is correctly added, but it lacks an "items" definition to clarify the expected type of values. If this is meant to be an array of strings, consider adding an "items": { "type": "string" } schema.


74-77: Nitpick on 'organizationUnit' property: Clarify description.
The description for organizationUnit—"The name of the organization"—is similar to the one for organization, which may lead to ambiguity. It might be beneficial to differentiate the two (for example, by specifying that this field refers to a subdivision or unit within the organization).


78-81: Review of 'slotTimeInMinutes' property: Consider minimum value constraint.
While the property is correctly defined, it could be enhanced by adding a "minimum": 0 constraint to prevent negative slot times if such values are not valid in your domain.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d500f81 and cdbcd5b.

⛔ Files ignored due to path filters (3)
  • zmsadmin/package-lock.json is excluded by !**/package-lock.json
  • zmscalldisplay/package-lock.json is excluded by !**/package-lock.json
  • zmsstatistic/composer.lock is excluded by !**/*.lock
📒 Files selected for processing (19)
  • .ddev/.env.template (1 hunks)
  • zmsadmin/js/page/counter/index.js (0 hunks)
  • zmsadmin/js/page/workstation/index.js (0 hunks)
  • zmsadmin/templates/block/emergency/emergency.twig (1 hunks)
  • zmsadmin/templates/block/process/info.twig (1 hunks)
  • zmsapi/src/Zmsapi/ProcessRedirect.php (1 hunks)
  • zmscitizenapi/bootstrap.php (1 hunks)
  • zmscitizenapi/src/Zmscitizenapi/Models/Office.php (2 hunks)
  • zmscitizenapi/src/Zmscitizenapi/Services/Core/MapperService.php (1 hunks)
  • zmscitizenapi/src/Zmscitizenapi/Services/Core/ZmsApiFacadeService.php (3 hunks)
  • zmscitizenapi/tests/Zmscitizenapi/Controllers/Office/OfficeListByServiceControllerTest.php (3 hunks)
  • zmscitizenapi/tests/Zmscitizenapi/Controllers/Office/OfficesListControllerTest.php (2 hunks)
  • zmscitizenapi/tests/Zmscitizenapi/Controllers/Office/OfficesServicesRelationsControllerTest.php (2 hunks)
  • zmscitizenapi/tests/Zmscitizenapi/Middleware/CorsMiddlewareTest.php (5 hunks)
  • zmscitizenapi/tests/Zmscitizenapi/Middleware/SecurityHeadersMiddlewareTest.php (3 hunks)
  • zmsdb/src/Zmsdb/Helper/CalculateSlots.php (1 hunks)
  • zmsentities/schema/citizenapi/collections/officeList.json (1 hunks)
  • zmsentities/schema/citizenapi/collections/officeServiceAndRelationList.json (1 hunks)
  • zmsentities/schema/citizenapi/office.json (1 hunks)
💤 Files with no reviewable changes (2)
  • zmsadmin/js/page/workstation/index.js
  • zmsadmin/js/page/counter/index.js
✅ Files skipped from review due to trivial changes (3)
  • .ddev/.env.template
  • zmscitizenapi/tests/Zmscitizenapi/Middleware/SecurityHeadersMiddlewareTest.php
  • zmscitizenapi/tests/Zmscitizenapi/Middleware/CorsMiddlewareTest.php
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (12)
zmscitizenapi/src/Zmscitizenapi/Models/Office.php (3)

24-34: LGTM! Well-structured property declarations.

The new properties are properly typed and documented with PHPDoc comments.


42-64: LGTM! Constructor maintains backward compatibility.

The constructor is well-designed with:

  • Type declarations for parameters
  • Nullable parameters with default values
  • Proper property initialization

78-91: LGTM! Consistent serialization.

The toArray method properly includes all new properties in the serialized output.

zmsadmin/templates/block/emergency/emergency.twig (1)

10-14: LGTM! Improved button rendering logic.

The conditional check prevents the emergency button from rendering when workstation name is undefined, avoiding potential UI issues.

zmsadmin/templates/block/process/info.twig (1)

63-64: Verify the impact of always showing the redirect button.

The "Weiterleiten" button is now always visible, regardless of appointment status. Please confirm if this change is intentional and doesn't affect the business logic.

zmsapi/src/Zmsapi/ProcessRedirect.php (1)

54-59: LGTM! Enhanced process redirection logic.

The change improves process tracking by:

  • Using queue number as the primary identifier when available
  • Safely falling back to process ID using the null coalescing operator
zmscitizenapi/tests/Zmscitizenapi/Controllers/Office/OfficesListControllerTest.php (1)

44-47: LGTM! Test cases updated with new Office model fields.

The test cases have been properly updated to include the new Office model fields with appropriate default values.

Also applies to: 84-87

zmsdb/src/Zmsdb/Helper/CalculateSlots.php (1)

169-169: Verify the impact of reduced slot cancellation window.

The default time window for canceling slots has been reduced from 10 minutes to 5 minutes. This change could affect:

  1. User experience - less time to manage appointments
  2. System behavior - more frequent slot availability updates

Please confirm:

  1. Is this change intentional?
  2. Has this been communicated to users?
  3. Are there any dependent systems that need to be updated?
zmscitizenapi/tests/Zmscitizenapi/Controllers/Office/OfficesServicesRelationsControllerTest.php (1)

44-47: LGTM! Test cases updated with new Office model fields.

The test cases have been properly updated to include the new Office model fields with appropriate default values.

Also applies to: 84-87

zmscitizenapi/src/Zmscitizenapi/Services/Core/MapperService.php (1)

66-69: LGTM! The implementation handles the new Office properties correctly.

The code safely extracts the new properties from the provider data using null coalescing operators, ensuring graceful handling of missing data.

zmscitizenapi/src/Zmscitizenapi/Services/Core/ZmsApiFacadeService.php (1)

44-44: LGTM! Return type is now more specific.

The return type change from OfficeList|array to OfficeList improves type safety.

zmsentities/schema/citizenapi/collections/officeServiceAndRelationList.json (1)

70-73: Review of 'organization' property: Schema looks good.
The property is correctly defined as a string (or null) with a clear description. No issues found here.

@MoDaae MoDaae changed the base branch from main to next February 5, 2025 06:40
@MoDaae MoDaae merged commit 160dae9 into next Feb 6, 2025
23 checks passed
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.

2 participants