Working on building generic TSSpec.

[?]
Jul 6, 2021, 2:29 AM
TTR5IFSG25VNBQ2F2FNOLUMTEIHVBHFOEXYB2ZWEHWOURUV4GJMQC

Dependencies

  • [2] XI5ALEH6 Take advantage of keytree FromStr functionality.
  • [3] IKPVWWLK Filter unemployment rate series.
  • [4] GQVS55HI Finished generate_ts_spec() function.
  • [5] 5POF332L Working on fn cpi_included().
  • [6] 77SIQZ3E Separating out spec generation.
  • [7] 2SABVMY3 Finished into_json() functionality.
  • [8] AT753JPO Selected US unemployment series.
  • [9] GUXZCEWW Added Country enum.
  • [10] U4VCAFXQ Added data_type to TSSpec key.
  • [11] CUADTSHQ Save csv data as multiple files.
  • [12] AIFRDCG2 Split off countries mod into a separate crate.
  • [13] 4MG5JFXT First record.
  • [14] 4QOTH75I Fixed UI specification code.
  • [15] UCSU3QE4 Created keytree generator for u and cpi.
  • [16] LVMGQJGH Finished framework for checking series specifications with data.

Change contents

  • edit in src/serve_ui.rs at line 3
    [3.105]
    [3.105]
    use std::collections::HashMap;
  • edit in src/serve_ui.rs at line 10
    [3.244]
    [3.347]
    };
    use time_series::{
    RegularTimeSeries,
  • edit in src/serve_ui.rs at line 19
    [2.31]
    [3.426]
    };
    use crate::check_data::{
    IndexedCheckedDataSpec,
  • edit in src/serve_ui.rs at line 27
    [2.140]
    [2.140]
    /// The top-level datastructure, served as JSON, that specifies all the data required to build a UI
    /// plot.
    pub struct UIJson(HashMap<(Country, usize), UIGraphicJson>);
  • replacement in src/serve_ui.rs at line 32
    [2.141][2.141:199]()
    // pub struct UIJson(HashMap<(Country Index),Vec<Graphic>
    [2.141]
    [2.199]
    impl UIJson {
  • replacement in src/serve_ui.rs at line 34
    [2.200][2.200:234]()
    // Do we want meta for each line?
    [2.200]
    [2.234]
    /// Create an empty `UIJson`.
    pub fn new() -> Self {
    UIJson(HashMap::new())
    }
    /// Insert a `UIGraphicJson` into `UIJson`. If the country already exists, increment the index
    /// in the key until a space is available.
    pub fn insert(&mut self, ui_graphic_json: UIGraphicJson) {
    let mut ix = 0;
    while self.0.get(&(ui_graphic_json.country, 0)).is_none() {
    ix += 1;
    }
    self.0.insert((ui_graphic_json.country, ix), ui_graphic_json);
    }
    }
    /// A UI plot. `UIGraphicJson` can be serialized to JSON.
    pub struct UIGraphicJson {
    country: Country,
    title: String,
    lines: Vec<UILineJson>,
    }
  • edit in src/serve_ui.rs at line 57
    [2.235]
    [2.235]
    /// A line in a UI plot. `UILineJson` can be serialized to JSON.
    pub struct UILineJson {
    data: RegularTimeSeries<2>,
    }
  • replacement in src/serve_ui.rs at line 66
    [3.491][3.491:758]()
    /// ui_graphic:
    /// time_series:
    /// data_type: u
    /// series: AUSURAMS_a
    /// transform: ident
    /// time_series:
    /// data_type: i
    /// series: _
    /// transform: ident
    [3.491]
    [3.758]
    /// country: Australia
    /// index: 0
    ///
    /// time_series:
    /// data_type: u
    /// series: AUSURAMS_a
    /// time_series:
    /// data_type: i
    /// series: _
    /// line:
  • edit in src/serve_ui.rs at line 78
    [3.810]
    [3.810]
    /// transform: indent
  • edit in src/serve_ui.rs at line 81
    [3.112]
    [3.879]
    impl UISpec {
    // Convert UISpec into UIJson.
    pub (crate) fn into_json(
    &self,
    data_spec: &IndexedCheckedDataSpec,
    root_path: &str) -> Result<UIJson, Error>
    {
    let mut ui_json = UIJson::new();
    for ui_graphic_spec in &self.0 {
    let ui_graphic_json = ui_graphic_spec.into_json(
    data_spec,
    root_path,
    )?;
    ui_json.insert(ui_graphic_json);
    }
    Ok(ui_json)
    }
    }
  • edit in src/serve_ui.rs at line 142
    [3.1304]
    [3.908]
    impl UIGraphicSpec {
    pub (crate) fn into_json(
    &self,
    data_spec: &IndexedCheckedDataSpec,
    root_path: &str) -> Result<UIGraphicJson, Error>
    {
    let mut v = Vec::new();
    for line_spec in &self.line {
    let x_time_series_spec = &self.time_series[line_spec.x];
    let y_time_series_spec = &self.time_series[line_spec.y];
    let line_json = line_spec.into_json(
    data_spec,
    x_time_series_spec,
    y_time_series_spec,
    root_path,
    ).unwrap();
    v.push(line_json);
    }
    Ok(
    UIGraphicJson {
    country: self.country,
    title: self.title.clone(),
    lines: v,
    }
    )
    }
    }
  • replacement in src/serve_ui.rs at line 200
    [3.2774][2.720:754]()
    x: SeriesId,
    y: SeriesId,
    [3.2774]
    [3.2804]
    x: usize,
    y: usize,
  • replacement in src/serve_ui.rs at line 203
    [3.2841][3.2841:2876]()
    end_date: Option<MonthlyDate>,
    [3.2841]
    [3.2876]
    end_date: Option<MonthlyDate>,
    transform2: Transform2,
    }
    impl UILineSpec {
    pub (crate) fn into_json(
    &self,
    data: &IndexedCheckedDataSpec,
    x: &UITimeSeriesSpec,
    y: &UITimeSeriesSpec,
    root_path: &str) -> Result<UILineJson, Error>
    {
    x.assert_data_type(DataType::U)?;
    y.assert_data_type(DataType::Inf)?;
    let x_data = x.time_series_data(data, root_path)?;
    let y_data = y.time_series_data(data, root_path)?;
    let range = MonthlyDate::range(&self.start_date, &self.end_date);
    let xy_data = match self.transform2 {
    Transform2::Zip => {
    let mut xy_data = x_data.zip_one_one(y_data);
    xy_data.with_range(&range);
    xy_data
    }
    };
    Ok(
    UILineJson {
    data: xy_data,
    }
    )
    }
  • replacement in src/serve_ui.rs at line 245
    [3.3481][2.755:967]()
    x: self.value("line::x")?,
    y: self.value("line::y")?,
    start_date: self.opt_value("line::start_date")?,
    end_date: self.opt_value("line::end_date")?,
    [3.3481]
    [3.3645]
    x: self.value("line::x")?,
    y: self.value("line::y")?,
    start_date: self.opt_value("line::start_date")?,
    end_date: self.opt_value("line::end_date")?,
    transform2: self.value("line::transform2")?,
  • replacement in src/serve_ui.rs at line 255
    [3.3678][3.1847:1930]()
    /// `Transform`s may include joining data, interpolation etc.
    pub enum Transform {
    [3.3678]
    [3.1930]
    /// Transforms from a TimeSeries<1> to another TimeSeries<1>.
    pub enum Transform1 {
  • replacement in src/serve_ui.rs at line 261
    [3.4134][3.1956:1985]()
    impl FromStr for Transform {
    [3.4134]
    [3.1985]
    impl FromStr for Transform1 {
  • replacement in src/serve_ui.rs at line 266
    [3.2080][3.2080:2125](),[3.2125][2.968:1010]()
    "ident" => Ok(Transform::Ident),
    _ => Err(parse_transform(s)),
    [3.2080]
    [3.4843]
    "ident" => Ok(Transform1::Ident),
    _ => Err(parse_transform1(s)),
    }
    }
    }
    /// Transforms from two TimeSeries<1> to a TimeSeries<2>.
    pub enum Transform2 {
    ///
    Zip,
    }
    impl FromStr for Transform2 {
    type Err = Error;
    fn from_str(s: &str) -> Result<Self, Self::Err> {
    match s {
    "zip" => Ok(Transform2::Zip),
    _ => Err(parse_transform2(s)),
  • edit in src/serve_ui.rs at line 296
    [3.2340][3.2340:2414]()
    start_date: Option<MonthlyDate>,
    end_date: Option<MonthlyDate>,
  • replacement in src/serve_ui.rs at line 297
    [3.2440][3.2440:2491]()
    series: String,
    transform: Transform,
    [3.2440]
    [3.5415]
    series_id: SeriesId,
    transform1: Transform1,
    }
    impl UITimeSeriesSpec {
    pub (crate) fn assert_data_type(&self, data_type: DataType) -> Result<(), Error> {
    if self.data_type == data_type {
    Ok(())
    } else {
    Err(data_type_mismatch(&self.data_type.to_string(), &data_type.to_string()))
    }
    }
    pub (crate) fn time_series_data(
    &self,
    data: &IndexedCheckedDataSpec,
    root_path: &str) -> Result<RegularTimeSeries<1>, Error>
    {
    data.time_series_data(
    self.series_id.clone(),
    root_path
    )
    }
  • edit in src/serve_ui.rs at line 327
    [3.2570][3.2570:2596]()
    /// transform: ident
  • replacement in src/serve_ui.rs at line 335
    [2.1078][2.1078:1351]()
    start_date: self.opt_value("time_series::start_date")?,
    end_date: self.opt_value("time_series::end_date")?,
    series: self.value("time_series::series")?,
    transform: self.value("time_series::transform")?,
    [2.1078]
    [3.7070]
    series_id: self.value("time_series::series")?,
    transform1: self.value("time_series::transform1")?,
  • replacement in src/serve_ts.rs at line 19
    [3.7908][3.7908:7929]()
    use crate::DataType;
    [3.7908]
    [3.47]
    use crate::{
    DataType,
    SeriesId,
    };
  • replacement in src/serve_ts.rs at line 60
    [3.788][3.312:363]()
    pub (crate) fn from_file(path: &str) -> Self {
    [3.788]
    [3.831]
    /// Read from file.
    pub fn from_file(path: &str) -> Self {
  • edit in src/serve_ts.rs at line 88
    [3.1002]
    [3.1002]
  • replacement in src/serve_ts.rs at line 157
    [3.1426][3.1426:1438]()
    /// ```text
    [3.1426]
    [3.1438]
    /// ```
  • replacement in src/serve_ts.rs at line 159
    [3.1448][3.1448:1691]()
    /// country:
    /// name: Australia
    /// graphic:
    /// series:
    /// id: AUSURANAA
    /// id: AUSURAQS
    /// id: AUSURHARMADSMEI
    /// id: AUSURHARMMDSMEI
    [3.1448]
    [3.1691]
    /// country: Australia
    /// index: 0
    /// graphic:
    /// series:
    /// series_id: AUSURANAA
    /// data_type: u
    /// series:
    /// data_type: u
    /// series_id: AUSURAQS
    /// series:
    /// data_type: u
    /// series_id: AUSURHARMADSMEI
    /// series:
    /// data_type: u
    /// series_id: AUSURHARMMDSMEI
  • replacement in src/serve_ts.rs at line 179
    [3.2264][3.1752:1782](),[3.1752][3.1752:1782]()
    pub data_type: DataType,
    [3.2264]
    [3.2265]
    pub index: usize,
  • replacement in src/serve_ts.rs at line 189
    [3.2390][3.2390:2429]()
    data_type: key.data_type,
    [3.2390]
    [3.2429]
    index: key.index,
  • edit in src/serve_ts.rs at line 194
    [3.1965]
    [3.2464]
    pub (crate) fn push(&mut self, ts_graphic_spec: TSGraphicSpec) {
    self.graphics.push(ts_graphic_spec)
    }
  • replacement in src/serve_ts.rs at line 201
    [3.2546][3.2546:2586]()
    data_type: self.data_type,
    [3.2546]
    [3.2092]
    index: self.index,
  • edit in src/serve_ts.rs at line 213
    [3.2243][3.2243:2314]()
    kt.push_keyvalue(1, "data_type", &self.data_type.to_string());
  • replacement in src/serve_ts.rs at line 225
    [3.2648][2.1946:2120]()
    country: self.value("country::country")?,
    data_type: self.value("country::data_type")?,
    graphics: self.vec_at("country::graphic")?,
    [3.2648]
    [3.9841]
    country: self.value("page::country")?,
    index: self.value("page::index")?,
    graphics: self.vec_at("page::graphic")?,
  • replacement in src/serve_ts.rs at line 233
    [3.2708][3.2708:2712]()
    ///
    [3.2708]
    [3.9937]
    /// ```
    /// graphic:
    /// series:
    /// series_id: AUSURANAA
    /// data_type: u
    /// series:
    /// data_type: u
    /// series_id: AUSURAQS
    /// series:
    /// data_type: u
    /// series_id: AUSURHARMADSMEI
    /// series:
    /// data_type: u
    /// series_id: AUSURHARMMDSMEI
    /// ```
  • replacement in src/serve_ts.rs at line 254
    [3.2794][3.10026:10060](),[3.10026][3.10026:10060]()
    pub series_ids: Vec<String>,
    [3.2794]
    [3.10060]
    pub series: Vec<TSSeriesSpec>,
  • replacement in src/serve_ts.rs at line 262
    [3.10161][3.10161:10197]()
    series_ids: Vec::new(),
    [3.10161]
    [3.10197]
    series: Vec::new(),
  • replacement in src/serve_ts.rs at line 266
    [3.10214][3.2832:2879](),[3.2879][3.10253:10298](),[3.10253][3.10253:10298]()
    pub (crate) fn push(&mut self, id: &str) {
    self.series_ids.push(id.to_string())
    [3.10214]
    [3.2880]
    pub (crate) fn push(&mut self, series: TSSeriesSpec) {
    self.series.push(series)
  • replacement in src/serve_ts.rs at line 278
    [3.3095][3.3095:3139]()
    for series_id in &self.series_ids {
    [3.3095]
    [3.3139]
    for series in &self.series {
  • replacement in src/serve_ts.rs at line 280
    [3.3140][3.3140:3220]()
    let ts = data_spec.time_series_data(series_id.clone(), root_path)?;
    [3.3140]
    [3.3220]
    let ts = data_spec.time_series_data(series.series_id.clone(), root_path)?;
  • replacement in src/serve_ts.rs at line 282
    [3.3221][3.3221:3294]()
    let meta = data_spec.meta(series_id.to_string(), root_path);
    [3.3221]
    [3.3294]
    let meta = data_spec.meta(&series.series_id, root_path);
  • replacement in src/serve_ts.rs at line 305
    [3.10617][3.10617:10698]()
    for id in &self.series_ids {
    kt.push_keyvalue(2, "id", &id);
    [3.10617]
    [3.10698]
    for series in &self.series {
    kt.push_keytree(2, series.keytree());
  • replacement in src/serve_ts.rs at line 319
    [2.2181][2.2181:2243]()
    series_ids: self.vec_value("graphic::data")?,
    [2.2181]
    [3.11011]
    series: self.vec_at("graphic::series")?,
    }
    )
    }
    }
    /// Component of `TSGraphicSpec`.
    /// ```text
    /// series:
    /// data_type: u
    /// series_id: AUSURHARMADSMEI
    /// ```
    pub struct TSSeriesSpec {
    ///
    data_type: DataType,
    series_id: SeriesId,
    }
    impl TSSeriesSpec {
    /// Return a new `TSSeries`.
    pub fn new(data_type: DataType, series_id: SeriesId) -> Self {
    TSSeriesSpec {
    data_type,
    series_id,
    }
    }
    }
    impl<'a> TryInto<TSSeriesSpec> for KeyTreeRef<'a> {
    type Error = keytree::Error;
    fn try_into(self) -> Result<TSSeriesSpec, Self::Error> {
    Ok(
    TSSeriesSpec {
    data_type: self.value("series::data_type")?,
    series_id: self.value("series::series_id")?,
  • edit in src/serve_ts.rs at line 360
    [3.11044]
    [3.11044]
    impl IntoKeyTree for TSSeriesSpec {
    fn keytree(&self) -> KeyTreeString {
    let mut kt = KeyTreeString::new();
    kt.push_key(0, "series");
    kt.push_keyvalue(1, "data_type", &self.data_type.to_string());
    kt.push_keyvalue(1, "series_id", &self.series_id.to_string());
    kt
    }
    }
  • replacement in src/serve_ts.rs at line 377
    [3.11319][3.3581:3636]()
    pub struct TSJson(HashMap<PageKey, Vec<GraphicJson>>);
    [3.11319]
    [3.2822]
    #[derive(Debug)]
    pub struct TSJson(pub HashMap<PageKey, String>);
  • replacement in src/serve_ts.rs at line 392
    [3.3980][3.3980:4033]()
    None => { self.0.insert(*key, value); },
    [3.3980]
    [3.4033]
    None => {
    self.0.insert(
    *key,
    serde_json::to_string(&value).unwrap(),
    );
    },
  • replacement in src/serve_ts.rs at line 403
    [3.11439][3.11439:11460]()
    #[derive(Serialize)]
    [3.11439]
    [3.11460]
    #[derive(Debug, Serialize)]
  • replacement in src/serve_ts.rs at line 412
    [3.11615][3.11615:11636]()
    #[derive(Serialize)]
    [3.11615]
    [3.4062]
    #[derive(Debug, Serialize)]
  • replacement in src/serve_ts.rs at line 431
    [3.4507][3.11837:11866](),[3.11837][3.11837:11866]()
    pub data_type: DataType,
    [3.4507]
    [3.4508]
    pub country: Country,
  • replacement in src/serve_ts.rs at line 433
    [3.4516][3.11866:11892](),[3.11866][3.11866:11892]()
    pub country: Country,
    [3.4516]
    [3.11892]
    pub index: usize,
    }
    impl PageKey {
    /// Return a new `PageKey`.
    pub fn new(country: Country, index: usize) -> Self {
    PageKey { country, index }
    }
  • replacement in src/serve_ts.rs at line 448
    [3.12374][2.2244:2299]()
    data_type: self.value("key::data_type")?,
    [3.12374]
    [2.2299]
    index: self.value("key::index")?,
  • replacement in src/main.rs at line 1
    [3.10][3.12460:12506]()
    // use std::convert::TryInto;
    // use std::fs;
    [3.10]
    [3.11575]
    use std::convert::TryInto;
    use std::fs;
  • replacement in src/main.rs at line 4
    [3.11576][3.12507:12530](),[3.12530][3.2947:2987]()
    // use fred_api::Fred;
    // use keytree::serialize::IntoKeyTree;
    [3.11576]
    [3.0]
    use countries::Country;
    use fred_api::Fred;
    use keytree::serialize::IntoKeyTree;
  • replacement in src/main.rs at line 8
    [3.1][3.12531:12577]()
    // use countries::Country;
    // use ui_data::*;
    [3.1]
    [3.12577]
    use ui_data::*;
  • replacement in src/main.rs at line 10
    [3.12605][3.2988:3017]()
    // use ui_data::serve_ts::*;
    [3.12605]
    [3.110]
    use ui_data::check_data::*;
    use ui_data::serve_ts::*;
    use ui_data::serve_ui::*;
  • replacement in src/main.rs at line 15
    [3.127][3.9571:9632]()
    // let root_dir = shellexpand::tilde("~/test_data/cpi");
    [3.127]
    [3.9632]
    let root_dir = shellexpand::tilde("~/test_data");
  • replacement in src/main.rs at line 17
    [3.9637][3.9637:10087]()
    // // "usa;interest",
    // // "prime",
    // // "australia;interest" -> nothing
    // for item in Fred::tags_series("australia;interest")
    // .unwrap()
    // .series()
    // .iter()
    // {
    // println!("{}", item);
    // // println!("{}", item.tags());
    // }
    // let spec_path = shellexpand::tilde("~/currency.engineering/source_spec.keytree");
    // let data_path = shellexpand::tilde("~/test_data");
    [3.9637]
    [3.10087]
    // Read in the data specification.
    let data_spec = CheckedDataSpec::from_file("checked_data.keytree").into_indexed();
    let ts_spec = TSSpec::from_file("ts_spec.keytree");
  • replacement in src/main.rs at line 21
    [3.10088][3.10088:10145](),[3.10145][3.11651:11765](),[3.11765][3.12632:12755](),[3.12755][3.11801:11802](),[3.11801][3.11801:11802](),[3.11802][3.3018:3051]()
    // spec_to_data::save_data(&spec_path, &data_path);
    // println!("{}", build_data_spec().keytree());
    let spec = DataSpec::from_file("source_data.keytree");
    let mut checked = spec.check();
    checked.write("/home/dyppb/test_data");
    // let ts_data = SourceData::new();
    checked.bootstrap_ts_spec();
    [3.10088]
    [3.292]
    let ts_json = ts_spec.into_json(&data_spec, &root_dir);
  • replacement in src/lib.rs at line 3
    [3.4835][3.10187:10269](),[3.16][3.10187:10269]()
    //! Collect unemployment rate, inflation rate and interest rate data server side.
    [3.4835]
    [3.10269]
    //! Collect unemployment rate, inflation rate and interest rate data server side, then serve this
    //! data as JSON in a format suitable for building UI graphics using D3.
  • replacement in src/lib.rs at line 6
    [3.10274][3.12789:12816]()
    //! ### Step 1. Build Spec
    [3.10274]
    [3.11914]
    //! ## Step 1. Find the data of Fred and build a spec for it.
  • replacement in src/lib.rs at line 22
    [3.12120][3.12817:12844]()
    //! ### Step 2. Check Data
    [3.12120]
    [3.12174]
    //! ## Step 2. Build a generic data specification.
  • replacement in src/lib.rs at line 33
    [3.12570][3.12570:12621]()
    //! println!("{}", build_data_spec().keytree());
    [3.12570]
    [3.12621]
    //! println!("{}", build_generic_data_spec().keytree());
  • replacement in src/lib.rs at line 64
    [3.5474][3.5474:5510]()
    //! ### Step 2. Check and Save Data
    [3.5474]
    [3.12789]
    //! ## Step 3. Check the data in the data specification.
  • replacement in src/lib.rs at line 88
    [3.6126][3.12881:12975](),[3.12881][3.12881:12975]()
    //! Check each data series, to see if the data is well-formed. Save the output specification.
    [3.6126]
    [3.12873]
    //! Check each data series, to see if the data is well-formed.
    //! ```
    //! let spec = DataSpec::from_file("source_data.keytree");
    //! println!("{}", spec.check().keytree());
    //! ```
    //! Save the output specification in `checked_data.keytree`.
  • replacement in src/lib.rs at line 95
    [3.12877][3.6127:6167]()
    //! ### Step 3*. Bootstrap TSPageSpec.
    [3.12877]
    [3.12975]
    //! ## Step 4. Use the data specification to write data to file.
  • edit in src/lib.rs at line 97
    [3.12979][3.6168:6221]()
    //! To generate a generic time-series specification,
  • replacement in src/lib.rs at line 98
    [3.6229][3.6229:6375]()
    //! checked_data_spec
    //! .from_file("data_spec.keytree")
    //! .bootstrap_ts_spec;
    //! ```
    //! The specification will look something like
    [3.6229]
    [3.6375]
    //! let checked = CheckedDataSpec::from_file("checked_data.keytree");
    //! checked.write("/full/path/to/data");
    //! ```
    //!
    //! If there is a break in the connection we can use
  • replacement in src/lib.rs at line 104
    [3.6383][3.6383:6636]()
    //! page:
    //! country:
    //! name: Australia
    //! graphic:
    //! series:
    //! id: AUSURANAA
    //! id: AUSURAQS
    //! id: AUSURHARMADSMEI
    //! id: AUSURHARMMDSMEI
    [3.6383]
    [3.6636]
    //! checked.resume_write(Series::new("GBRURNAA"), "/full/path/to/data")
    //! ```
    //! to resume.
    //!
    //! ## Step 5. Generate a generic time-series graphics specification.
    //!
    //! This is used to generate time-series plots. Once it is generated in full, then it can be edited
    //! manually.
    //!
    //! ```text
    //! checked.generic_ts_spec()
  • edit in src/lib.rs at line 116
    [3.6644][3.6644:6742]()
    //! Once it has been generated with the full set of data, we want to be able to edit it manually.
  • replacement in src/lib.rs at line 117
    [3.6746][3.6746:6780]()
    //! ### Step 3. Serve Time-series
    [3.6746]
    [3.6780]
    //! ## Step 6. Serve Time-series
  • replacement in src/lib.rs at line 124
    [3.13021][3.7090:7191]()
    //! The procedure is generally to read in the specification in `ts_spec.keytree`, and to read in the
    [3.13021]
    [3.7191]
    //! The procedure is generally to read in the specification in `ts_spec.keytree`.
  • edit in src/lib.rs at line 127
    [3.7297]
    [3.7297]
    //!
  • replacement in src/lib.rs at line 129
    [3.7305][3.7305:7469]()
    //! // Read in the data specification.
    //! let data_spec = CheckedData::from_file("data_spec.keytree").indexed();
    //!
    //! // Read in the time-series specification.
    [3.7305]
    [3.7469]
    //! let data_spec = CheckedDataSpec::from_file("checked_data.keytree").into_indexed();
  • edit in src/lib.rs at line 131
    [3.7525]
    [3.7525]
    //! ```
    //!
    //! Take both specifications and load data from "/full/path/to/data".
  • replacement in src/lib.rs at line 135
    [3.7529][3.7529:7687]()
    //! // Load all data to memory. The server uses `ts_json` as a data-store to respond to data
    //! // requests.
    //! let ts_json = ts_spec.into_json(data_spec);
    [3.7529]
    [3.7687]
    //! ```
    //! let ts_json = ts_spec.into_json(data_spec, "/full/path/to/data");
  • replacement in src/lib.rs at line 145
    [3.13094][3.13169:13207]()
    //! ### Step 5. Serve UI Scatterplots
    [3.13094]
    [3.13133]
    //! ## Step 7. Serve UI Scatterplots
  • edit in src/lib.rs at line 174
    [2.2538]
    [2.2538]
    impl MonthlyDate {
    /// Create a time_series::DateRange.
    pub fn range(
    date_opt1: &Option<MonthlyDate>,
    date_opt2: &Option<MonthlyDate>) -> time_series::DateRange
    {
    time_series::DateRange::new(
    date_opt1.as_ref().map(|date| date.0),
    date_opt2.as_ref().map(|date| date.0),
    )
    }
    }
  • edit in src/lib.rs at line 200
    [2.2902]
    [2.2902]
    #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize)]
  • edit in src/lib.rs at line 202
    [2.2931]
    [2.2931]
    impl SeriesId {
  • edit in src/lib.rs at line 205
    [2.2932]
    [2.2932]
    /// Create a new SeriesId from a string.
    pub fn new(s: &str) -> Self {
    SeriesId(s.to_string())
    }
    }
  • edit in src/lib.rs at line 219
    [3.1795]
    [3.10809]
    impl fmt::Display for SeriesId {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
    write!(f, "{}", self.0)
    }
    }
  • replacement in src/lib.rs at line 226
    [3.10867][3.7837:7899]()
    #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize)]
    [3.10867]
    [3.10922]
    #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
  • edit in src/lib.rs at line 238
    [3.3393][2.3074:3075]()
  • replacement in src/lib.rs at line 269
    [3.17081][3.5199:5241](),[3.5199][3.5199:5241]()
    pub fn title(series_id: &str) -> String {
    [3.17081]
    [3.5241]
    pub fn title(series_id: &SeriesId) -> String {
  • replacement in src/lib.rs at line 271
    [3.5272][3.17082:17132]()
    let seriess = match Fred::series(series_id) {
    [3.5272]
    [3.17132]
    let seriess = match Fred::series(&series_id.to_string()) {
  • replacement in src/check_data.rs at line 1
    [3.13227][3.13269:13300]()
    use std::collections::HashMap;
    [3.13227]
    [3.13228]
    use std::collections::{
    BTreeMap,
    HashMap,
    };
  • replacement in src/check_data.rs at line 26
    [3.13484][3.13484:13505]()
    use crate::DataType;
    [3.13444]
    [3.8061]
    use crate::{
    DataType,
    SeriesId,
    };
  • edit in src/check_data.rs at line 38
    [3.13488]
    [3.3066]
    TSSeriesSpec,
  • replacement in src/check_data.rs at line 48
    [3.13529][3.13659:13753](),[3.13659][3.13659:13753]()
    println!("{}", series_spec.id);
    match Fred::series(&series_spec.id) {
    [3.13529]
    [3.13530]
    println!("{}", series_spec.series_id);
    match Fred::series(&series_spec.series_id.to_string()) {
  • replacement in src/check_data.rs at line 52
    [3.13848][3.13848:14061]()
    data_type: series_spec.data_type,
    country: series_spec.country,
    id: series_spec.id.clone(),
    error: "ok".to_string(),
    [3.13848]
    [3.13558]
    data_type: series_spec.data_type,
    country: series_spec.country,
    series_id: series_spec.series_id.clone(),
    error: "ok".to_string(),
  • replacement in src/check_data.rs at line 62
    [3.14248][3.14248:14460]()
    data_type: series_spec.data_type,
    country: series_spec.country,
    id: series_spec.id.clone(),
    error: err.to_string(),
    [3.14248]
    [3.13601]
    data_type: series_spec.data_type,
    country: series_spec.country,
    series_id: series_spec.series_id.clone(),
    error: err.to_string(),
  • replacement in src/check_data.rs at line 81
    [3.8482][3.8482:8518]()
    index: HashMap<String, usize>,
    [3.8482]
    [3.8518]
    index: HashMap<SeriesId, usize>,
  • edit in src/check_data.rs at line 85
    [3.8551]
    [3.8551]
    /// Get data_type and country of a given series_id.
    pub (crate) fn get(&self, series_id: SeriesId) -> (DataType, Country) {
    let index = self.index.get(&series_id).unwrap();
    let data_type = self.data.0[*index].data_type;
    let country = self.data.0[*index].country;
    (data_type, country)
    }
    /// Return a generic time-series graphics specification.
    ///
    /// ```text
    /// ts_spec:
    /// page:
    /// country: Australia
    /// index: 0
    /// graphic:
    /// series:
    /// series_id: AUSURANAA
    /// data_type: u
    /// series:
    /// data_type: u
    /// series_id: AUSURAQS
    /// series:
    /// data_type: u
    /// series_id: AUSURHARMADSMEI
    /// series:
    /// data_type: u
    /// series_id: AUSURHARMMDSMEI
    /// ```
    /// TSSpec
    /// TSPageSpec
    /// country
    /// index
    /// TSGraphicSpec
    /// height
    /// TSSeriesSpec
    ///
    /// IndexedCheckedDataSpec
    /// CheckedDataSpec
    /// CheckedSourceSeries
    /// DataType
    /// Country
    /// SeriesId
    ///
    pub fn generic_ts_spec(&self) -> TSSpec {
    let mut map: BTreeMap<(DataType, Country), Vec<SeriesId>> = BTreeMap::new();
    for (series_id, _) in self.index.iter() {
    let (data_type, country) = self.get(series_id.clone());
    match map.get_mut(&(data_type, country)) {
    Some(value) => value.push(series_id.clone()),
    None => {
    map.insert((data_type, country), vec!(series_id.clone()));
    },
    };
    }
    // build TSSpec
    let ts_spec = TSSpec::new();
    for ((data_type, country), series_ids) in map {
    let mut ts_spec = TSSpec::new();
    let mut ts_graphic_spec = TSGraphicSpec::new();
    for series_id in series_ids {
    let ts_series_spec = TSSeriesSpec::new(data_type, series_id);
    ts_graphic_spec.push(ts_series_spec);
    };
  • edit in src/check_data.rs at line 158
    [3.8552]
    [3.8552]
    let page_key = PageKey::new(country, 0);
    let mut ts_page_spec = TSPageSpec::new(page_key, vec!(ts_graphic_spec));
    ts_spec.push(ts_page_spec);
    };
    ts_spec
    }
  • replacement in src/check_data.rs at line 168
    [3.8649][3.8649:8676]()
    series_id: String,
    [3.8649]
    [3.8676]
    series_id: SeriesId,
  • replacement in src/check_data.rs at line 175
    [3.8847][3.8847:8941]()
    println!("Series {} not found in IndexedCheckedDataSpec::index.", series_id);
    [3.8847]
    [3.8941]
    println!("Series {} not found in IndexedCheckedDataSpec::index.", series_id.to_string());
  • replacement in src/check_data.rs at line 184
    [2.3465][2.3465:3546]()
    spec_has_error_status(&series_id, &checked_series.error.clone())
    [2.3465]
    [2.3546]
    spec_has_error_status(&series_id.to_string(), &checked_series.error.clone())
  • replacement in src/check_data.rs at line 192
    [3.9366][3.9366:9402]()
    checked_series.country,
    [3.9366]
    [3.9402]
    checked_series.country.as_path(),
  • replacement in src/check_data.rs at line 198
    [3.9505][2.3561:3644]()
    .map_err(|_| time_series_not_regular(&checked_series.id.clone()))?
    [3.9505]
    [3.9637]
    .map_err(|_| time_series_not_regular(&checked_series.series_id.to_string()))?
  • replacement in src/check_data.rs at line 203
    [3.9700][3.9700:9779]()
    pub fn meta(&self, series_id: String, root_path: &str) -> SeriesMetaData {
    [3.9700]
    [3.9779]
    pub fn meta(&self, series_id: &SeriesId, root_path: &str) -> SeriesMetaData {
  • replacement in src/check_data.rs at line 216
    [3.10118][3.10118:10149]()
    "{}/{}/{}/{}.csv",
    [3.10118]
    [3.10149]
    "{}/{}/{}/{}.meta",
  • replacement in src/check_data.rs at line 219
    [3.10210][3.10210:10246]()
    checked_series.country,
    [3.10210]
    [3.10246]
    checked_series.country.as_path(),
  • edit in src/check_data.rs at line 239
    [3.14803][3.10433:10434]()
  • edit in src/check_data.rs at line 249
    [3.15050]
    [3.15059]
    // We need to change the arrangement. We update the checked_data.keytree from files. We have a
    // resume function which takes the same checked_data.keytree and writes from a SeriesId. We have
    // another function with goes through the files to update the time-stamp.
  • replacement in src/check_data.rs at line 257
    [3.13873][3.13873:13915]()
    /// save_data_csv("LRUNTTTTSIQ156S");
    [3.13873]
    [3.13915]
    /// let mut checked = CheckedDataSpec::from_file("checked_data.keytree");
    /// checked.write(&root_dir);
  • replacement in src/check_data.rs at line 262
    [3.14010][3.14010:14057]()
    pub fn write(&mut self, root_path: &str) {
    [3.14010]
    [3.14057]
    pub fn write(&self, root_path: &str) {
    for series in &self.0 {
    series.write_data(root_path);
    series.write_meta(root_path);
    }
    }
    /// Same as `write()` except that it starts in the specification at `series_id`. Useful if there
    /// is a break in the connection when writing.
    pub fn resume_write(&self, series_id: SeriesId, root_path: &str) {
  • replacement in src/check_data.rs at line 274
    [3.14058][3.14058:14094]()
    for series in &mut self.0 {
    [3.14058]
    [3.14094]
    for series in self.0.iter().skip_while( | checked |{
    checked.series_id != series_id
    })
    {
  • edit in src/check_data.rs at line 281
    [3.14189][3.14189:14230]()
    println!("{}", self.keytree())
  • replacement in src/check_data.rs at line 285
    [3.10658][3.10658:10718]()
    let mut h: HashMap<String, usize> = HashMap::new();
    [3.10658]
    [3.10718]
    let mut h: HashMap<SeriesId, usize> = HashMap::new();
  • replacement in src/check_data.rs at line 287
    [3.10773][3.10773:10817]()
    h.insert(series.id.clone(), i);
    [3.10773]
    [3.10817]
    h.insert(series.series_id.clone(), i);
  • edit in src/check_data.rs at line 294
    [3.14236][3.14236:14348](),[3.14348][3.3079:3117](),[3.3117][3.14385:14386](),[3.14385][3.14385:14386](),[3.14386][3.3118:3184](),[3.3184][3.14455:14456](),[3.14455][3.14455:14456](),[3.14456][3.15183:15215](),[3.15183][3.15183:15215](),[3.15215][3.14457:14665](),[3.14665][3.15382:15397](),[3.15382][3.15382:15397](),[3.15397][3.14666:14725](),[3.14725][3.3185:3327](),[3.3327][3.14875:15042](),[3.14875][3.14875:15042](),[3.15042][3.3328:3480](),[3.3480][3.15207:15241](),[3.15207][3.15207:15241](),[3.15241][3.15397:15407](),[3.15397][3.15397:15407](),[3.15407][3.15242:15243](),[3.15243][3.3481:3523](),[3.3523][3.15289:15290](),[3.15289][3.15289:15290](),[3.15290][3.3524:3643](),[3.3643][3.15433:15445](),[3.15433][3.15433:15445](),[3.15445][3.3644:3686](),[3.3686][3.15407:15413](),[3.15492][3.15407:15413](),[3.15407][3.15407:15413]()
    /// Takes `checked_data.keytree` and builds a collection of graphics,
    /// each plotting 1 time-series.
    pub fn bootstrap_ts_spec(&self) {
    let mut h: HashMap<PageKey, TSPageSpec> = HashMap::new();
    for series in &self.0 {
    // Check that there are no errors in the CheckedDataSpec series.
    if series.error.to_lowercase() != "ok" {
    println!("{}", series.keytree());
    panic!();
    };
    // Insert the series into the TSGraphicSpec.
    match h.get_mut(&series.key()) {
    Some(page_spec) => {
    page_spec.graphics[0].push(&series.id);
    },
    None => {
    let mut ts_graphic_spec = TSGraphicSpec::new();
    ts_graphic_spec.push(&series.id);
    let ts_page_spec = TSPageSpec::new(series.key(), vec!(ts_graphic_spec));
    h.insert(series.key(), ts_page_spec);
    }
    }
    }
    // Build TSSpec from the hashmap.
    let mut ts_spec = TSSpec(Vec::new());
    for (key, page_spec) in h {
    ts_spec.push(page_spec);
    };
    println!("{}", ts_spec.keytree())
    }
  • replacement in src/check_data.rs at line 309
    [3.15765][3.15765:15800]()
    kt.push_key(0, "seriess");
    [3.15765]
    [3.15800]
    kt.push_key(0, "page");
  • replacement in src/check_data.rs at line 328
    [3.11103][3.15706:15734](),[3.15706][3.15706:15734]()
    pub id: String,
    [3.11103]
    [3.11104]
    pub series_id: SeriesId,
  • edit in src/check_data.rs at line 365
    [3.3688][3.11260:11282](),[3.11282][3.3688:3831](),[3.3688][3.3688:3831](),[3.3831][3.15845:15846](),[3.15845][3.15845:15846]()
    /// Return a key.
    pub fn key(&self) -> PageKey {
    PageKey {
    data_type: self.data_type,
    country: self.country,
    }
    }
  • replacement in src/check_data.rs at line 366
    [3.15925][3.15925:15977]()
    pub fn write_data(&mut self, root_path: &str) {
    [3.15925]
    [3.15977]
    pub fn write_data(&self, root_path: &str) {
  • replacement in src/check_data.rs at line 370
    [3.16042][3.16042:16113]()
    let observations = match Fred::series_observations(&self.id) {
    [3.16042]
    [3.16113]
    let observations = match Fred::series_observations(&self.series_id.to_string()) {
  • replacement in src/check_data.rs at line 397
    [3.16765][3.16765:16790]()
    self.id,
    [3.16765]
    [3.16790]
    self.series_id,
  • edit in src/check_data.rs at line 399
    [3.16805][3.16805:16806](),[3.16806][2.4314:4368]()
    self.time_stamp = Some(TimeStamp::now());
  • edit in src/check_data.rs at line 401
    [3.16950]
    [3.16950]
    println!("Writing {}", filename);
  • replacement in src/check_data.rs at line 408
    [3.17105][3.17105:17157]()
    pub fn write_meta(&mut self, root_path: &str) {
    [3.17105]
    [3.17157]
    pub fn write_meta(&self, root_path: &str) {
  • replacement in src/check_data.rs at line 410
    [3.17158][3.17158:17208]()
    let meta = match Fred::series(&self.id) {
    [3.17158]
    [3.17208]
    let meta = match Fred::series(&self.series_id.to_string()) {
  • replacement in src/check_data.rs at line 416
    [3.17418][3.17418:17479]()
    id: self.id.clone(),
    [3.17418]
    [3.17479]
    series_id: self.series_id.clone(),
  • replacement in src/check_data.rs at line 440
    [3.18261][3.18261:18282]()
    self.id,
    [3.18261]
    [3.18282]
    self.series_id,
  • edit in src/check_data.rs at line 444
    [3.18342]
    [3.18342]
    println!("Writing {}", filename);
  • replacement in src/check_data.rs at line 455
    [3.16329][3.16329:16374]()
    kt.push_keyvalue(1, "id", &self.id);
    [3.16329]
    [3.16374]
    kt.push_keyvalue(1, "series_id", &self.series_id.to_string());
  • edit in src/check_data.rs at line 479
    [3.18687]
    [3.16874]
    let country: Country = self.value("series::country")?;
  • replacement in src/check_data.rs at line 484
    [2.4770][2.4770:4829]()
    id: self.value("series::id")?,
    [2.4770]
    [2.4829]
    series_id: self.value("series::series_id")?,
  • replacement in src/check_data.rs at line 501
    [3.19201][3.19201:19258]()
    /// id: AUSCPALTT01IXNBQ
    [3.19201]
    [3.19258]
    /// series_id: AUSCPALTT01IXNBQ
  • replacement in src/check_data.rs at line 509
    [3.19648][3.19648:19669]()
    #[derive(Serialize)]
    [3.19648]
    [3.19669]
    #[derive(Debug, Serialize)]
  • replacement in src/check_data.rs at line 512
    [3.19719][3.19719:19735]()
    id: String,
    [3.19719]
    [3.19735]
    series_id: SeriesId,
  • replacement in src/check_data.rs at line 526
    [3.11529][3.11529:11556]()
    series_id: String,
    [3.11529]
    [3.11556]
    series_id: SeriesId,
  • replacement in src/check_data.rs at line 551
    [2.5041][2.5041:5113]()
    id: self.value("series_meta::id")?,
    [2.5041]
    [2.5113]
    series_id: self.value("series_meta::series_id")?,
  • replacement in src/check_data.rs at line 568
    [3.20848][3.20848:20893]()
    kt.push_keyvalue(1, "id", &self.id);
    [3.20848]
    [3.20893]
    kt.push_keyvalue(1, "series_id", &self.series_id.to_string());
  • edit in src/check_data.rs at line 579
    [3.21249]
    // self.time_stamp = Some(TimeStamp::now());
  • replacement in src/build_spec.rs at line 21
    [3.21547][3.21547:21568]()
    use crate::DataType;
    [3.21547]
    [3.21568]
    use crate::{
    DataType,
    SeriesId,
    };
  • replacement in src/build_spec.rs at line 63
    [3.22545][3.22545:22634]()
    /// println!("{}", generic_cpi_series_spec(&Country::NewZealand, "cpi_series.keytree"));
    [3.22545]
    [3.22634]
    /// println!("{}", generic_cpi_series_spec(Country::NewZealand, "cpi_series.keytree"));
  • replacement in src/build_spec.rs at line 65
    [3.22642][3.22642:22709]()
    pub fn generic_cpi_series_spec(country: &Country) -> SeriesItems {
    [3.22642]
    [3.22709]
    pub fn generic_cpi_series_spec(country: Country) -> SeriesItems {
  • replacement in src/build_spec.rs at line 448
    [3.44897][3.44897:44961]()
    match Fred::tags_series(&to_tag("cpi", &country)) {
    [3.44897]
    [3.44961]
    match Fred::tags_series(&to_tag("cpi", country)) {
  • replacement in src/build_spec.rs at line 462
    [3.45264][3.45264:45316]()
    fn to_tag(tag: &str, country: &Country) -> String {
    [3.45264]
    [3.45316]
    fn to_tag(tag: &str, country: Country) -> String {
  • edit in src/build_spec.rs at line 468
    [3.45408]
    [3.45408]
    }
    /// Return relevant inflation rate series for a country. This function first selects all series with
    /// a certain tag pattern, and then applies required phrases and exclusionary phrases.
    /// ```
    /// println!("{}", generic_inf_series_spec(Country::Canada));
    /// ```
    pub fn generic_inf_series_spec(country: Country) -> SeriesItems {
    if let Country::UnitedStates = country {
    // Need to use a different search technique for US data.
    let exclude_phrase = vec!(
    "Producer Price Index",
    "Projections",
    "Export Price Index",
    "Implicit Price Deflator",
    "Employment Cost Index",
    "Contributions to",
    "Inflation Expectation",
    "Equity Market",
    "excluding food and energy",
    "Excluding Food and Energy",
    "excluding Food and Energy",
    "Urban",
    "Sticky",
    "Opinion",
    "Consumer Price Index",
    "Personal Consumption",
    "Private Consumption",
    );
    // let one_of = vec!(
    // "Unemployment Rate for United States",
    // "Unemployment Rate: Aged 15 and Over: All Persons for the United States",
    // "Unemployment Rate: Aged 15-74: All Persons for the United States",
    // "Harmonized Unemployment Rate: Total: All Persons for the United States",
    // "Unemployment Rate - 18 Years and Over",
    // );
    let tag_series = Fred::tags_series("inflation;usa;nation").unwrap().seriess;
    tag_series
    .exclude_phrases(exclude_phrase)
    // .equals_one_of(one_of)
    } else {
    let (exclude_phrase, include_phrase) = match country {
    Country::Australia => {
    (
    vec!(
    "Opinion",
    ),
    vec!(
    "Inflation",
    ),
    )
    },
    Country::Austria => {
    (
    vec!(
    "Opinion",
    ),
    vec!(
    "Inflation",
    ),
    )
    },
    Country::Belgium => {
    (
    vec!(
    "Opinion",
    ),
    vec!(
    "Inflation",
    ),
    )
    },
    Country::Canada => {
    (
    vec!(
    "Opinion",
    ),
    vec!(
    "Inflation",
    ),
    )
    },
    Country::Chile => {
    (
    vec!(
    "Opinion",
    ),
    vec!(
    "Inflation",
    ),
    )
    },
    Country::CzechRepublic => {
    (
    vec!(
    "Opinion",
    ),
    vec!(
    "Inflation",
    ),
    )
    },
    Country::Denmark => {
    (
    vec!(
    "Opinion",
    ),
    vec!(
    "Inflation",
    ),
    )
    },
    Country::Estonia => {
    (
    vec!(
    "Opinion",
    ),
    vec!(
    "Inflation",
    ),
    )
    },
    Country::Finland => {
    (
    vec!(
    "Opinion",
    ),
    vec!(
    "Inflation",
    ),
    )
    },
    Country::France => {
    (
    vec!(
    "Opinion",
    ),
    vec!(
    "Inflation",
    ),
    )
    },
    Country::Germany => {
    (
    vec!(
    "Opinion",
    ),
    vec!(
    "Inflation",
    ),
    )
    },
    Country::Greece => {
    (
    vec!(
    "Opinion",
    ),
    vec!(
    "Inflation",
    ),
    )
    },
    Country::Ireland => {
    (
    vec!(
    "Opinion",
    ),
    vec!(
    "Inflation",
    ),
    )
    },
    Country::Israel => {
    (
    vec!(
    ),
    vec!(
    "Inflation",
    ),
    )
    },
    Country::Italy => {
    (
    vec!(
    "Opinion",
    ),
    vec!(
    "Inflation",
    ),
    )
    },
    Country::Japan => {
    (
    vec!(
    ),
    vec!(
    "Inflation",
    ),
    )
    },
    Country::Latvia => {
    (
    vec!(
    ),
    vec!(
    "Inflation",
    ),
    )
    },
    Country::Netherlands => {
    (
    vec!(
    "Opinion",
    ),
    vec!(
    "Inflation",
    ),
    )
    },
    Country::NewZealand => {
    (
    vec!(
    ),
    vec!(
    "Inflation",
    ),
    )
    },
    Country::Norway => {
    (
    vec!(
    ),
    vec!(
    "Inflation",
    ),
    )
    },
    Country::Poland => {
    (
    vec!(
    "Opinion",
    ),
    vec!(
    "Inflation",
    ),
    )
    },
    Country::Serbia => {
    (
    vec!(
    ),
    vec!(
    "Inflation",
    ),
    )
    },
    Country::SouthKorea => {
    (
    vec!(
    ),
    vec!(
    "Inflation",
    ),
    )
    },
    Country::Spain => {
    (
    vec!(
    "Opinion",
    ),
    vec!(
    "Inflation",
    ),
    )
    },
    Country::Sweden => {
    (
    vec!(
    "Opinion",
    ),
    vec!(
    "Inflation",
    ),
    )
    },
    Country::Switzerland => {
    (
    vec!(
    "Opinion",
    ),
    vec!(
    "Inflation",
    ),
    )
    },
    Country::UnitedKingdom => {
    (
    vec!(
    "Opinion",
    "Consumer Price Inflation",
    ),
    vec!(
    "Inflation",
    ),
    )
    },
    Country::UnitedStates => {
    (
    vec!(
    ),
    vec!(
    "",
    ),
    )
    },
    _ => {
    panic!()
    },
    };
    match Fred::tags_series(&to_tag("inflation", country)) {
    Ok(tags_series) => {
    tags_series.seriess
    .exclude_phrases(exclude_phrase)
    .only_include(include_phrase)
    },
    Err(err) => {
    println!("{}", err);
    panic!();
    },
    }
    }
  • replacement in src/build_spec.rs at line 806
    [3.45479][3.45479:45558]()
    /// println!("{}", unemployment_series(&Country::Canada, "u_series.keytree"));
    [3.45479]
    [3.45558]
    /// println!("{}", unemployment_series(Country::Canada, "u_series.keytree"));
  • replacement in src/build_spec.rs at line 808
    [3.45566][3.45566:45631]()
    pub fn generic_u_series_spec(country: &Country) -> SeriesItems {
    [3.45566]
    [3.45631]
    pub fn generic_u_series_spec(country: Country) -> SeriesItems {
  • edit in src/build_spec.rs at line 1312
    [3.60080]
    [3.60080]
    /// Build a generic specification of one datatype and country.
    pub fn data_spec_for_country(data_type: DataType, country: Country) -> DataSpec {
    let mut seriess = DataSpec(Vec::new());
    match data_type {
    DataType::U => {
    for series_item in generic_u_series_spec(country).iter() {
    seriess.0.push(
    SourceSeries {
    data_type: DataType::U,
    country,
    series_id: SeriesId::new(&series_item.id.clone()),
    }
    )
    }
    println!("{} {}", country, data_type);
    },
    DataType::Inf => {
    for series_item in generic_inf_series_spec(country).iter() {
    seriess.0.push(
    SourceSeries {
    data_type: DataType::Inf,
    country,
    series_id: SeriesId::new(&series_item.id.clone()),
    }
    )
    }
    println!("{} {}", country, data_type);
    },
    DataType::Cpi => {
    for series_item in generic_cpi_series_spec(country).iter() {
    seriess.0.push(
    SourceSeries {
    data_type: DataType::Cpi,
    country,
    series_id: SeriesId::new(&series_item.id.clone()),
    }
    )
    }
    println!("{} {}", country, data_type);
    },
    DataType::Int => {},
    }
    seriess
    }
    /// Build a generic specification for all data. Output looks like
  • replacement in src/build_spec.rs at line 1364
    [3.60177][3.60177:60210]()
    /// id: AUSURAMS
    [3.60177]
    [3.60210]
    /// series_id: AUSURAMS
  • replacement in src/build_spec.rs at line 1366
    [3.60219][3.60219:60258]()
    pub fn build_data_spec() -> DataSpec {
    [3.60219]
    [3.60258]
    pub fn build_generic_data_spec() -> DataSpec {
  • edit in src/build_spec.rs at line 1368
    [3.60302][3.60302:60336]()
    let data_type = DataType::U;
  • replacement in src/build_spec.rs at line 1369
    [3.60379][3.60379:60696]()
    println!("{}", country);
    for series_item in generic_u_series_spec(&country).iter() {
    seriess.0.push(
    SourceSeries {
    data_type,
    country,
    id: series_item.id.clone(),
    }
    )
    }
    }
    [3.60379]
    [3.60696]
    seriess.append(&mut data_spec_for_country(DataType::U, country));
    }
    for country in countries_with_data() {
    seriess.append(&mut data_spec_for_country(DataType::Cpi, country));
    }
    for country in countries_with_data() {
    seriess.append(&mut data_spec_for_country(DataType::Inf, country));
    }
  • edit in src/build_spec.rs at line 1380
    [3.60711]
    [3.60711]
    /// A generic specification of all data series. Output looks like
  • edit in src/build_spec.rs at line 1397
    [3.61142][3.61142:61151]()
  • replacement in src/build_spec.rs at line 1398
    [3.61152][3.61152:61535]()
    // /// Read in source_data.keytree, download series, and return
    // /// `CheckedSourceSeries`.
    // pub fn update(&self) {
    // for series in &self.0 {
    // let data = match Fred::series(&series.id) {
    // Ok(data) => println!("{}", data.keytree()),
    // Err(err) => println!("{:?}", err),
    // };
    // }
    // }
    [3.61152]
    [3.61535]
    /// Append `other` to `Self`.
    pub fn append(&mut self, other: &mut DataSpec) {
    self.0.append(&mut other.0)
    }
  • edit in src/build_spec.rs at line 1427
    [3.62032][3.12044:12045]()
  • replacement in src/build_spec.rs at line 1428
    [3.12053][3.62032:62061](),[3.62032][3.62032:62061](),[3.62061][3.12054:12055]()
    pub data_type: DataType,
    [3.12053]
    [3.12055]
    pub data_type: DataType,
  • replacement in src/build_spec.rs at line 1430
    [3.12063][3.62061:62087](),[3.62061][3.62061:62087](),[3.62087][3.12064:12065]()
    pub country: Country,
    [3.12063]
    [3.12065]
    pub country: Country,
  • replacement in src/build_spec.rs at line 1432
    [3.12073][3.62087:62107](),[3.62087][3.62087:62107]()
    pub id: String,
    [3.12073]
    [3.62107]
    pub series_id: SeriesId,
  • replacement in src/build_spec.rs at line 1441
    [3.62402][3.62402:62447]()
    kt.push_keyvalue(1, "id", &self.id);
    [3.62402]
    [3.62447]
    kt.push_keyvalue(1, "series_id", &self.series_id.to_string());
  • replacement in src/build_spec.rs at line 1454
    [2.5706][2.5706:5761]()
    id: self.value("series::id")?,
    [2.5706]
    [3.63017]
    series_id: self.value("series::series_id")?,