Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split imported events into multiple files. #277

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,15 @@
};
use clap::{Parser, Subcommand, ValueEnum};
use eyre::Report;
use github::choose_file_for_event;
use log::info;
use schemars::schema_for;
use std::{
collections::HashMap,
env,

Check warning on line 53 in src/main.rs

View workflow job for this annotation

GitHub Actions / clippy

unused imports: `env`, `process::exit`

warning: unused imports: `env`, `process::exit` --> src/main.rs:53:5 | 53 | env, | ^^^ ... 56 | process::exit, | ^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default
fs::write,
path::{Path, PathBuf},
process::exit,
sync::{Arc, Mutex},
};
use tokio::net::TcpListener;
Expand Down Expand Up @@ -210,6 +214,24 @@
Ok(())
}

fn write_events_to_files(events: Events) -> Result<(), Report> {

Check warning on line 217 in src/main.rs

View workflow job for this annotation

GitHub Actions / clippy

function `write_events_to_files` is never used

warning: function `write_events_to_files` is never used --> src/main.rs:217:4 | 217 | fn write_events_to_files(events: Events) -> Result<(), Report> { | ^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(dead_code)]` on by default
let empty_events = Events::default();
let mut events_by_file: HashMap<String, Events> = HashMap::new();
for event in events.events {
let chosen_file = choose_file_for_event(&empty_events, &event).unwrap();
events_by_file
.entry(chosen_file)
.or_default()
.events
.push(event);
}
for (filename, events) in events_by_file {
info!("Writing {} events to {}", events.events.len(), filename);
write(filename, events.to_yaml_string()?)?;
}
Ok(())
}

async fn find_duplicates() -> Result<(), Report> {
let mut events = load_events(None).await?;

Expand Down
Loading