Integrate date_range with transforms.
[?]
CrEcTsRjb1hHQjHuumqRfqdbVV4X58iLEubi4noaDPFa
Jul 23, 2021, 5:14 AM
PK7JY27R55PZON4SPFLJBX66IAE47SXBRAGDHXM4SN6TKZXO5LMACDependencies
- [2]
PQKGZNQGAdded class field to GraphicJson. - [3]
EHEK63WACleaning up ts.rs. - [4]
XI5ALEH6Take advantage of keytree FromStr functionality. - [5]
SPSFTMLRCompleted loading ts_data from specification. - [6]
TSY4YBBZChanged ts Spec datastructures to new format. - [7]
E2T2A74YAdded class field to GraphicSpec. - [8]
5B2HBV3JCompleted first try at ts Json data-structure. - [9]
SAHJYVNBRemoved checking functionality. - [10]
2CCG6KUPRedo time-series spec. - [11]
BB2T6X3XImproved documentation. - [12]
XPXYFEZMFinished code for building TSJson struct. - [13]
GQVS55HIFinished generate_ts_spec() function. - [14]
K4CH53V4Added GPL2 license, included missing source files. - [15]
TTR5IFSGWorking on building generic TSSpec. - [16]
UUD3CJZLMaking error handling more comprehensive. - [*]
4MG5JFXTFirst record.
Change contents
- replacement in src/ts.rs at line 15
use crate::{ DataType, MonthlyDate, SeriesId, SeriesMetaData, SeriesSpec };use crate::{ DataType, DateRange, MonthlyDate, SeriesId, SeriesMetaData, SeriesSpec }; - replacement in src/ts.rs at line 65
class: GraphicClass,category: GraphicCategory, - edit in src/ts.rs at line 78
series_id: SeriesId, - edit in src/ts.rs at line 142
// if m_series.contains_key(series_id) {// println!("Duplicate series_id");// panic!()// }; - replacement in src/ts.rs at line 162
class_opt,category_opt, - replacement in src/ts.rs at line 177
let class = match class_opt {None => GraphicClass::Source,Some(GraphicClass::Cleaned) => GraphicClass::Cleaned,Some(GraphicClass::Collated) => GraphicClass::Collated,Some(GraphicClass::Source) => GraphicClass::Source,let category = match category_opt {None => GraphicCategory::Source,Some(GraphicCategory::Cleaned) => GraphicCategory::Cleaned,Some(GraphicCategory::Collated) => GraphicCategory::Collated,Some(GraphicCategory::Source) => GraphicCategory::Source, - replacement in src/ts.rs at line 187
if let GraphicClass::Source = class { graphic_spec.assert_has_one_series()? };if let GraphicCategory::Source = category {if !graphic_spec.assert_has_one_series() {return Err(expected_graphic_has_one_series(file!(),line!(),&country.to_string(),&data_type.to_string(),*index,))}}; - replacement in src/ts.rs at line 199
let text_spec = match graphic_spec.class_opt {Some(GraphicClass::Cleaned) => TextSpec::Link,Some(GraphicClass::Collated) => TextSpec::Link,Some(GraphicClass::Source) => TextSpec::Meta,let text_spec = match graphic_spec.category_opt {Some(GraphicCategory::Cleaned) => TextSpec::Link,Some(GraphicCategory::Collated) => TextSpec::Link,Some(GraphicCategory::Source) => TextSpec::Meta, - replacement in src/ts.rs at line 209
class: class,category: category, - edit in src/ts.rs at line 220
// dbg!(&series_id); - edit in src/ts.rs at line 365
series_id: series_spec.series_id.clone(), - replacement in src/ts.rs at line 461
pub enum GraphicClass {pub enum GraphicCategory { - replacement in src/ts.rs at line 472
impl FromStr for GraphicClass {impl FromStr for GraphicCategory { - replacement in src/ts.rs at line 477
"collation" => Ok(GraphicClass::Collated),"source" => Ok(GraphicClass::Source),"cleaned" => Ok(GraphicClass::Cleaned),"collation" => Ok(GraphicCategory::Collated),"source" => Ok(GraphicCategory::Source),"cleaned" => Ok(GraphicCategory::Cleaned), - replacement in src/ts.rs at line 485
impl fmt::Display for GraphicClass {impl fmt::Display for GraphicCategory { - replacement in src/ts.rs at line 488
GraphicClass::Collated => "collation",GraphicClass::Source => "source",GraphicClass::Cleaned => "cleaned",GraphicCategory::Collated => "collation",GraphicCategory::Source => "source",GraphicCategory::Cleaned => "cleaned", - replacement in src/ts.rs at line 508[3.9473]→[3.1546:1588](∅→∅),[3.1588]→[3.3497:3533](∅→∅),[3.9473]→[3.3497:3533](∅→∅),[3.3566]→[3.3566:3601](∅→∅)
pub class_opt: Option<GraphicClass>,pub title_opt: Option<String>,pub series_ids: Vec<SeriesId>,pub category_opt: Option<GraphicCategory>,pub title_opt: Option<String>,pub series_ids: Vec<SeriesId>, - replacement in src/ts.rs at line 514
pub (crate) fn assert_has_one_series(&self) -> Result<(), Error> {if self.series_ids.len() != 1 {Err(expected_graphic_has_one_series(file!(),line!(),))} else {Ok(())}pub (crate) fn assert_has_one_series(&self) -> bool {self.series_ids.len() == 1 - replacement in src/ts.rs at line 525
class_opt: self.opt_value("graphic::class")?,category_opt: self.opt_value("graphic::category")?, - replacement in src/ts.rs at line 538
if let Some(class) = &self.class_opt {if let Some(class) = &self.category_opt { - edit in src/ts.rs at line 562
DateRange(DateRange), - edit in src/ts.rs at line 585
Transform::DateRange(date_range)=> write!(f, "{}", date_range.to_string()), - replacement in src/lib.rs at line 205
GraphicClass,GraphicCategory, - replacement in src/lib.rs at line 249
#[derive(Clone, Debug)]#[derive(Clone, Copy, Debug, Serialize)] - edit in src/lib.rs at line 275
}}impl fmt::Display for DateRange {fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {let s = match (self.0.first_date(), self.0.last_date()) {(None, None) => {format!("open")},(Some(d1), None) => {format!("from {}-{}-01",d1.year(),d1.month(),)},(None, Some(d2)) => {format!("to {}-{}-01",d2.year(),d2.month())},(Some(d1), Some(d2)) => {format!("between {}-{}-01 and {}-{}-01",d1.year(),d1.month(),d2.year(),d2.month(),)},};write!(f, "{}", s) - replacement in src/lib.rs at line 523[3.4990]→[3.1781:1839](∅→∅),[3.1839]→[3.4917:4951](∅→∅),[3.4990]→[3.4917:4951](∅→∅),[3.4985]→[3.4985:5025](∅→∅)
class_opt: Some(GraphicClass::Collated),title_opt: None,series_ids: Vec::new(),category_opt: Some(GraphicCategory::Collated),title_opt: None,series_ids: Vec::new(), - edit in src/lib.rs at line 536
date_range: DateRange::new(&None, &None), - replacement in src/lib.rs at line 547[3.5840]→[3.1840:1900](∅→∅),[3.1900]→[3.5270:5308](∅→∅),[3.5840]→[3.5270:5308](∅→∅),[3.5346]→[3.5346:5416](∅→∅)
class_opt: Some(GraphicClass::Source),title_opt: None,series_ids: vec!(series_spec.series_id.clone()),category_opt: Some(GraphicCategory::Source),title_opt: None,series_ids: vec!(series_spec.series_id.clone()), - edit in src/lib.rs at line 724
pub date_range: DateRange, - replacement in src/lib.rs at line 808
let mut rts = self.read_data_without_transform(country, root_path)?;let rts = self.read_data_without_transform(country, root_path)?; - replacement in src/lib.rs at line 830
}},Transform::DateRange(range) => rts.range(&range.0), - edit in src/lib.rs at line 834
rts.with_range(&self.date_range.0); - edit in src/lib.rs at line 1151
if let Some(first_date) = self.date_range.first_date() {kt.push_value(1, "first_date", first_date);}if let Some(last_date) = self.date_range.last_date() {kt.push_value(1, "last_date", last_date);}; - edit in src/lib.rs at line 1172
let date_range = DateRange::new(&first_date, &last_date);let mut transforms: Vec<Transform> = self.vec_value("series::transforms")?;if first_date.is_some() || last_date.is_some() {transforms.push(Transform::DateRange(date_range));} - replacement in src/lib.rs at line 1185
date_range: DateRange::new(&first_date, &last_date),transforms: self.vec_value("series::transforms")?,transforms: transforms, - edit in src/fred.rs at line 17
DateRange, - edit in src/fred.rs at line 116
date_range: DateRange::new(&None, &None), - edit in src/fred.rs at line 169
date_range: DateRange::new(&None, &None), - replacement in src/error.rs at line 31
code_line: u32) -> Errorcode_line: u32,country: &str,data_type: &str,index: usize) -> Error - replacement in src/error.rs at line 37
"[ui_date:02:{}:{}] Expected source graphic to have exactly one series.","[ui_date:02:{}:{}] [{} {} {}] Expected source graphic to have exactly one series.", - edit in src/error.rs at line 40
country,data_type,index,