feat: add download counter to activity sidebar#2490
Conversation
miaulalala
commented
Apr 2, 2026
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Activity
|
||||||||||||||||||||||||||||
| Project |
Activity
|
| Branch Review |
feat/802/download-count-summary
|
| Run status |
|
| Run duration | 01m 52s |
| Commit |
|
| Committer | Anna |
| View all properties for this run ↗︎ | |
| Test results | |
|---|---|
|
|
0
|
|
|
0
|
|
|
1
|
|
|
0
|
|
|
9
|
| View all changes introduced in this branch ↗︎ | |
There was a problem hiding this comment.
Pull request overview
Adds a “download count” summary to the file activity sidebar by introducing a new OCS endpoint to count public-link download activities and a Vue component that displays total and last-30-days counts.
Changes:
- Backend: add
Data::countDownloads()and expose it viaAPIv2Controller::getDownloadCount()+ route. - Frontend: add
DownloadSummarycomponent and render it inActivityTabwhen the node has a public link. - Tests/mocks: add PHPUnit + Vitest coverage and extend the axios mock for the new endpoint.
Reviewed changes
Copilot reviewed 17 out of 38 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/DataTest.php | Adds PHPUnit coverage for the new countDownloads() data-layer method |
| tests/.phpunit.cache/test-results | Adds PHPUnit cache artifact containing test run metadata |
| src/views/ActivityTab.vue | Renders DownloadSummary and gates it behind a “has public link” computed |
| src/components/DownloadSummary.vue | New Vue component fetching and displaying total / 30-day download counts |
| src/tests/DownloadSummary.test.ts | Vitest coverage for DownloadSummary rendering and refetch behavior |
| src/tests/ActivityTab.test.ts | Vitest coverage for conditional rendering of DownloadSummary in ActivityTab |
| src/mocks/@nextcloud/axios.js | Extends axios mock to handle the new download-count OCS endpoint |
| lib/Data.php | Adds countDownloads() query method counting download activities for a file |
| lib/Controller/APIv2Controller.php | Adds getDownloadCount() OCS endpoint with period handling |
| js/settings-store-D0Wy_JbI.chunk.mjs | Updates built asset content and its sourceMappingURL |
| js/activity-personalSettings.mjs | Updates built asset imports (including settings-store chunk name) |
| js/activity-app.mjs | Updates built asset imports after rebuild |
| js/activity-adminSettings.mjs | Updates built asset imports (including settings-store chunk name) |
| js/ActivityTab-X3_g71dI.chunk.mjs.map | Adds sourcemap for new ActivityTab bundle that includes DownloadSummary |
| js/ActivityTab-X3_g71dI.chunk.mjs | Adds new built ActivityTab bundle including DownloadSummary |
| js/ActivityTab-CV-K5d4d.chunk.mjs.map | Removes old ActivityTab sourcemap (previous bundle) |
| js/ActivityTab-CV-K5d4d.chunk.mjs.license | Updates license aggregation to include @mdi/svg (Apache-2.0) |
| js/ActivityTab-CV-K5d4d.chunk.mjs | Removes old ActivityTab bundle |
| appinfo/routes.php | Registers the new APIv2#getDownloadCount route |
Comments suppressed due to low confidence (7)
tests/.phpunit.cache/test-results:1
- PHPUnit cache artifacts (like
tests/.phpunit.cache/test-results) shouldn’t be committed because they create noisy diffs and can cause cross-environment churn. Remove this file from the PR and addtests/.phpunit.cache/(or at leasttests/.phpunit.cache/test-results) to.gitignore.
lib/Data.php:1 - The method assumes the DBAL layer will return the count column under the key
'count'. To make this robust across DBAL/query-builder implementations, prefer an explicit aliasing API (e.g.,selectAlias(...)/addSelect(... AS count)) so$row['count']is guaranteed to exist regardless of howfunc()->count(...)formats the expression.
lib/Data.php:1 - The method assumes the DBAL layer will return the count column under the key
'count'. To make this robust across DBAL/query-builder implementations, prefer an explicit aliasing API (e.g.,selectAlias(...)/addSelect(... AS count)) so$row['count']is guaranteed to exist regardless of howfunc()->count(...)formats the expression.
tests/DataTest.php:1 - The new test inserts integer values (
timestamp,object_id) without explicitly marking them asPARAM_INT. To align with the production query (which usesPARAM_INT) and avoid DB-specific typing quirks, passIQueryBuilder::PARAM_INTfor these numeric parameters in the test setup as well.
tests/DataTest.php:1 - The new test inserts integer values (
timestamp,object_id) without explicitly marking them asPARAM_INT. To align with the production query (which usesPARAM_INT) and avoid DB-specific typing quirks, passIQueryBuilder::PARAM_INTfor these numeric parameters in the test setup as well.
src/components/DownloadSummary.vue:1 - If
fileIdchanges and the fetch fails,totalCount/monthlyCountremain at their previous values, so the component can show stale counts for the new file. Clear the counts before starting the request (and/or in the catch block) so failures result in hiding the summary rather than displaying outdated data.
src/components/DownloadSummary.vue:1 - The UI makes two HTTP requests for every file (
period=allandperiod=30d). If this summary will be shown frequently, consider adding a single endpoint that returns both counts in one response to reduce request overhead and improve perceived sidebar performance.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Does this really makes sense to include in the activity app? But otherwise fine and a nice improvement :) |
|
Nice, the wording seems ok 👍
|
I don't think we have the data without the activity app - the counter is based on the download activities. |
@nimishavijay should this be the regular BG colour too? The info has the same level of importance as the below lines imho. wdyt? |
|
@miaulalala I'd lean slightly towards keeping it maxcontrast as it seems like metadata, but that's not a super strong opinion. We can change it to be consistent with the rest of the items below :) I would however suggest we do |
a081839 to
64aa1a7
Compare
|
/compile amend |
64aa1a7 to
0a9935f
Compare
0a9935f to
1c7137b
Compare
|
/compile amend |
Signed-off-by: Anna Larch <anna@nextcloud.com> Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
1c7137b to
ebb93b3
Compare

