aboutsummaryrefslogtreecommitdiffstats
path: root/cache/bug_subcache.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2022-12-21 21:54:36 +0100
committerMichael Muré <batolettre@gmail.com>2022-12-21 21:54:36 +0100
commit9b98fc06489353053564b431ac0c0d73a5c55a56 (patch)
tree67cab95c0c6167c0982516a2dda610bd5ece9eab /cache/bug_subcache.go
parent905c9a90f134842b97e2cf729d8b11ff59bfd766 (diff)
downloadgit-bug-9b98fc06489353053564b431ac0c0d73a5c55a56.tar.gz
cache: tie up the refactor up to compiling
Diffstat (limited to 'cache/bug_subcache.go')
-rw-r--r--cache/bug_subcache.go21
1 files changed, 12 insertions, 9 deletions
diff --git a/cache/bug_subcache.go b/cache/bug_subcache.go
index f0a8889b..14b56cdc 100644
--- a/cache/bug_subcache.go
+++ b/cache/bug_subcache.go
@@ -24,11 +24,7 @@ func NewRepoCacheBug(repo repository.ClockedRepo,
return NewBugCache(b, repo, getUserIdentity, entityUpdated)
}
- makeExcerpt := func(b *bug.Bug) *BugExcerpt {
- return NewBugExcerpt(b, b.Compile())
- }
-
- makeIndex := func(b *BugCache) []string {
+ makeIndexData := func(b *BugCache) []string {
snap := b.Snapshot()
var res []string
for _, comment := range snap.Comments {
@@ -38,9 +34,16 @@ func NewRepoCacheBug(repo repository.ClockedRepo,
return res
}
+ actions := Actions[*bug.Bug]{
+ ReadWithResolver: bug.ReadWithResolver,
+ ReadAllWithResolver: bug.ReadAllWithResolver,
+ Remove: bug.Remove,
+ MergeAll: bug.MergeAll,
+ }
+
sc := NewSubCache[*bug.Bug, *BugExcerpt, *BugCache](
repo, resolvers, getUserIdentity,
- makeCached, makeExcerpt, makeIndex,
+ makeCached, NewBugExcerpt, makeIndexData, actions,
"bug", "bugs",
formatVersion, defaultMaxLoadedBugs,
)
@@ -104,8 +107,8 @@ func (c *RepoCacheBug) ResolveComment(prefix string) (*BugCache, entity.Combined
return matchingBug, matchingCommentId, nil
}
-// QueryBugs return the id of all Bug matching the given Query
-func (c *RepoCacheBug) QueryBugs(q *query.Query) ([]entity.Id, error) {
+// Query return the id of all Bug matching the given Query
+func (c *RepoCacheBug) Query(q *query.Query) ([]entity.Id, error) {
c.mu.RLock()
defer c.mu.RUnlock()
@@ -140,7 +143,7 @@ func (c *RepoCacheBug) QueryBugs(q *query.Query) ([]entity.Id, error) {
}
for _, excerpt := range foundBySearch {
- if matcher.Match(excerpt, c) {
+ if matcher.Match(excerpt, c.resolvers()) {
filtered = append(filtered, excerpt)
}
}