Skip to content

Commit

Permalink
added updatedBy to historical image data
Browse files Browse the repository at this point in the history
  • Loading branch information
Ken Erwin committed Oct 15, 2024
1 parent 15f11e5 commit 1311aae
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
23 changes: 21 additions & 2 deletions backend/internal/ingestor/ingestor.go
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,25 @@ func (i *Ingestor) processTileUpdate(ctx context.Context, location *big.Int, ima
if len(image) > 800 {
image = image[:800]
}

// Try to lookup tx.From ENS
// Lookup ENS
ensName, err := lookupENS(i.ethClient, tx.From)
if err != nil {
if strings.Contains(err.Error(), "not a resolver") {
// This is an expected error for addresses without ENS names
i.logger.Debug("Address does not have an ENS name", zap.String("address", tx.From))
} else {
// Log other errors as warnings
i.logger.Warn("Failed to lookup ENS", zap.Error(err), zap.String("address", tx.From))
}
ensName = "" // Ensure ensName is empty if lookup failed
}
i.logger.Debug("ENS lookup result", zap.String("ens", ensName), zap.String("address", tx.From))
updatedBy := tx.From
if ensName != "" {
updatedBy = ensName
}
// Add to dataHistory
dataHistory := db.InsertDataHistoryParams{
TileID: int32(location.Int64()),
Expand All @@ -823,7 +842,7 @@ func (i *Ingestor) processTileUpdate(ctx context.Context, location *big.Int, ima
TimeStamp: time.Unix(timestamp, 0),
BlockNumber: blockNumber,
Image: image,
UpdatedBy: tx.From,
UpdatedBy: updatedBy,
LogIndex: transactionIndex,
}

Expand All @@ -832,7 +851,7 @@ func (i *Ingestor) processTileUpdate(ctx context.Context, location *big.Int, ima
}

// Update the tile in the database
err := i.queries.UpdateTile(ctx, db.UpdateTileParams{
err = i.queries.UpdateTile(ctx, db.UpdateTileParams{
ID: int32(location.Int64()),
Price: priceEthStr,
Url: url,
Expand Down
1 change: 1 addition & 0 deletions backend/internal/ingestor/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func GenerateTiledataJSON(tiles []db.Tile, queries *db.Queries, ctx context.Cont
"date": history.TimeStamp,
"image": history.Image,
"image_url": fmt.Sprintf("https://pixelmap.art/%d/%d.png", tile.ID, history.BlockNumber),
"updatedBy": history.UpdatedBy,
}
}

Expand Down

0 comments on commit 1311aae

Please sign in to comment.