Remove deleted_at
parent
8561d90caf
commit
8313c74482
|
@ -151,7 +151,7 @@ func (c *Consumer) checkForCursorReset(ctx context.Context, seq int64) error {
|
|||
func (c *Consumer) resetCursor(ctx context.Context, seq int64) error {
|
||||
zerolog.Ctx(ctx).Warn().Str("pds", c.remote.Host).Msgf("Cursor reset: %d -> %d", c.remote.Cursor, seq)
|
||||
err := c.db.Model(&c.remote).
|
||||
Where(&pds.PDS{Model: gorm.Model{ID: c.remote.ID}}).
|
||||
Where(&pds.PDS{ID: c.remote.ID}).
|
||||
Updates(&pds.PDS{FirstCursorSinceReset: seq}).Error
|
||||
if err != nil {
|
||||
return fmt.Errorf("updating FirstCursorSinceReset: %w", err)
|
||||
|
@ -167,7 +167,7 @@ func (c *Consumer) updateCursor(ctx context.Context, seq int64) error {
|
|||
}
|
||||
|
||||
err := c.db.Model(&c.remote).
|
||||
Where(&pds.PDS{Model: gorm.Model{ID: c.remote.ID}}).
|
||||
Where(&pds.PDS{ID: c.remote.ID}).
|
||||
Updates(&pds.PDS{Cursor: seq}).Error
|
||||
if err != nil {
|
||||
return fmt.Errorf("updating Cursor: %w", err)
|
||||
|
@ -271,7 +271,7 @@ func (c *Consumer) processMessage(ctx context.Context, typ string, r io.Reader,
|
|||
|
||||
if payload.TooBig {
|
||||
// Just trigger a re-index by resetting rev.
|
||||
err := c.db.Model(r).Where(&repo.Repo{Model: gorm.Model{ID: repoInfo.ID}}).
|
||||
err := c.db.Model(r).Where(&repo.Repo{ID: repoInfo.ID}).
|
||||
Updates(&repo.Repo{
|
||||
FirstCursorSinceReset: c.remote.FirstCursorSinceReset,
|
||||
FirstRevSinceReset: payload.Rev,
|
||||
|
@ -282,7 +282,7 @@ func (c *Consumer) processMessage(ctx context.Context, typ string, r io.Reader,
|
|||
}
|
||||
|
||||
if repoInfo.FirstCursorSinceReset != c.remote.FirstCursorSinceReset {
|
||||
err := c.db.Model(r).Where(&repo.Repo{Model: gorm.Model{ID: repoInfo.ID}}).
|
||||
err := c.db.Model(r).Where(&repo.Repo{ID: repoInfo.ID}).
|
||||
Updates(&repo.Repo{
|
||||
FirstCursorSinceReset: c.remote.FirstCursorSinceReset,
|
||||
FirstRevSinceReset: payload.Rev,
|
||||
|
|
|
@ -117,7 +117,7 @@ func (p *WorkerPool) worker(ctx context.Context, signal chan struct{}) {
|
|||
}
|
||||
updates.LastIndexAttempt = time.Now()
|
||||
err := p.db.Model(&repo.Repo{}).
|
||||
Where(&repo.Repo{Model: gorm.Model{ID: work.Repo.ID}}).
|
||||
Where(&repo.Repo{ID: work.Repo.ID}).
|
||||
Updates(updates).Error
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msgf("Failed to update repo info for %q: %s", work.Repo.DID, err)
|
||||
|
@ -216,7 +216,7 @@ retry:
|
|||
}
|
||||
}
|
||||
|
||||
err = p.db.Model(&repo.Repo{}).Where(&repo.Repo{Model: gorm.Model{ID: work.Repo.ID}}).
|
||||
err = p.db.Model(&repo.Repo{}).Where(&repo.Repo{ID: work.Repo.ID}).
|
||||
Updates(&repo.Repo{LastIndexedRev: newRev}).Error
|
||||
if err != nil {
|
||||
return fmt.Errorf("updating repo rev: %w", err)
|
||||
|
|
|
@ -4,10 +4,14 @@ import (
|
|||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"github.com/uabluerail/indexer/models"
|
||||
)
|
||||
|
||||
type PDS struct {
|
||||
gorm.Model
|
||||
ID models.ID `gorm:"primarykey"`
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
Host string `gorm:"uniqueIndex"`
|
||||
Cursor int64
|
||||
FirstCursorSinceReset int64
|
||||
|
|
|
@ -16,7 +16,9 @@ import (
|
|||
)
|
||||
|
||||
type Repo struct {
|
||||
gorm.Model
|
||||
ID models.ID `gorm:"primarykey"`
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
PDS models.ID `gorm:"index:rev_state_index,priority:2;index:was_indexed,priority:2"`
|
||||
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"`
|
||||
|
@ -28,7 +30,9 @@ type Repo struct {
|
|||
}
|
||||
|
||||
type Record struct {
|
||||
gorm.Model
|
||||
ID models.ID `gorm:"primarykey"`
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
Repo models.ID `gorm:"index:idx_repo_record_key,unique,priority:1;not null"`
|
||||
Collection string `gorm:"index:idx_repo_record_key,unique,priority:2;not null"`
|
||||
Rkey string `gorm:"index:idx_repo_record_key,unique,priority:3"`
|
||||
|
|
Loading…
Reference in New Issue