Skip to content

Commit

Permalink
Merge pull request #205 from tstromberg/cache-times
Browse files Browse the repository at this point in the history
Use internal mtime tracking to determine in-memory issue validatity
  • Loading branch information
tstromberg authored Aug 19, 2020
2 parents 1dd4c54 + 30d303f commit 0a05f35
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/hubbub/conversation.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type Conversation struct {
// Latest comment or event
Updated time.Time `json:"updated"`

// Seen is the time we last saw this conversation
// Seen is the age of the data which generated this data
Seen time.Time `json:"seen"`

// When did this item reach the current priority?
Expand Down
4 changes: 2 additions & 2 deletions pkg/hubbub/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,10 @@ func (h *Engine) IssueSummary(i *github.Issue, cs []*github.IssueComment, age ti
key := i.GetHTMLURL()
cached, ok := h.seen[key]
if ok {
if !cached.Updated.Before(i.GetUpdatedAt()) && cached.CommentsTotal >= len(cs) {
if !cached.Seen.Before(h.mtime(i)) && cached.CommentsTotal >= len(cs) {
return h.seen[key]
}
klog.Infof("%s in issue cache, but was invalid. Live @ %s (%d comments), cached @ %s (%d comments) ", i.GetHTMLURL(), i.GetUpdatedAt(), len(cs), cached.Updated, cached.CommentsTotal)
klog.Infof("%s in issue cache, but was invalid. Live @ %s (%d comments), cached @ %s (%d comments) ", i.GetHTMLURL(), h.mtime(i), len(cs), cached.Seen, cached.CommentsTotal)
}

h.seen[key] = h.createIssueSummary(i, cs, age)
Expand Down
4 changes: 2 additions & 2 deletions pkg/hubbub/pull_requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,10 @@ func (h *Engine) PRSummary(ctx context.Context, pr *github.PullRequest, cs []*Co
key := pr.GetHTMLURL()
cached, ok := h.seen[key]
if ok {
if !cached.Updated.Before(pr.GetUpdatedAt()) && cached.CommentsTotal >= len(cs) && cached.TimelineTotal >= len(timeline) && cached.ReviewsTotal >= len(reviews) {
if !cached.Seen.Before(h.mtime(pr)) && cached.CommentsTotal >= len(cs) && cached.TimelineTotal >= len(timeline) && cached.ReviewsTotal >= len(reviews) {
return h.seen[key]
}
klog.Infof("%s in PR cache, but was invalid. Live @ %s (%d comments), cached @ %s (%d comments) ", pr.GetHTMLURL(), pr.GetUpdatedAt(), len(cs), cached.Updated, cached.CommentsTotal)
klog.Infof("%s in PR cache, but was invalid. Live @ %s (%d comments), cached @ %s (%d comments) ", pr.GetHTMLURL(), h.mtime(pr), len(cs), cached.Seen, cached.CommentsTotal)
}

h.seen[key] = h.createPRSummary(ctx, pr, cs, timeline, reviews, age, fetch)
Expand Down

0 comments on commit 0a05f35

Please sign in to comment.