Skip to content

Commit

Permalink
Split imported events into multiple files.
Browse files Browse the repository at this point in the history
  • Loading branch information
qwandor committed May 25, 2024
1 parent 8c237bd commit 76a9f4e
Showing 1 changed file with 22 additions and 0 deletions.
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 axum::{
};
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 @@ fn print_events(events: &Events) -> Result<(), Report> {
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

0 comments on commit 76a9f4e

Please sign in to comment.