You need to sign in or sign up before continuing.
Include total project snippet repository size in project statistics
At the moment, when a wiki or a project repository receives a push, we expire and recalculate some of the project statistics, in order to have, for example, an accurate storage size.
Now, with snippets having repositories, I think we should include this metric.
In #213526 (closed) we expire the snippet repository size. Therefore, when we call the ProjectCache
worker, all the snippet repository sizes should be up to date. The task will be to sum al the snippet repo sizes and include them in the overall project storage size.
Basically, we can:
- Add a column in
ProjectStatistics
likesnippets_size
- In https://gitlab.com/gitlab-org/gitlab/blob/master/app/workers/post_receive.rb#L75, add a call to call like
ProjectCacheWorker.perform_async(project.id, [], [:snippets_size])
after we expire the snippet repository size cache. - Update the
ProjectStatistic
model to include this newsnippets_size
metric - We should also call the
ProjectCacheWorker
when we remove a snippet. - Include the new metric in those views we show them (at the moment I'm only aware of the Admin section)
Test Activity
- Test that the statistics are updated properly when the repository is updated (more size/lower size)
@vij:
- Test statistic is incremented correctly
- Test statistic is decremented correctly
- Test statistic is included in admin views
MR Breakdown
We need to update one table in the database, the related class to include snippets, and also the places when we render this statistics, which can be views or API endpoints.
- 1 MR to add the column to the database
- 1 MR to update the main class
- 1 MR to update API endpoints
- 1 MR to update views
Edited by Francisco Javier López