Skip to content

Commit

Permalink
Merge pull request #152 from holaplex/abdul/total-mints
Browse files Browse the repository at this point in the history
Update total_mints when indexing each mint & fix metadata_json indexing
  • Loading branch information
imabdulbasit authored Jul 26, 2023
2 parents 7d9e761 + 67e6da3 commit 07676e5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions api/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ impl Processor {
project_id: Set(project_id.parse()?),
credits_deduction_id: Set(None),
creation_status: Set(CreationStatus::Created),
total_mints: Set(-1),
total_mints: Set(0),
address: Set(Some(mint_address)),
signature: Set(None),
seller_fee_basis_points: Set(seller_fee_basis_points.try_into()?),
Expand All @@ -233,7 +233,7 @@ impl Processor {
image: Set(image),
animation_url: Set(None),
external_url: Set(None),
..Default::default()
identifier: Set(String::new()),
};

let json_model = metadata_json.insert(self.db.get()).await?;
Expand Down Expand Up @@ -307,7 +307,7 @@ impl Processor {
image: Set(image),
animation_url: Set(None),
external_url: Set(None),
..Default::default()
identifier: Set(String::new()),
};

let json_model = metadata_json.insert(self.db.get()).await?;
Expand All @@ -324,6 +324,15 @@ impl Processor {
index_attributes(&self.db, json_model.id, attributes).await?;
index_files(&self.db, json_model.id, files).await?;

let collection = Collections::find_by_id(collection_id.parse()?)
.one(self.db.get())
.await
.context("failed to load collection from db")?
.context("collection not found in db")?;
let mut collection_am: collections::ActiveModel = collection.clone().into();

collection_am.total_mints = Set(collection.total_mints + 1);

Ok(())
}

Expand Down
2 changes: 1 addition & 1 deletion api/src/mutations/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ impl Mutation {
)),
}),
Some(&NftEventKey {
id: String::new(),
id: Uuid::new_v4().to_string(),
project_id: input.project.to_string(),
user_id: user_id.to_string(),
}),
Expand Down

0 comments on commit 07676e5

Please sign in to comment.