mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-27 08:09:58 -07:00
server: add support for .json .csv and ?all=true
This commit is contained in:
@@ -1,17 +1,19 @@
|
||||
use std::iter::Sum;
|
||||
|
||||
use crate::{Date, HeightMap};
|
||||
|
||||
use super::{AnyMap, DateMapChunkId, GenericMap, Height, MapValue, SerializedBTreeMap};
|
||||
|
||||
pub type DateMap<Value> = GenericMap<Date, Value, DateMapChunkId, SerializedBTreeMap<Date, Value>>;
|
||||
|
||||
impl<T> DateMap<T>
|
||||
impl<Value> DateMap<Value>
|
||||
where
|
||||
T: MapValue,
|
||||
Value: MapValue,
|
||||
{
|
||||
pub fn multi_insert_last(
|
||||
&mut self,
|
||||
dates: &[Date],
|
||||
source: &mut HeightMap<T>,
|
||||
source: &mut HeightMap<Value>,
|
||||
last_height: &mut DateMap<Height>,
|
||||
) {
|
||||
dates.iter().for_each(|date| {
|
||||
@@ -23,6 +25,24 @@ where
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
pub fn multi_insert_sum_range(
|
||||
&mut self,
|
||||
dates: &[Date],
|
||||
height_map: &HeightMap<Value>,
|
||||
first_height: &mut DateMap<Height>,
|
||||
last_height: &mut DateMap<Height>,
|
||||
) where
|
||||
Value: Sum,
|
||||
{
|
||||
dates.iter().for_each(|date| {
|
||||
let first_height = first_height.get_or_import(date).unwrap();
|
||||
let last_height = last_height.get_or_import(date).unwrap();
|
||||
let range = (*first_height)..=(*last_height);
|
||||
|
||||
self.insert(*date, height_map.sum_range(&range));
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub trait AnyDateMap: AnyMap {
|
||||
|
||||
Reference in New Issue
Block a user