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 zmskvr 145 wartezeit statistik #923

Merged
merged 32 commits into from
Mar 18, 2025

Conversation

MoDaae
Copy link
Collaborator

@MoDaae MoDaae commented Mar 6, 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

    • Introduced an automated daily waiting statistics calculation that enhances performance reporting.
    • Enhanced process tracking to prioritize accurate arrival times and indicate missed appointments.
    • Updated waiting time reports with clearer headers, including maximum waiting values.
  • Bug Fixes

    • Adjusted process status handling to more accurately reflect completion and missed process conditions.
    • Improved queue data processing for more reliable waiting time calculations.
    • Enhanced error handling in report generation for better robustness.

MoDaae added 24 commits February 3, 2025 15:51
…d() hinzugefügt, addValuesWaitingTimeData angepasst um die Fälle im Story
aufruf von setWasMissed wenn Wiederhole aufgebraucht sind
…lbst wenn es sich, um einen Termin handelt (Verpasste Termine bekommen Aufnahmezeit zur Zeit der Aufnahme)
…mme der Wartende pro stunde über mehrere Tage zu rechnen
Copy link
Contributor

coderabbitai bot commented Mar 6, 2025

Walkthrough

This update introduces several changes across the system. Process handling methods have been modified to update queue arrival times, adjust finished status flags, and conditionally mark processes as missed. A new daily statistic calculation feature has been added, comprising a cron command, a PHP script, and a helper class to calculate waiting times. In addition, database migrations and schema updates have been incorporated to support a new property for missed process tracking. Report templates and tests have been updated for terminology consistency, and formatting improvements have been applied to streamline method signatures and logging.

Changes

Files Change Summary
zmsadmin/src/Zmsadmin/ProcessQueueReset.php, zmsapi/src/Zmsapi/ProcessFinished.php, zmsapi/src/Zmsapi/ProcessQueued.php, zmsapi/src/Zmsapi/ProcessRedirect.php, zmsapi/src/Zmsapi/WorkstationProcessDelete.php, zmsapi/src/Zmsapi/WorkstationProcessParked.php Updated process response handling: added queue arrival time update, switched finished flag from true to false, added optional waiting time checks, and inserted logic to flag processes as missed based on status and metrics.
zmsapi/cron/cronjob.daily, zmsdb/bin/calculateDailyWaitingStatistic, zmsdb/composer.json, zmsdb/migrations/91740644959-calculateDailyWaitingStatistic.sql, zmsdb/src/Zmsdb/Helper/CalculateDailyWaitingStatisticByCron.php Introduced daily waiting statistic calculation feature via a new cron command, a dedicated PHP script, a composer bin entry, a migration for cron configuration, and a helper class to calculate and update statistics.
zmsdb/migrations/91738315597-add-column-wasMissed-buerger.sql, zmsdb/src/Zmsdb/Query/Process.php, zmsentities/schema/process.json, zmsentities/src/Zmsentities/Process.php Added and integrated a new wasMissed property for processes: new SQL column, JSON schema property, and corresponding entity methods (getter/setter and default value) to track missed processes.
zmsentities/tests/Zmsentities/ProcessTest.php Updated assertions in tests for waited seconds, minutes, and arrival times to reflect changes in the underlying calculation logic.
zmsstatistic/templates/page/reportWaitingIndex.twig, zmsstatistic/src/Zmsstatistic/Download/WaitingReport.php, zmsstatistic/tests/Zmsstatistic/ReportWaitingDepartmentTest.php, zmsstatistic/tests/Zmsstatistic/ReportWaitingOrganisationTest.php, zmsstatistic/tests/Zmsstatistic/ReportWaitingScopeTest.php Modified report templates and tests: adjusted table headers and content to include updated terminologies, such as appending “(Max.)” to month labels, and removed obsolete report parts.
zmsdb/src/Zmsdb/Process.php Simplified method signatures and logging statements through formatting improvements without changing core functionality.

Sequence Diagram(s)

