feat(UserStatsJobs): wire UserStatsJob to send stats to PSS via API client#18
Open
Arsalanulhaq wants to merge 2 commits intoas/dev/NSW-876-user-event-listenerfrom
Open
Conversation
a273b83 to
8810d6e
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates NCW Tools’ UserStatsJob to push user-count stats to NextcloudPSS via the ionos-ncpss-addons-api-client, introducing small service wrappers for client creation and PSS config access.
Changes:
- Replaced log-only behavior in
UserStatsJobwith an API call (updateStats) to PSS while keeping payload logging. - Added
PssConfigService(system-config reader) andApiStatsClientService(API client factory). - Added the new API client dependency to Composer and updated unit tests accordingly.
Reviewed changes
Copilot reviewed 7 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
lib/BackgroundJob/UserStatsJob.php |
Builds a PSS stats request and performs the updateStats API call with error logging. |
lib/Service/PssConfigService.php |
Reads PSS-related system config values used by the job. |
lib/Service/ApiStatsClientService.php |
Constructs the Guzzle client and Stats API wrapper from the generated client library. |
lib/AppInfo/Application.php |
Adds explicit vendor/autoload.php loading so the generated client classes resolve. |
tests/unit/BackgroundJob/UserStatsJobTest.php |
Updates/extends unit tests to verify the API call and error logging behavior. |
composer.json |
Adds the ionos-ncpss-addons-api-client repository + requirement; adjusts post-update bin behavior. |
composer.lock |
Locks new dependency set (including Guzzle + PSR packages and the IONOS client). |
psalm.xml |
Adds constructor references for Psalm’s container reflection setup. |
.gitignore |
Ignores a local directory related to the API client repo. |
b88779b to
f08c24c
Compare
ebc180d to
e3d658d
Compare
Replaces the log-only payload with an actual HTTP PUT call to the NextcloudPSS service using the ionos-ncpss-addons-api-client. Follows the same factory + config-service pattern as the mail app's IONOS integration (ApiStatsClientService, PssConfigService). Brand, extRef, and PSS credentials are read from system config. The log statement is kept alongside the API call for observability. Errors are caught and logged without retrying.
- Guard vendor/autoload.php require_once with file_exists() - Add connect/request timeouts to Guzzle client (5s/10s) - Move DateTime construction inside try/catch - Short-circuit on empty brand/extRef/baseUrl with error log - Log error on empty username/password in PssConfigService - Add dist section to composer.json to avoid requiring git at install time - Add test for missing required PSS config early-exit path
e3d658d to
d9f0fbb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
UserStatsJobwith an actual HTTP PUT call to the NextcloudPSS service usingionos-ncpss-addons-api-clientApiStatsClientService(factory) andPssConfigService(config reader) following the same pattern as the mail app's IONOS integrationncw_tools.pss.*)Test plan
1. Set system config keys (inside the container)
2. Temporary code change required for local testing (self-signed cert)
PSS uses a self-signed certificate locally. Guzzle will reject it by default, so these two temporary changes are needed — do not commit:
lib/Service/PssConfigService.php— add:lib/Service/ApiStatsClientService.php— changenewClient()to:lib/BackgroundJob/UserStatsJob.php— change thenewClient()call to:Then set the config flag:
3. Trigger the flow
4. Run the queued job
5. Verify