Don't update LastFirehoseRev more than once a day
parent
581cf8c720
commit
4b40c5919b
|
@ -32,6 +32,8 @@ import (
|
|||
"github.com/uabluerail/indexer/util/resolver"
|
||||
)
|
||||
|
||||
const lastRevUpdateInterval = 24 * time.Hour
|
||||
|
||||
type BadRecord struct {
|
||||
ID models.ID `gorm:"primarykey"`
|
||||
CreatedAt time.Time
|
||||
|
@ -430,6 +432,13 @@ func (c *Consumer) processMessage(ctx context.Context, typ string, r io.Reader,
|
|||
}
|
||||
}
|
||||
|
||||
if repoInfo.FirstCursorSinceReset > 0 && repoInfo.FirstRevSinceReset != "" &&
|
||||
repoInfo.LastIndexedRev != "" &&
|
||||
c.remote.FirstCursorSinceReset > 0 &&
|
||||
repoInfo.FirstCursorSinceReset >= c.remote.FirstCursorSinceReset &&
|
||||
repoInfo.FirstRevSinceReset <= repoInfo.LastIndexedRev &&
|
||||
time.Since(repoInfo.UpdatedAt) > lastRevUpdateInterval {
|
||||
|
||||
err = c.db.Model(&repo.Repo{}).Where(&repo.Repo{ID: repoInfo.ID}).
|
||||
Updates(&repo.Repo{
|
||||
LastFirehoseRev: payload.Rev,
|
||||
|
@ -437,6 +446,7 @@ func (c *Consumer) processMessage(ctx context.Context, typ string, r io.Reader,
|
|||
if err != nil {
|
||||
log.Error().Err(err).Msgf("Failed to update last_firehose_rev for %q: %s", repoInfo.DID, err)
|
||||
}
|
||||
}
|
||||
|
||||
if payload.TooBig {
|
||||
// Just trigger a re-index by resetting rev.
|
||||
|
|
Loading…
Reference in New Issue