Skip to content

Commit

Permalink
fix some db indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Coats committed Mar 13, 2024
1 parent 66a3414 commit 96f00fc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/db/mongodb/collections/analytics/account_candidacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub struct AccountCandidacyDocument {
pub account_id: AccountId,
pub staking_start_epoch: EpochIndex,
pub staking_end_epoch: EpochIndex,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub candidacy_slots: Option<Vec<SlotIndex>>,
}

Expand Down Expand Up @@ -55,7 +56,7 @@ impl MongoDbCollection for AccountCandidacyCollection {
IndexOptions::builder()
.name("candidate_index".to_string())
.partial_filter_expression(doc! {
"candidacy_slot": { "$exists": true },
"candidacy_slots": { "$exists": true },
})
.build(),
)
Expand Down
3 changes: 3 additions & 0 deletions src/db/mongodb/collections/application_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ use crate::{
/// The MongoDb document representation of singleton Application State.
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub struct ApplicationStateDocument {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub starting_slot: Option<SlotIndex>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub last_migration: Option<MigrationVersion>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub node_config: Option<NodeConfiguration>,
}

Expand Down
3 changes: 3 additions & 0 deletions src/db/mongodb/collections/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@ pub struct BlockDocument {
/// The block.
block: Raw<Block>,
/// The block's state.
#[serde(default, skip_serializing_if = "Option::is_none")]
block_state: Option<BlockState>,
/// The index of the slot to which this block commits.
slot_index: SlotIndex,
/// The block's payload type.
#[serde(default, skip_serializing_if = "Option::is_none")]
payload_type: Option<u8>,
/// Metadata about the possible transaction payload.
#[serde(default, skip_serializing_if = "Option::is_none")]
transaction: Option<TransactionMetadata>,
}

Expand Down
3 changes: 2 additions & 1 deletion src/db/mongodb/collections/outputs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ pub struct OutputMetadata {
/// Commitment ID that includes the output.
pub commitment_id_included: SlotCommitmentId,
/// Optional spent metadata.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub spent_metadata: Option<SpentMetadata>,
}

Expand Down Expand Up @@ -662,7 +663,7 @@ impl OutputCollection {
[
doc! { "$match": {
"_id": output_id.to_bson(),
"metadata.spent_metadata": { "$ne": null }
"metadata.spent_metadata": { "$exists": true }
} },
doc! { "$replaceWith": "$metadata.spent_metadata" },
],
Expand Down

0 comments on commit 96f00fc

Please sign in to comment.