Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
joshstevens19 committed Aug 6, 2024
1 parent 3a0dfee commit f8751a6
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 27 deletions.
9 changes: 6 additions & 3 deletions cli/src/commands/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@ fn write_docker_compose(path: &Path) -> Result<(), WriteFileError> {
}

fn write_gitignore(path: &Path) -> Result<(), WriteFileError> {
write_file(&path.join(".gitignore"), r#".rindexer
write_file(
&path.join(".gitignore"),
r#".rindexer
generated_csv/**/*.txt
"#)
"#,
)
}

pub fn handle_new_command(
Expand Down Expand Up @@ -218,7 +221,7 @@ POSTGRES_PASSWORD=rindexer"#;
if is_rust_project {
generate_rindexer_rust_project(&project_path);
}

write_gitignore(&project_path)?;

print_success_message(&success_message);
Expand Down
2 changes: 1 addition & 1 deletion core/src/chat/clients.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ impl ChatClients {
}
}
}

if let Some(discord) = &self.discord {
for instance in discord {
if instance.config.networks.contains(&event_message.network) {
Expand Down
3 changes: 1 addition & 2 deletions core/src/event/conditions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ fn evaluate_condition(value: &Value, condition: &str) -> bool {
U64::from_str_radix(comp, 10).unwrap_or_default()
}
"=" => value == &Value::String(comp.to_string()),
"" => value == &Value::String(subpart.to_string()), /* Exact match if no */
// operator
"" => value == &Value::String(subpart.to_string()),
_ => false,
};
}
Expand Down
50 changes: 31 additions & 19 deletions core/src/indexer/last_synced.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,9 @@ async fn get_last_synced_block_number_file(
network: &str,
event_name: &str,
) -> Result<Option<U64>, UpdateLastSyncedBlockNumberFile> {
let file_path = build_last_synced_block_number_file(
full_path,
contract_name,
network,
event_name,
);

let file_path =
build_last_synced_block_number_file(full_path, contract_name, network, event_name);

let path = Path::new(&file_path);

if !path.exists() {
Expand Down Expand Up @@ -86,8 +82,9 @@ pub async fn get_last_synced_block_number(config: SyncConfig<'_>) -> Option<U64>
if config.database.is_none() && config.contract_csv_enabled {
if let Some(csv_details) = config.csv_details {
return if let Ok(result) = get_last_synced_block_number_file(
&get_full_path(config.project_path, &csv_details.path)
.unwrap_or_else(|_| panic!("failed to get full path {}", config.project_path.display())),
&get_full_path(config.project_path, &csv_details.path).unwrap_or_else(|_| {
panic!("failed to get full path {}", config.project_path.display())
}),
config.contract_name,
config.network,
config.event_name,
Expand All @@ -114,10 +111,16 @@ pub async fn get_last_synced_block_number(config: SyncConfig<'_>) -> Option<U64>
let stream_details = config.stream_details.as_ref().unwrap();

// create the path if it does not exist
stream_details.create_full_streams_last_synced_block_path(config.project_path, config.contract_name).await;
stream_details
.create_full_streams_last_synced_block_path(config.project_path, config.contract_name)
.await;

return if let Ok(result) = get_last_synced_block_number_file(
&config.project_path.join(stream_details.get_streams_last_synced_block_path()).canonicalize().expect("Failed to canonicalize path"),
&config
.project_path
.join(stream_details.get_streams_last_synced_block_path())
.canonicalize()
.expect("Failed to canonicalize path"),
config.contract_name,
config.network,
config.event_name,
Expand Down Expand Up @@ -187,7 +190,7 @@ async fn update_last_synced_block_number_for_file(
&config.network_contract.network,
&config.event_name,
);

let last_block = get_last_synced_block_number_file(
full_path,
&config.contract_name,
Expand Down Expand Up @@ -244,21 +247,30 @@ pub fn update_progress_and_last_synced(config: Arc<EventProcessingConfig>, to_bl
error!("Error updating last synced block: {:?}", e);
}
} else if let Some(csv_details) = &config.csv_details {
if let Err(e) =
update_last_synced_block_number_for_file(&config,
&get_full_path(&config.project_path, &csv_details.path)
.unwrap_or_else(|_| panic!("failed to get full path {}", config.project_path.display())),
to_block).await
if let Err(e) = update_last_synced_block_number_for_file(
&config,
&get_full_path(&config.project_path, &csv_details.path).unwrap_or_else(|_| {
panic!("failed to get full path {}", config.project_path.display())
}),
to_block,
)
.await
{
error!(
"Error updating last synced block to CSV - path - {} error - {:?}",
csv_details.path, e
);
}
} else if let Some(stream_last_synced_block_file_path) = &config.stream_last_synced_block_file_path {
} else if let Some(stream_last_synced_block_file_path) =
&config.stream_last_synced_block_file_path
{
if let Err(e) = update_last_synced_block_number_for_file(
&config,
&config.project_path.join(stream_last_synced_block_file_path).canonicalize().expect("Failed to canonicalize path"),
&config
.project_path
.join(stream_last_synced_block_file_path)
.canonicalize()
.expect("Failed to canonicalize path"),
to_block,
)
.await
Expand Down
10 changes: 8 additions & 2 deletions core/src/manifest/stream.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::path::Path;

use lapin::ExchangeKind;
use serde::{Deserialize, Deserializer, Serialize};
use serde_json::{Map, Value};
Expand Down Expand Up @@ -171,8 +172,13 @@ impl StreamsConfig {
path.trim_end_matches('_').to_string()
}

pub async fn create_full_streams_last_synced_block_path(&self, project_path: &Path, contract_name: &str) {
let path = self.get_streams_last_synced_block_path() + "/" + contract_name + "/last-synced-blocks";
pub async fn create_full_streams_last_synced_block_path(
&self,
project_path: &Path,
contract_name: &str,
) {
let path =
self.get_streams_last_synced_block_path() + "/" + contract_name + "/last-synced-blocks";

let full_path = project_path.join(path);

Expand Down

0 comments on commit f8751a6

Please sign in to comment.