sequenceDiagram
    participant Cron as CronJob
    participant Script as DailyWaitingStatisticScript
    participant Helper as CalculateDailyWaitingStatisticByCron
    participant DB as Database

    Cron->>Script: Invoke daily waiting statistic command
    Script->>Helper: Instantiate helper and call run(day, commit)
    Helper->>DB: Fetch citizen data (buerger)
    Helper->>Helper: Process data and aggregate waiting times
    alt commit flag set
        Helper->>DB: Insert/update statistics in wartenrstatistik
    else Dry run
        Helper-->>Script: Output dry run message (no DB changes)
    end
Loading
sequenceDiagram
    participant WS as WorkstationProcessDelete (ReadResponse)
    participant Proc as Process Object

    WS->>WS: Check process status is "called" and callCount exceeds maximum
    alt Conditions met
        WS->>Proc: Call setWasMissed(true)
    else
        WS->>Proc: Proceed without marking as missed
    end
Loading

Poem

I'm a little rabbit, hopping with delight,
I see our code has danced from dark to light.
New stats and missed flags now run in tune,
Cron jobs sing under the harvest moon 🌙.
With cleaner logs and neat arrays so tight,
Our changes hop forward—oh, what a sight!
Celebrate each line with a joyful bite!


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e222bf2 and 1b9d14f.

