use crate::{
nns::{
NnsGovernanceRefreshAttemptStatus, governance::NnsGovernanceCacheMetadata,
neuron::report::model::NnsNeuronRow,
},
snapshot_cache::SnapshotEnvelope,
};
use serde::{Deserialize as SerdeDeserialize, Serialize};
pub(super) type NnsNeuronCache = SnapshotEnvelope<NnsGovernanceCacheMetadata, NnsNeuronCacheRows>;
pub(super) const NNS_NEURON_CACHE_FIELDS: &[&str] = &[
"schema_version",
"network",
"source_endpoint",
"fetched_at",
"fetched_by",
"domain",
"entity",
"collection",
"scope",
"governance_canister_id",
"completeness",
"neurons",
];
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
pub struct NnsNeuronRefreshReport {
pub schema_version: u32,
pub network: String,
pub governance_canister_id: String,
pub neuron_count: usize,
pub page_size: u32,
pub page_count: u32,
pub complete: bool,
pub point_in_time_guaranteed: bool,
pub replaced_existing_cache: bool,
pub attempt_finalization_error: Option<String>,
pub fetched_at: String,
pub source_endpoint: String,
pub fetched_by: String,
pub cache_path: String,
pub refresh_attempt_path: String,
pub refresh_lock_path: String,
}
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
pub struct NnsNeuronCacheStatusReport {
pub schema_version: u32,
pub network: String,
pub cache_root: String,
pub found: bool,
pub cache: Option<NnsNeuronCacheSummary>,
pub expected_cache_path: String,
pub refresh_attempt_path: String,
pub latest_attempt: Option<NnsGovernanceRefreshAttemptStatus>,
}
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
pub struct NnsNeuronCacheSummary {
pub cache_status: String,
pub cache_error: Option<String>,
pub complete: bool,
pub point_in_time_guaranteed: bool,
pub row_count: usize,
pub page_count: u32,
pub page_size: u32,
pub fetched_at: String,
pub source_endpoint: String,
pub cache_path: String,
}
#[derive(Clone, Debug, Eq, PartialEq, SerdeDeserialize, Serialize)]
pub(super) struct NnsNeuronCacheRows {
pub(super) neurons: Vec<NnsNeuronRow>,
}
pub(super) struct CompleteNeuronCollection {
pub(super) neurons: Vec<NnsNeuronRow>,
pub(super) page_count: u32,
pub(super) last_cursor: Option<String>,
}