1package indexer
2
3import (
4 "context"
5
6 "tangled.org/core/appview/models"
7 "tangled.org/core/appview/notify"
8 "tangled.org/core/log"
9)
10
11var _ notify.Notifier = &Indexer{}
12
13func (ix *Indexer) NewIssue(ctx context.Context, issue *models.Issue) {
14 l := log.FromContext(ctx).With("notifier", "indexer", "issue", issue)
15 l.Debug("indexing new issue")
16 err := ix.Issues.Index(ctx, *issue)
17 if err != nil {
18 l.Error("failed to index an issue", "err", err)
19 }
20}
21
22func (ix *Indexer) NewIssueState(ctx context.Context, issue *models.Issue) {
23 l := log.FromContext(ctx).With("notifier", "indexer", "issue", issue)
24 l.Debug("updating an issue")
25 err := ix.Issues.Index(ctx, *issue)
26 if err != nil {
27 l.Error("failed to index an issue", "err", err)
28 }
29}
30
31func (ix *Indexer) DeleteIssue(ctx context.Context, issue *models.Issue) {
32 l := log.FromContext(ctx).With("notifier", "indexer", "issue", issue)
33 l.Debug("deleting an issue")
34 err := ix.Issues.Delete(ctx, issue.Id)
35 if err != nil {
36 l.Error("failed to delete an issue", "err", err)
37 }
38}
39
40func (ix *Indexer) NewPull(ctx context.Context, pull *models.Pull) {
41 l := log.FromContext(ctx).With("notifier", "indexer", "pull", pull)
42 l.Debug("indexing new pr")
43 err := ix.Pulls.Index(ctx, pull)
44 if err != nil {
45 l.Error("failed to index a pr", "err", err)
46 }
47}
48
49func (ix *Indexer) NewPullState(ctx context.Context, pull *models.Pull) {
50 l := log.FromContext(ctx).With("notifier", "indexer", "pull", pull)
51 l.Debug("updating a pr")
52 err := ix.Pulls.Index(ctx, pull)
53 if err != nil {
54 l.Error("failed to index a pr", "err", err)
55 }
56}