Skip to content

Commit

Permalink
parse datetime reward_index
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeldjeffrey committed May 10, 2024
1 parent 42e8f97 commit 3c16657
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
7 changes: 1 addition & 6 deletions reward_index/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use anyhow::Result;
use chrono::{TimeZone, Utc};
use clap::Parser;
use file_store::{
file_info_poller::LookbackBehavior, file_source, reward_manifest::RewardManifest, FileStore,
Expand Down Expand Up @@ -82,11 +81,7 @@ impl Server {
.state(pool.clone())
.store(file_store)
.prefix(FileType::RewardManifest.to_string())
.lookback(LookbackBehavior::StartAfter(
Utc.timestamp_opt(settings.start_after as i64, 0)
.single()
.unwrap(),
))
.lookback(LookbackBehavior::StartAfter(settings.start_after))
.poll_duration(interval)
.offset(interval * 2)
.create()
Expand Down
7 changes: 4 additions & 3 deletions reward_index/src/settings.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use chrono::{DateTime, Utc};
use config::{Config, Environment, File};
use humantime_serde::re::humantime;
use serde::Deserialize;
Expand Down Expand Up @@ -38,15 +39,15 @@ pub struct Settings {
pub operation_fund_key: Option<String>,
pub unallocated_reward_entity_key: Option<String>,
#[serde(default = "default_start_after")]
pub start_after: u64,
pub start_after: DateTime<Utc>,
}

fn default_interval() -> Duration {
humantime::parse_duration("15 minutes").unwrap()
}

fn default_start_after() -> u64 {
0
fn default_start_after() -> DateTime<Utc> {
DateTime::UNIX_EPOCH
}

fn default_log() -> String {
Expand Down

0 comments on commit 3c16657

Please sign in to comment.