Skip to content

Commit

Permalink
🐛 Fixed issue where transfers don't regenerate tiledata.json
Browse files Browse the repository at this point in the history
  • Loading branch information
Ken Erwin committed Oct 3, 2024
1 parent b335da7 commit f08bfc8
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 42 deletions.
52 changes: 34 additions & 18 deletions backend/internal/ingestor/ingestor.go
Original file line number Diff line number Diff line change
Expand Up @@ -704,28 +704,13 @@ func (i *Ingestor) processDataHistory(ctx context.Context) error {
}
utils.RenderFullMap(tiles, "cache/tilemap.png")

// get all tiles
all_tiles, err := i.queries.ListTiles(ctx, db.ListTilesParams{
Limit: int32(3970),
Offset: 0,
})

if err != nil {
return fmt.Errorf("failed to get all tiles: %w", err)
// Call the reusable function
if err := i.updateTileDataAndSync(ctx); err != nil {
return err
}
GenerateTiledataJSON(all_tiles)

i.logger.Info("Finished processing data history", zap.Int("count", len(history)))

// Sync with S3 after processing only if s3Syncer is initialized
if i.s3Syncer != nil {
err := i.s3Syncer.SyncWithS3(ctx)
if err != nil {
i.logger.Error("Failed to sync with S3", zap.Error(err))
// Note: We're not returning this error as it shouldn't stop the main process
}
}

return nil
}

Expand Down Expand Up @@ -955,5 +940,36 @@ func (i *Ingestor) processTransfer(ctx context.Context, args []interface{}, tx *
return fmt.Errorf("failed to update tile owner: %w", err)
}

// Call the reusable function
if err := i.updateTileDataAndSync(ctx); err != nil {
return err
}

return nil
}

func (i *Ingestor) updateTileDataAndSync(ctx context.Context) error {
i.logger.Info("Updating tiledata.json and syncing with S3")
// Fetch all tiles
allTiles, err := i.queries.ListTiles(ctx, db.ListTilesParams{
Limit: int32(3970),
Offset: 0,
})
if err != nil {
return fmt.Errorf("failed to get all tiles: %w", err)
}

// Generate tiledata.json
GenerateTiledataJSON(allTiles)

// Sync with S3 if s3Syncer is initialized
if i.s3Syncer != nil {
err := i.s3Syncer.SyncWithS3(ctx)
if err != nil {
i.logger.Error("Failed to sync with S3", zap.Error(err))
// Note: We're not returning this error as it shouldn't stop the main process
}
}

return nil
}
24 changes: 0 additions & 24 deletions monorepo.code-workspace

This file was deleted.

0 comments on commit f08bfc8

Please sign in to comment.