Start recording last rev for each repo

main
Max Ignatenko 2024-03-13 22:27:04 +00:00
parent 85259baa1c
commit 9c51a4621f
2 changed files with 9 additions and 0 deletions

View File

@ -356,6 +356,14 @@ func (c *Consumer) processMessage(ctx context.Context, typ string, r io.Reader,
} }
} }
err = c.db.Model(&repo.Repo{}).Where(&repo.Repo{ID: repoInfo.ID}).
Updates(&repo.Repo{
LastFirehoseRev: payload.Rev,
}).Error
if err != nil {
log.Error().Err(err).Msgf("Failed to update last_firehose_rev for %q: %s", repoInfo.DID, err)
}
if payload.TooBig { if payload.TooBig {
// Just trigger a re-index by resetting rev. // Just trigger a re-index by resetting rev.
err := c.db.Model(&repo.Repo{}).Where(&repo.Repo{ID: repoInfo.ID}). err := c.db.Model(&repo.Repo{}).Where(&repo.Repo{ID: repoInfo.ID}).

View File

@ -22,6 +22,7 @@ type Repo struct {
DID string `gorm:"uniqueIndex;column:did"` DID string `gorm:"uniqueIndex;column:did"`
LastIndexedRev string `gorm:"index:rev_state_index,expression:(last_indexed_rev < first_rev_since_reset),priority:1;index:was_indexed,expression:(last_indexed_rev is null OR last_indexed_rev = ''),priority:1"` LastIndexedRev string `gorm:"index:rev_state_index,expression:(last_indexed_rev < first_rev_since_reset),priority:1;index:was_indexed,expression:(last_indexed_rev is null OR last_indexed_rev = ''),priority:1"`
FirstRevSinceReset string FirstRevSinceReset string
LastFirehoseRev string
FirstCursorSinceReset int64 FirstCursorSinceReset int64
TombstonedAt time.Time TombstonedAt time.Time
LastIndexAttempt time.Time LastIndexAttempt time.Time