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