mirror of
				https://github.com/Djeeberjr/fw-anwesenheit.git
				synced 2025-11-04 07:34:10 +00:00 
			
		
		
		
	added IDMapping to IDStore
This commit is contained in:
		
							parent
							
								
									de7c260e14
								
							
						
					
					
						commit
						907b758626
					
				@ -5,7 +5,7 @@ use std::{
 | 
			
		||||
};
 | 
			
		||||
use tokio::fs;
 | 
			
		||||
 | 
			
		||||
use crate::tally_id::TallyID;
 | 
			
		||||
use crate::{id_mapping::IDMapping, tally_id::TallyID};
 | 
			
		||||
 | 
			
		||||
/// Represents a single day that IDs can attend
 | 
			
		||||
#[derive(Deserialize, Serialize)]
 | 
			
		||||
@ -18,12 +18,14 @@ pub struct AttendanceDay {
 | 
			
		||||
#[derive(Deserialize, Serialize)]
 | 
			
		||||
pub struct IDStore {
 | 
			
		||||
    days: HashMap<String, AttendanceDay>,
 | 
			
		||||
    pub mapping: IDMapping,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl IDStore {
 | 
			
		||||
    pub fn new() -> Self {
 | 
			
		||||
        IDStore {
 | 
			
		||||
            days: HashMap::new(),
 | 
			
		||||
            mapping: IDMapping::new(),
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -82,7 +84,7 @@ impl IDStore {
 | 
			
		||||
        days.sort();
 | 
			
		||||
 | 
			
		||||
        let header = days.join(seperator);
 | 
			
		||||
        csv.push_str(&format!("ID{}{}\n", seperator, header));
 | 
			
		||||
        csv.push_str(&format!("ID{seperator}{header}\n"));
 | 
			
		||||
 | 
			
		||||
        for user_id in user_ids.iter() {
 | 
			
		||||
            csv.push_str(&user_id.0.to_string());
 | 
			
		||||
@ -95,7 +97,7 @@ impl IDStore {
 | 
			
		||||
                    .contains(user_id);
 | 
			
		||||
 | 
			
		||||
                if was_there {
 | 
			
		||||
                    csv.push_str(&format!("{}x", seperator));
 | 
			
		||||
                    csv.push_str(&format!("{seperator}x"));
 | 
			
		||||
                } else {
 | 
			
		||||
                    csv.push_str(seperator);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
@ -27,6 +27,7 @@ mod parser;
 | 
			
		||||
mod pm3;
 | 
			
		||||
mod tally_id;
 | 
			
		||||
mod webserver;
 | 
			
		||||
mod id_mapping;
 | 
			
		||||
 | 
			
		||||
const STORE_PATH: &str = "./data.json";
 | 
			
		||||
const PWM_CHANNEL_BUZZER: Channel = Channel::Pwm0; //PWM0 = GPIO18/Physical pin 12
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user