fn update_region(region_id: RegionID,
                 client: esi::Client,
                 uni: universe::Universe,
                 mut order_store: store::Store,
                 reschedule_channel: channel::Sender<(RegionID, DateTime<Utc>)>)
                 -> thread::JoinHandle<Result<store::UpdateResult>> {
    thread::spawn(move || {
        let before_download = Instant::now();
        let orders = match download_region(region_id, client, uni, reschedule_channel) {
            Ok(result) => result,
            Err(e) => {
                warn!("Could not download region {}: {}", region_id, e);
                for e in e.iter().skip(1) {
                    warn!("caused by: {}", e);
                }
                bail!(e);
            }
        };
        let after_download = Instant::now();

        let before_store = Instant::now();
        let r = order_store.store_region(region_id, orders);
        let after_store = Instant::now();

        let dd = after_download.duration_since(before_download);
        let download_time_ms = (dd.as_secs() * 1_000) + u64::from(dd.subsec_millis());
        let sd = after_store.duration_since(before_store);
        let store_time_ms = (sd.as_secs() * 1_000) + u64::from(sd.subsec_millis());
        info!("{:8} - New: {:6}\tUpdated: {:6}\tClosed: {:6}\tUnaffected: {:6}\tAffected RegionTypes: {:6}\tDownload: {:5}ms\tStore: {:5}ms", region_id, r.new.len(), r.updated.len(), r.closed.len(), r.unaffected.len(), r.region_types.len(), download_time_ms, store_time_ms);

        Ok(r)
    })
}
/// Download and store a region's market
/// It works like this (for regions/structures):
/// Spawn thread per region -> get metadata -> spawn thread per page
Download and store a region's market
It works like this (for regions/structures):
Spawn thread per region -> get metadata -> spawn thread per page
Download and store a region ' s market It works like this ( for regions / structures ) : Spawn thread per region - > get metadata - > spawn thread per page
fn update_region(region_id: RegionID,
                 client: esi::Client,
                 uni: universe::Universe,
                 mut order_store: store::Store,
                 reschedule_channel: channel::Sender<(RegionID, DateTime<Utc>)>)
                 -> thread::JoinHandle<Result<store::UpdateResult>> {
    thread::spawn(move || {
        let before_download = Instant::now();
        let orders = match download_region(region_id, client, uni, reschedule_channel) {
            Ok(result) => result,
            Err(e) => {
                warn!("Could not download region {}: {}", region_id, e);
                for e in e.iter().skip(1) {
                    warn!("caused by: {}", e);
                }
                bail!(e);
            }
        };
        let after_download = Instant::now();
        let before_store = Instant::now();
        let r = order_store.store_region(region_id, orders);
        let after_store = Instant::now();
        let dd = after_download.duration_since(before_download);
        let download_time_ms = (dd.as_secs() * 1_000) + u64::from(dd.subsec_millis());
        let sd = after_store.duration_since(before_store);
        let store_time_ms = (sd.as_secs() * 1_000) + u64::from(sd.subsec_millis());
        info!("{:8} - New: {:6}\tUpdated: {:6}\tClosed: {:6}\tUnaffected: {:6}\tAffected RegionTypes: {:6}\tDownload: {:5}ms\tStore: {:5}ms", region_id, r.new.len(), r.updated.len(), r.closed.len(), r.unaffected.len(), r.region_types.len(), download_time_ms, store_time_ms);
        Ok(r)
    })
}
fn update_region ( region_id : RegionID , client : esi :: Client , uni : universe :: Universe , mut order_store : store :: Store , reschedule_channel : channel :: Sender < ( RegionID , DateTime < Utc > ) > ) -> thread :: JoinHandle < Result < store :: UpdateResult > > { thread :: spawn ( move | | { let before_download = Instant :: now ( ) ; let orders = match download_region ( region_id , client , uni , reschedule_channel ) { Ok ( result ) => result , Err ( e ) => { warn ! ( " " region_id e ) ; for e in e . iter ( ) . skip ( 1 ) { warn ! ( " " e ) ; } bail ! ( e ) ; } } ; let after_download = Instant :: now ( ) ; let before_store = Instant :: now ( ) ; let r = order_store . store_region ( region_id , orders ) ; let after_store = Instant :: now ( ) ; let dd = after_download . duration_since ( before_download ) ; let download_time_ms = ( dd . as_secs ( ) * 1_000 ) + u64 :: from ( dd . subsec_millis ( ) ) ; let sd = after_store . duration_since ( before_store ) ; let store_time_ms = ( sd . as_secs ( ) * 1_000 ) + u64 :: from ( sd . subsec_millis ( ) ) ; info ! ( " \t \t \t \t \t \t " region_id r new len ( ) r updated len ( ) r closed len ( ) r unaffected len ( ) r region_types len ( ) download_time_ms store_time_ms ) ; Ok ( r ) } ) }
Download and store a region's market
It works like this (for regions/structures):
Spawn thread per region -> get metadata -> spawn thread per page
Download and store a region ' s market It works like this ( for regions / structures ) : Spawn thread per region - > get metadata - > spawn thread per page
region_id
RegionID
client
esi::Client
uni
universe::Universe
order_store
store::Store
reschedule_channel
channel::Sender<(RegionID, DateTime<Utc>)>
region_id
RegionID
client
esi::Client
uni
universe::Universe
order_store
store::Store
reschedule_channel
channel::Sender<(RegionID, DateTime<Utc>)>