📒 Files selected for processing (1)
  • zmsapi/src/Zmsapi/ProcessQueued.php (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • zmsapi/src/Zmsapi/ProcessQueued.php

Note

🎁 Summarized by CodeRabbit Free

Your organization has reached its limit of developer seats under the Pro Plan. For new users, CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please add seats to your subscription by visiting https://app.coderabbit.ai/login.If you believe this is a mistake and have available seats, please assign one to the pull request author through the subscription management page using the link above.

🪧 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 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: 9

🧹 Nitpick comments (3)
zmsentities/src/Zmsentities/Exchange.php (1)

127-153: Consider logging skipped data and addressing pipeline formatting warning
Currently, if $date does not match the specified pattern or $dateItems is not an array, the code silently continues. If it's important to diagnose missing or malformed data, consider logging these events or raising exceptions. Additionally, storing results in $entity->data['sum'] may conflict if other sums are used; a more specific key name (e.g. 'hourlySum') would enhance clarity.

Also note that the pipeline reported a PHPCS formatting issue at line 131. You can remove the blank line before the foreach to comply:

129     $entity = clone $this;
130     $sums = [];
-131
132     foreach ($entity->data as $date => $dateItems) {
🧰 Tools
🪛 GitHub Actions: Combined Workflow

[error] 131-131: PHPCS: Blank line found at start of control structure. PHPCBF can fix this automatically.

zmsdb/src/Zmsdb/Query/Process.php (1)

916-944: Complex waiting time condition
This logic checks multiple status transitions (queued → called, missed → queued, etc.). Consider separating these paths into smaller, self-describing methods or adding comprehensive test coverage to reduce complexity and ensure correctness for all scenarios.

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

19-21: Use a dedicated logging mechanism instead of echo for CLI output.

While echo works, the project's coding guidelines recommend using a CLI output handler or a PSR-3–compliant logger for better maintainability and configurability.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4b2c06c and 6c9adc5.

⛔ Files ignored due to path filters (2)
  • zmsapi/composer.lock is excluded by !**/*.lock
  • zmsdldb/composer.lock is excluded by !**/*.lock
📒 Files selected for processing (20)
  • zmsadmin/src/Zmsadmin/ProcessQueueReset.php (1 hunks)
  • zmsapi/cron/cronjob.daily (1 hunks)
  • zmsapi/src/Zmsapi/ProcessFinished.php (1 hunks)
  • zmsapi/src/Zmsapi/ProcessQueued.php (1 hunks)
  • zmsapi/src/Zmsapi/ProcessRedirect.php (4 hunks)
  • zmsapi/src/Zmsapi/WorkstationProcessDelete.php (1 hunks)
  • zmsapi/src/Zmsapi/WorkstationProcessParked.php (0 hunks)
  • zmsdb/bin/calculateDailyWaitingStatistic (1 hunks)
  • zmsdb/composer.json (1 hunks)
  • zmsdb/migrations/91738315597-add-column-wasMissed-buerger.sql (1 hunks)
  • zmsdb/migrations/91740644959-calculateDailyWaitingStatistic.sql (1 hunks)
  • zmsdb/src/Zmsdb/Helper/CalculateDailyWaitingStatisticByCron.php (1 hunks)
  • zmsdb/src/Zmsdb/Process.php (13 hunks)
  • zmsdb/src/Zmsdb/Query/Process.php (4 hunks)
  • zmsentities/schema/process.json (1 hunks)
  • zmsentities/src/Zmsentities/Exchange.php (2 hunks)
  • zmsentities/src/Zmsentities/Process.php (3 hunks)
  • zmsentities/tests/Zmsentities/ProcessTest.php (3 hunks)
  • zmsstatistic/src/Zmsstatistic/ReportWaitingIndex.php (1 hunks)
  • zmsstatistic/templates/page/reportWaitingIndex.twig (7 hunks)
💤 Files with no reviewable changes (1)
  • zmsapi/src/Zmsapi/WorkstationProcessParked.php
✅ Files skipped from review due to trivial changes (3)
  • zmsdb/migrations/91740644959-calculateDailyWaitingStatistic.sql
  • zmsdb/migrations/91738315597-add-column-wasMissed-buerger.sql
  • zmsdb/src/Zmsdb/Process.php
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.php`: Flag any usage of error_log() as it should be re...

**/*.php: Flag any usage of error_log() as it should be replaced with proper logging mechanisms:

  1. For error handling: Use a proper logging framework with error levels (PSR-3 LoggerInterface)
  2. For debugging: Use a dedicated debug logger or remove debug statements
  3. For CLI output: Use a CLI output handler or symfony/console
  4. For application events: Use structured logging with proper log levels

Example replacement:

// Instead of:
error_log("Import failed - " . $e->getMessage());

// Use:
$logger->error("Import failed", ['error' => $e->getMessage()]);
  • zmsstatistic/src/Zmsstatistic/ReportWaitingIndex.php
  • zmsadmin/src/Zmsadmin/ProcessQueueReset.php
  • zmsapi/src/Zmsapi/ProcessQueued.php
  • zmsapi/src/Zmsapi/ProcessFinished.php
  • zmsapi/src/Zmsapi/ProcessRedirect.php
  • zmsentities/tests/Zmsentities/ProcessTest.php
  • zmsentities/src/Zmsentities/Process.php
  • zmsapi/src/Zmsapi/WorkstationProcessDelete.php
  • zmsentities/src/Zmsentities/Exchange.php
  • zmsdb/src/Zmsdb/Query/Process.php
  • zmsdb/src/Zmsdb/Helper/CalculateDailyWaitingStatisticByCron.php
🪛 GitHub Actions: Combined Workflow
zmsapi/src/Zmsapi/ProcessRedirect.php

[error] 1-1: ERROR | [x] Header blocks must be separated by a single blank line


[error] 9-9: ERROR | [x] Import statements must not begin with a leading backslash


[error] 10-10: ERROR | [x] Import statements must not begin with a leading backslash


[error] 12-12: ERROR | [x] Import statements must not begin with a leading backslash


[error] 13-13: ERROR | [x] Import statements must not begin with a leading backslash


[error] 44-44: ERROR | [x] Parentheses must be used when instantiating a new class


[error] 51-51: ERROR | [x] Parentheses must be used when instantiating a new class


[error] 81-81: ERROR | [x] Parentheses must be used when instantiating a new class


[error] 109-109: ERROR | [x] Parentheses must be used when instantiating a new class

zmsentities/src/Zmsentities/Exchange.php

[error] 131-131: PHPCS: Blank line found at start of control structure. PHPCBF can fix this automatically.

zmsdb/src/Zmsdb/Helper/CalculateDailyWaitingStatisticByCron.php

[error] 1-1: 19 errors found affecting 9 lines. Issues include: Import statements must not begin with a leading backslash, expected spaces around '=>', blank line found at start of control structure, and missing newline at end of file.

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (23)
zmsdb/composer.json (1)

47-47: Clean addition of new bin script.

The addition of the "bin/calculateDailyWaitingStatistic" script to the composer.json file is properly placed within the existing "bin" section. This script appears to be part of the new waiting time statistics feature.

zmsadmin/src/Zmsadmin/ProcessQueueReset.php (1)

37-39: Enhances queue tracking with arrival time.

This new block properly sets the arrival time for a process queue when it exists, improving time tracking which is essential for waiting time statistics.

zmsapi/cron/cronjob.daily (1)

13-13: Properly integrated new daily cron job.

The addition of the calculateDailyWaitingStatistic job to the daily cronjob follows the same pattern as other entries, with appropriate environment checking before execution.

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

32-34: Proper implementation of missed appointment tracking.

This condition correctly identifies when a process should be marked as missed based on its status and call count, enhancing the data available for waiting time statistics.

zmsstatistic/src/Zmsstatistic/ReportWaitingIndex.php (1)

53-53: Functional addition looks good!

The addition of withSumByHour(['waitingcount']) to the method chain enhances the existing data processing by aggregating the waiting count data by hour.

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

36-43: Good enhancement for queue data handling.

The new code correctly transfers the waiting time and arrival time from the request entity to the process entity when available, enhancing the queue data handling capabilities.

zmsentities/schema/process.json (1)

320-324: Schema addition is well-structured.

The new wasMissed property is well-defined with appropriate type, default value, and descriptive documentation. This addition will help track processes that were previously marked as missed.

zmsdb/bin/calculateDailyWaitingStatistic (1)

1-21: New script for calculating waiting statistics is well-implemented.

The script is properly structured with:

  • Clear documentation explaining its purpose
  • Command-line argument handling for verbose output and commit control
  • Appropriate error messaging for dry runs
  • Logical flow for calculating statistics based on the previous day's data

This is a good addition to enhance the system's reporting capabilities.

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

50-50: Logic change for process status recording.

The boolean parameter to writeEntityFinished has been changed from true to false, modifying how process completion is recorded in the database. This change aligns with the feature implementation for tracking waiting times properly.

zmsentities/tests/Zmsentities/ProcessTest.php (3)

157-157: Updated test expectation for waited seconds calculation.

The expected value in the test has been significantly changed from a previous high value (53767) to a much smaller value (45), which indicates a fundamental change in how waiting time is calculated in the system.


173-173: Updated test expectation for waited minutes calculation.

Similar to the waited seconds test, the expected value has been substantially reduced from 896.1167 to 0.75 minutes, reflecting the change in waiting time calculation logic.


381-381: Updated test expectation for arrival time.

The expected arrival time in the queue list test has been changed to '1447922893' from a previous value, aligning with the new arrival time tracking feature in this pull request.

zmsstatistic/templates/page/reportWaitingIndex.twig (3)

57-57: Updated column headers to indicate maximum values.

The column headers now explicitly indicate that the values shown are maximum values by adding "(Max.)" to the date format, improving clarity for users.

Also applies to: 175-175


73-75: Improved terminology for waiting time descriptions.

The descriptions have been updated to use more precise terminology, changing from "gemessene Zeit" (measured time) to "Wartezeit" (waiting time) and adding "Durchschnittliche" (average) where appropriate. This improves user understanding of the displayed statistics.

Also applies to: 118-119, 191-195, 238-239


123-126: Changed data source for waiting counts to use sum instead of max.

The template now correctly references the sum data structure for waiting counts instead of using the max structure, which provides more accurate statistics by aggregating data differently.

Also applies to: 243-245

zmsentities/src/Zmsentities/Process.php (5)

52-53: Verify default values for new properties
Setting 'wasMissed' => false by default is reasonable, but confirm that this aligns with overall missed-process logic. Also ensure 'lastChange' => time() is updated as intended throughout the entity's life cycle if it is truly meant to reflect the most recent modification.


576-587: Confirm queue-based arrival overriding appointment arrival
The new logic makes queue arrival time take precedence over appointment time. Ensure that this behavior is correct for the business scenarios involving late arrivals or “verpasste” Termine.


595-599: New setter method for arrivalTime
The straightforward assignment to $this->queue['arrivalTime'] looks good. No further issues.


624-629: Added setWasMissed method
Implementation is clean. This setter aligns with the newly introduced wasMissed property.


630-634: Added getWasMissed method
Returning a strict boolean is appropriate. The method appears correct.

zmsdb/src/Zmsdb/Query/Process.php (3)

245-245: Ensure wasMissed column is present
Confirm that the database schema has the wasMissed field to match this mapping. This is crucial for preventing undefined column errors.


687-687: Adding wasMissed to the update logic
Incorporating addValuesWasMissed($process); ensures the flag is consistently stored when updating. Looks good.


959-967: New addValuesWasMissed implementation
Storing a boolean as 1/0 is standard practice. Implementation is concise and consistent with the entity’s wasMissed property.

Comment on lines 109 to 110
$workstation = (new \BO\Zmsdb\Workstation)->readResolvedReferences($workstation, 1);
$process = (new Query())->writeNewPickup(
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add parentheses when instantiating a new class.

Parentheses must be used when instantiating a new class according to the coding standards.

Apply this fix:

-                $workstation = (new \BO\Zmsdb\Workstation)->readResolvedReferences($workstation, 1);
+                $workstation = (new \BO\Zmsdb\Workstation())->readResolvedReferences($workstation, 1);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
$workstation = (new \BO\Zmsdb\Workstation)->readResolvedReferences($workstation, 1);
$process = (new Query())->writeNewPickup(
$workstation = (new \BO\Zmsdb\Workstation())->readResolvedReferences($workstation, 1);
$process = (new Query())->writeNewPickup(
🧰 Tools
🪛 GitHub Actions: Combined Workflow

[error] 109-109: ERROR | [x] Parentheses must be used when instantiating a new class

Comment on lines 44 to 45
$process = (new Query)->updateEntity(
$process,
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add parentheses when instantiating a new class.

Parentheses must be used when instantiating a new class according to the coding standards.

Apply this fix:

-        $process = (new Query)->updateEntity(
+        $process = (new Query())->updateEntity(
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
$process = (new Query)->updateEntity(
$process,
$process = (new Query())->updateEntity(
$process,
🧰 Tools
🪛 GitHub Actions: Combined Workflow

[error] 44-44: ERROR | [x] Parentheses must be used when instantiating a new class

Comment on lines 81 to 82
$cluster = (new \BO\Zmsdb\Cluster)->readByScopeId($workstation->scope['id'], 1);
$workstation->testMatchingProcessScope($workstation->getScopeList($cluster), $process);
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add parentheses when instantiating a new class.

Parentheses must be used when instantiating a new class according to the coding standards.

Apply this fix:

-        $cluster = (new \BO\Zmsdb\Cluster)->readByScopeId($workstation->scope['id'], 1);
+        $cluster = (new \BO\Zmsdb\Cluster())->readByScopeId($workstation->scope['id'], 1);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
$cluster = (new \BO\Zmsdb\Cluster)->readByScopeId($workstation->scope['id'], 1);
$workstation->testMatchingProcessScope($workstation->getScopeList($cluster), $process);
$cluster = (new \BO\Zmsdb\Cluster())->readByScopeId($workstation->scope['id'], 1);
$workstation->testMatchingProcessScope($workstation->getScopeList($cluster), $process);
🧰 Tools
🪛 GitHub Actions: Combined Workflow

[error] 81-81: ERROR | [x] Parentheses must be used when instantiating a new class

Comment on lines 9 to 14
use \BO\Slim\Render;
use \BO\Mellon\Validator;
use BO\Zmsdb\Process;
use BO\Zmsdb\Process as Query;
use BO\Zmsdb\ProcessStatusQueued;
use \BO\Zmsdb\Process as Query;
use \BO\Zmsdb\ProcessStatusQueued;
use BO\Zmsdb\Workstation;
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove leading backslashes in import statements.

Import statements should not begin with leading backslashes as indicated by the pipeline failures.

Apply this fix:

-use \BO\Slim\Render;
-use \BO\Mellon\Validator;
 use BO\Zmsdb\Process;
-use \BO\Zmsdb\Process as Query;
-use \BO\Zmsdb\ProcessStatusQueued;
 use BO\Zmsdb\Workstation;
+use BO\Slim\Render;
+use BO\Mellon\Validator;
+use BO\Zmsdb\Process as Query;
+use BO\Zmsdb\ProcessStatusQueued;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
use \BO\Slim\Render;
use \BO\Mellon\Validator;
use BO\Zmsdb\Process;
use BO\Zmsdb\Process as Query;
use BO\Zmsdb\ProcessStatusQueued;
use \BO\Zmsdb\Process as Query;
use \BO\Zmsdb\ProcessStatusQueued;
use BO\Zmsdb\Workstation;
use BO\Slim\Render;
use BO\Mellon\Validator;
use BO\Zmsdb\Process;
use BO\Zmsdb\Process as Query;
use BO\Zmsdb\ProcessStatusQueued;
use BO\Zmsdb\Workstation;
🧰 Tools
🪛 GitHub Actions: Combined Workflow

[error] 9-9: ERROR | [x] Import statements must not begin with a leading backslash


[error] 10-10: ERROR | [x] Import statements must not begin with a leading backslash


[error] 12-12: ERROR | [x] Import statements must not begin with a leading backslash


[error] 13-13: ERROR | [x] Import statements must not begin with a leading backslash

Comment on lines 51 to 52
(new Workstation)->writeRemovedProcess($workstation);
$processStatusArchived->writeEntityFinished($process, \App::$now, false);
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix class instantiation and note the changed boolean parameter.

Two issues to address:

  1. Parentheses must be used when instantiating a new class
  2. Note that the boolean parameter to writeEntityFinished has been changed from true to false, matching the change in ProcessFinished.php

Apply this fix:

-        (new Workstation)->writeRemovedProcess($workstation);
-        $processStatusArchived->writeEntityFinished($process, \App::$now, false);
+        (new Workstation())->writeRemovedProcess($workstation);
+        $processStatusArchived->writeEntityFinished($process, \App::$now, false);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
(new Workstation)->writeRemovedProcess($workstation);
$processStatusArchived->writeEntityFinished($process, \App::$now, false);
(new Workstation())->writeRemovedProcess($workstation);
$processStatusArchived->writeEntityFinished($process, \App::$now, false);
🧰 Tools
🪛 GitHub Actions: Combined Workflow

[error] 51-51: ERROR | [x] Parentheses must be used when instantiating a new class

Comment on lines 1 to 217
'sid' => $scopeId,
'd' => $dateStr
];
$updateCols = [];

// Für jede Stunde 0..23 Spalten für "spontan" und "termin" füllen
foreach (range(0, 23) as $hour) {
// Dynamische Spaltennamen für spontane Kunden
$colWaitCountSp = sprintf('wartende_ab_%02d_spontan', $hour);
$colWaitTimeSp = sprintf('echte_zeit_ab_%02d_spontan', $hour);
$colWayTimeSp = sprintf('wegezeit_ab_%02d_spontan', $hour);

$countSp = $hoursData[$hour]['spontan']['count'];
$avgWaitSp= ($countSp > 0)
? round($hoursData[$hour]['spontan']['sumWait'] / $countSp, 2)
: 0.0;
$avgWaySp= ($countSp > 0)
? round($hoursData[$hour]['spontan']['sumWay'] / $countSp, 2)
: 0.0;

$updateCols[] = "`$colWaitCountSp` = :$colWaitCountSp";
$updateCols[] = "`$colWaitTimeSp` = :$colWaitTimeSp";
$updateCols[] = "`$colWayTimeSp` = :$colWayTimeSp";

$updateParams[$colWaitCountSp] = $countSp;
$updateParams[$colWaitTimeSp] = $avgWaitSp;
$updateParams[$colWayTimeSp] = $avgWaySp;

// termin
$colWaitCountTe = sprintf('wartende_ab_%02d_termin', $hour);
$colWaitTimeTe = sprintf('echte_zeit_ab_%02d_termin', $hour);
$colWayTimeTe = sprintf('wegezeit_ab_%02d_termin', $hour);

$countTe = $hoursData[$hour]['termin']['count'];
$avgWaitTe= ($countTe > 0)
? round($hoursData[$hour]['termin']['sumWait'] / $countTe, 2)
: 0.0;
$avgWayTe= ($countTe > 0)
? round($hoursData[$hour]['termin']['sumWay'] / $countTe, 2)
: 0.0;

$updateCols[] = "`$colWaitCountTe` = :$colWaitCountTe";
$updateCols[] = "`$colWaitTimeTe` = :$colWaitTimeTe";
$updateCols[] = "`$colWayTimeTe` = :$colWayTimeTe";

$updateParams[$colWaitCountTe] = $countTe;
$updateParams[$colWaitTimeTe] = $avgWaitTe;
$updateParams[$colWayTimeTe] = $avgWayTe;
}

$sqlUpdate = sprintf(
"UPDATE wartenrstatistik
SET %s
WHERE standortid = :sid
AND datum = :d
LIMIT 1",
implode(', ', $updateCols)
);

if ($commit) {
$this->perform($sqlUpdate, $updateParams);
} else {
echo "[DRY RUN] update scope=$scopeId, date=$dateStr with stats.\n";
}
}
}

echo "Done collecting stats for {$day->format('Y-m-d')}\n";
}

private function extractScopeFromAnmerkung(?string $anmerkung, ?string $customText): ?int
{
if (!$anmerkung && !$customText) {
return null;
}
$pattern = "/'StandortID' => '(\d+)'/";
foreach ([$anmerkung, $customText] as $txt) {
if (preg_match($pattern, (string)$txt, $matches)) {
return (int)$matches[1];
}
}
return null;
}

private function timeToMinutes(?string $timeStr): float
{
if (!$timeStr || $timeStr === '00:00:00') {
return 0.0;
}
$parts = explode(':', $timeStr);
if (count($parts) !== 3) {
return 0.0;
}
$h = (int)$parts[0];
$m = (int)$parts[1];
$s = (int)$parts[2];
$totalSeconds = $h * 3600 + $m * 60 + $s;
return round($totalSeconds / 60, 2);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Ensure consistent spacing around array key-value pairs.

The pipeline also flags several instances where spaces around => might not adhere to the required style. Review all array declarations to match the coding style consistently (e.g., key => value).

🧰 Tools
🪛 GitHub Actions: Combined Workflow

[error] 1-1: 19 errors found affecting 9 lines. Issues include: Import statements must not begin with a leading backslash, expected spaces around '=>', blank line found at start of control structure, and missing newline at end of file.

namespace BO\Zmsdb\Helper;

use BO\Zmsdb\Base;
use \DateTimeImmutable;
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove the leading backslash in the import statement to comply with coding standards.

According to the pipeline failure logs, import statements must not begin with a leading backslash.

- use \DateTimeImmutable;
+ use DateTimeImmutable;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
use \DateTimeImmutable;
use DateTimeImmutable;

Comment on lines +37 to +38
AND Name NOT IN ('(abgesagt)')
";
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove trailing whitespace to fix linting errors.

The pipeline logs indicate blank space issues, which can break strict code style rules.

-             AND Name NOT IN ('(abgesagt)')  
+             AND Name NOT IN ('(abgesagt)')
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
AND Name NOT IN ('(abgesagt)')
";
AND Name NOT IN ('(abgesagt)')
";

$totalSeconds = $h * 3600 + $m * 60 + $s;
return round($totalSeconds / 60, 2);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add a newline at the end of the file.

The pipeline complains about a missing newline.

 // End of file
-}
\ No newline at end of file
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
}
}

manjencic
manjencic previously approved these changes Mar 10, 2025
@MoDaae MoDaae merged commit 89f5b26 into next Mar 18, 2025
50 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