Skip to content

Commit

Permalink
fix: indexing burnt ACC updates (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
tahsintunan authored Jul 22, 2023
1 parent 3773fc5 commit 6dc00a6
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions nft_ingester/src/program_transformers/token_metadata/v1_asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,17 @@ pub async fn burn_v1_asset<T: ConnectionTrait + TransactionTrait>(
id: FBPubkey,
slot: u64,
) -> Result<(), IngesterError> {
let id = id.0;
let slot_i = slot as i64;
let (id, slot_i) = (id.0, slot as i64);
let model = asset::ActiveModel {
id: Set(id.to_vec()),
slot_updated: Set(slot_i),
burnt: Set(true),
..Default::default()
};

let mut query = asset::Entity::insert(model)
.on_conflict(
OnConflict::columns([asset::Column::Id])
.update_columns([asset::Column::SlotUpdated, asset::Column::Burnt])
.to_owned(),
)
// If the asset hasn't been indexed yet, we don't do anything.
let query = asset::Entity::update(model)
.filter(asset::Column::SlotUpdated.lt(slot_i))
.build(DbBackend::Postgres);
query.sql = format!(
"{} WHERE excluded.slot_updated > asset.slot_updated",
query.sql
);
conn.execute(query).await?;
Ok(())
}
Expand Down

0 comments on commit 6dc00a6

Please sign in to comment.