keinsell / neuronek

🧬 Intelligent dosage tracker application with purpose to monitor supplements, nootropics and psychoactive substances along with their long-term influence on one's mind and body.
https://neuronek.up.railway.app/reference
Do What The F*ck You Want To Public License
11 stars 2 forks source link

Export Duration Strings from ETL #496

Closed keinsell closed 3 weeks ago

keinsell commented 3 weeks ago

When I was parsing phases from route of administration infromation (right from database) at the end they we're completly different than psychonautwiki's data on which database is based, my guess is somewhere in the ETL process unit of duration is lost and not everything is serialized on seconds -> there is a need to rebuild database with duration units or ISO format of duration to avoid confusion.

      let phases: Vec<Phase> = db::substance_route_of_administration_phase::Entity::find()
            .filter(
                db::substance_route_of_administration_phase::Column::RouteOfAdministrationId
                    .eq(&route_of_administration.id),
            )
            .all(&DB_CONNECTION as &DatabaseConnection)
            .await
            .unwrap()
            .iter()
            .map(|p| {
                let phase_id = p.id.clone();
                let route_of_administration_id = p.route_of_administration_id.clone().unwrap();
                let phase_classification =
                    PhaseClassification::from_str(&p.classification).unwrap();

                let phase_duration = DurationRange {
                    start: TimeDelta::seconds(p.min_duration.unwrap() as i64),
                    end: TimeDelta::seconds(p.max_duration.unwrap() as i64),
                };

                let phase = Phase {
                    id: phase_id,
                    route_of_administration_id: route_of_administration_id,
                    phase_classification: phase_classification,
                    duration_range: phase_duration,
                };

                phase
            })
            .collect();            
linear[bot] commented 3 weeks ago

NEU-41 Export Duration Strings from ETL