forgejo/services/repository
Gusted 70a7d6a0de
[ENHANCEMENT] Improve caching of contributor stats
- It was noticed [in the Forgejo matrix channel](https://matrix.to/#/!qjPHwFPdxhpLkXMkyP:matrix.org/$vk78UR0eFCwQMDMTZ7-DWjMVB_LIAwHW6SkjhEcGkQQ?via=matrix.org) that the generation of the Forgejo project contributor stats was taking quite a while on codeberg.org. This was continued with the fact that a few moments later it was once again generating them again; it seemed like they weren't being cached while they were.
- The problem was that the cache TTL is hardcoded to ten minutes and not to the configured TTL. This patch changes that by using the configured TLL for the contributor cache, as this is a computationally heavy operation and should be cached for as long as possible for a good user experience. This doesn't impact the accuracy of this feature because the commit ID of the default branch is used as a cache key.
- Also changed in this patch, is that errors aren't cached and are instead being logged, this is more helpful to the administrator. For the user essentially nothing changed on this side, the contributor stats just looks like it's loading indefinitely.
- Realistically, testing this isn't possible, as the cache library Forgejo currently uses doesn't expose the TTL or expiration time of a key. Manually testing this behavior is quite lengthy, as one of the steps would need to be "wait for ten minutes" and describe how you can notice the data was cached or was just generated, and because you could use different types of cache, it will be quite hard to write down how you could check the TTL of a key for a particular cache (I'm not even sure it's even possible for some).
2024-07-06 21:23:46 +02:00
..
archiver
commitstatus Fix automerge will not work because of some events haven't been triggered (#30780) 2024-05-26 19:01:36 +02:00
files
adopt.go Fix incorrect default branch when adopt a repository (#30912) 2024-05-12 20:03:10 +02:00
adopt_test.go fix(repository): git push to an adopted repository fails 2024-06-16 19:06:06 +02:00
avatar.go
avatar_test.go
branch.go Fix push multiple branches error with tests (#31151) 2024-06-02 20:39:42 +02:00
cache.go
check.go
collaboration.go
collaboration_test.go
commit.go
contributors_graph.go [ENHANCEMENT] Improve caching of contributor stats 2024-07-06 21:23:46 +02:00
contributors_graph_test.go [ENHANCEMENT] Improve caching of contributor stats 2024-07-06 21:23:46 +02:00
create.go
create_test.go
delete.go mysql: use inner join for hook_task deletion 2024-05-24 10:31:41 +02:00
fork.go
fork_test.go
generate.go cleanup(services): xstrings v1.5.0 the CAMEL & PASCAL workarounds 2024-06-07 18:10:37 +02:00
generate_test.go
hooks.go
init.go
lfs.go
lfs_test.go
main_test.go
migrate.go
push.go
repository.go Merge branch 'forgejo' into forgejo-federated-pr5 2024-05-29 18:26:16 +02:00
repository_test.go
review.go
review_test.go
setting.go
star.go feat(federated-star) star repositories via ActivityPub (#1680) 2024-06-06 08:58:11 +02:00
template.go
transfer.go Add lint-go-gopls (#30729) 2024-06-09 11:13:39 +02:00
transfer_test.go