Skip to content

feat: add download counter to activity sidebar#2490

Merged
miaulalala merged 1 commit intomasterfrom
feat/802/download-count-summary
Apr 8, 2026
Merged

feat: add download counter to activity sidebar#2490
miaulalala merged 1 commit intomasterfrom
feat/802/download-count-summary

Conversation

@miaulalala
Copy link
Copy Markdown
Collaborator

image

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 2, 2026

Codecov Report

❌ Patch coverage is 93.33333% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/components/DownloadSummary.vue 90.90% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@cypress
Copy link
Copy Markdown

cypress bot commented Apr 2, 2026

Activity    Run #3554

Run Properties:  status check passed Passed #3554  •  git commit e28d6f0382: feat: add download counter to activity sidebar
Project Activity
Branch Review feat/802/download-count-summary
Run status status check passed Passed #3554
Run duration 01m 52s
Commit git commit e28d6f0382: feat: add download counter to activity sidebar
Committer Anna
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 1
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 9
View all changes introduced in this branch ↗︎

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 via APIv2Controller::getDownloadCount() + route.
  • Frontend: add DownloadSummary component and render it in ActivityTab when 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 add tests/.phpunit.cache/ (or at least tests/.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 how func()->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 how func()->count(...) formats the expression.
    tests/DataTest.php:1
  • The new test inserts integer values (timestamp, object_id) without explicitly marking them as PARAM_INT. To align with the production query (which uses PARAM_INT) and avoid DB-specific typing quirks, pass IQueryBuilder::PARAM_INT for 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 as PARAM_INT. To align with the production query (which uses PARAM_INT) and avoid DB-specific typing quirks, pass IQueryBuilder::PARAM_INT for these numeric parameters in the test setup as well.
    src/components/DownloadSummary.vue:1
  • If fileId changes and the fetch fails, totalCount/monthlyCount remain 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=all and period=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.

@susnux
Copy link
Copy Markdown
Contributor

susnux commented Apr 2, 2026

Does this really makes sense to include in the activity app?
I would have expected this either in the files app or in the files_downloadlimit app (as this app already keeps track of downloads) and then register a ActivitySidebarPlugin just like comments does.

But otherwise fine and a nice improvement :)

@sorbaugh
Copy link
Copy Markdown

sorbaugh commented Apr 2, 2026

cc @jancborchardt @nimishavijay

@nimishavijay
Copy link
Copy Markdown
Member

Nice, the wording seems ok 👍

  • I would suggest we align the text and icons with the rest of the text and icons below (position seems to be a bit floating right now)
  • The color can be maxcontrast and there can be a var(--default-grid-baseline) * 3 margin at the bottom to distinguish between it and the rest of the items.
  • For the icon we can use the download for offline icon as the current one seems a bit outdated.

@miaulalala
Copy link
Copy Markdown
Collaborator Author

Does this really makes sense to include in the activity app? I would have expected this either in the files app or in the files_downloadlimit app (as this app already keeps track of downloads) and then register a ActivitySidebarPlugin just like comments does.

But otherwise fine and a nice improvement :)

I don't think we have the data without the activity app - the counter is based on the download activities.

@susnux susnux linked an issue Apr 3, 2026 that may be closed by this pull request
@miaulalala
Copy link
Copy Markdown
Collaborator Author

miaulalala commented Apr 7, 2026

3* 2*
image image

@nimishavijay should this be the regular BG colour too? The info has the same level of importance as the below lines imho. wdyt?

@nimishavijay
Copy link
Copy Markdown
Member

@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 default-grid-baseline *2 instead of *3 as it seems like waaay too much whitespace below now.

@miaulalala miaulalala requested a review from nimishavijay April 7, 2026 10:48
Copy link
Copy Markdown
Member

@nimishavijay nimishavijay left a comment

Choose a reason for hiding this comment

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

Nice! Good to go :)

@miaulalala miaulalala force-pushed the feat/802/download-count-summary branch from a081839 to 64aa1a7 Compare April 8, 2026 17:07
@miaulalala
Copy link
Copy Markdown
Collaborator Author

/compile amend

@miaulalala miaulalala marked this pull request as ready for review April 8, 2026 17:08
@nextcloud-command nextcloud-command force-pushed the feat/802/download-count-summary branch from 64aa1a7 to 0a9935f Compare April 8, 2026 17:10
@miaulalala miaulalala force-pushed the feat/802/download-count-summary branch from 0a9935f to 1c7137b Compare April 8, 2026 17:35
@miaulalala
Copy link
Copy Markdown
Collaborator Author

/compile amend

Signed-off-by: Anna Larch <anna@nextcloud.com>
Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
@nextcloud-command nextcloud-command force-pushed the feat/802/download-count-summary branch from 1c7137b to ebb93b3 Compare April 8, 2026 17:40
@miaulalala miaulalala merged commit e7f660a into master Apr 8, 2026
59 checks passed
@miaulalala miaulalala deleted the feat/802/download-count-summary branch April 8, 2026 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show the number of downloads of a public link

5 participants