project init
This commit is contained in:
commit
25c5a5f556
9 changed files with 3222 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/target
|
1891
Cargo.lock
generated
Normal file
1891
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
17
Cargo.toml
Normal file
17
Cargo.toml
Normal file
|
@ -0,0 +1,17 @@
|
|||
[package]
|
||||
name = "willdaten"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
chrono = "0.4.39"
|
||||
diesel = { version = "2.2.6", features = ["64-column-tables", "chrono", "postgres", "postgres_backend", "uuid"] }
|
||||
dotenvy = "0.15.7"
|
||||
hex = "0.4.3"
|
||||
maud = "0.26.0"
|
||||
reqwest = { version = "0.12.12", features = ["json"] }
|
||||
serde = { version = "1.0.217", features = ["derive"] }
|
||||
serde_json = "1.0.135"
|
||||
sha2 = "0.10.8"
|
||||
tokio = { version = "1.43.0", features = ["full"] }
|
||||
uuid = "1.12.0"
|
142
VRN Data Database.sql
Normal file
142
VRN Data Database.sql
Normal file
|
@ -0,0 +1,142 @@
|
|||
CREATE TABLE "stop_lists" (
|
||||
"input" int PRIMARY KEY,
|
||||
"point_dm" varchar(255),
|
||||
"point_type" varchar(255),
|
||||
"point_name" varchar(255),
|
||||
"point_stateless" varchar(255),
|
||||
"point_stopId" int,
|
||||
"point_anytype" varchar(255),
|
||||
"point_sort" int,
|
||||
"point_quality" int,
|
||||
"point_best" int,
|
||||
"point_object" varchar(255),
|
||||
"point_ref_id" int,
|
||||
"point_ref_gid" varchar(50),
|
||||
"point_ref_omc" int,
|
||||
"point_ref_placeID" int,
|
||||
"point_ref_place" varchar(50),
|
||||
"point_ref_coords" varchar(50),
|
||||
"itdOdvAssignedStops_stopid" int,
|
||||
"itdOdvAssignedStops_name" varchar(255),
|
||||
"itdOdvAssignedStops_x" float,
|
||||
"itdOdvAssignedStops_y" float,
|
||||
"itdOdvAssignedStops_mapName" varchar(255),
|
||||
"itdOdvAssignedStops_value" varchar(255),
|
||||
"itdOdvAssignedStops_place" varchar(255),
|
||||
"itdOdvAssignedStops_nameWithPlace" varchar(255),
|
||||
"itdOdvAssignedStops_distanceTime" int,
|
||||
"itdOdvAssignedStops_isTransferStop" int,
|
||||
"itdOdvAssignedStops_vm" int,
|
||||
"itdOdvAssignedStops_gid" varchar(255),
|
||||
"meta_lastModificationDate" timestamp
|
||||
);
|
||||
|
||||
CREATE TABLE "serving_lines" (
|
||||
"servingLineId" varchar(255) PRIMARY KEY,
|
||||
"mode_name" varchar(255),
|
||||
"mode_number" varchar(50),
|
||||
"mode_product" varchar(255),
|
||||
"mode_productId" int,
|
||||
"mode_type" int,
|
||||
"mode_code" int,
|
||||
"mode_destination" varchar(255),
|
||||
"mode_destID" int,
|
||||
"mode_desc" varchar(255),
|
||||
"mode_timetablePeriod" varchar(255),
|
||||
"diva_branch" varchar(50),
|
||||
"diva_line" varchar(50),
|
||||
"diva_supplement" varchar(50),
|
||||
"diva_dir" varchar(50),
|
||||
"diva_project" varchar(50),
|
||||
"diva_network" varchar(50),
|
||||
"diva_stateless" varchar(255),
|
||||
"diva_tripCode" int,
|
||||
"diva_operator" varchar(255),
|
||||
"diva_opPublicCode" varchar(50),
|
||||
"diva_opCode" varchar(50),
|
||||
"diva_Vf" date,
|
||||
"diva_vTo" date,
|
||||
"diva_lineDisplay" varchar(50),
|
||||
"meta_lastModificationDate" timestamp
|
||||
);
|
||||
|
||||
CREATE TABLE "arrivals" (
|
||||
"depatureRequestId" serial,
|
||||
"stopDetailId" serial PRIMARY KEY,
|
||||
"stopID" int,
|
||||
"x" float,
|
||||
"y" float,
|
||||
"mapName" varchar(255),
|
||||
"area" varchar(50),
|
||||
"platform" varchar(50),
|
||||
"platformName" varchar(255),
|
||||
"stopName" varchar(255),
|
||||
"nameWO" varchar(255),
|
||||
"pointType" varchar(50),
|
||||
"countdown" int,
|
||||
"arrivalTime" timestamp,
|
||||
"realArrivalTime" timestamp,
|
||||
"servingLine_key" varchar(255),
|
||||
"servingLine_code" varchar(50),
|
||||
"servingLine_number" varchar(50),
|
||||
"servingLine_symbol" varchar(50),
|
||||
"servingLine_motType" int,
|
||||
"servingLine_mtSubcode" int,
|
||||
"servingLine_realtime" boolean,
|
||||
"servingLine_direction" varchar(255),
|
||||
"servingLine_directionFrom" varchar(255),
|
||||
"servingLine_name" varchar(255),
|
||||
"servingLine_delay" int,
|
||||
"servingLine_liErgRiProj_line" varchar(255),
|
||||
"servingLine_liErgRiProj_project" varchar(255),
|
||||
"servingLine_liErgRiProj_direction" varchar(50),
|
||||
"servingLine_liErgRiProj_supplement" varchar(50),
|
||||
"servingLine_liErgRiProj_network" varchar(255),
|
||||
"servingLine_destID" varchar(255),
|
||||
"servingLine_stateless" varchar(255),
|
||||
"servingLine_lineDisplay" varchar(255),
|
||||
"operator_code" varchar(50),
|
||||
"operator_name" varchar(255),
|
||||
"operator_publicCode" varchar(50),
|
||||
"attrs_name" varchar(255),
|
||||
"attrs_value" varchar(255)
|
||||
);
|
||||
|
||||
CREATE TABLE "depature_requests" (
|
||||
"depatureRequestId" serial PRIMARY KEY,
|
||||
"stopid" int,
|
||||
"serverid" varchar(255),
|
||||
"requestid" varchar(255),
|
||||
"sessionid" varchar(255),
|
||||
"calcTime" float,
|
||||
"serverTime" timestamp,
|
||||
"logRequestId" varchar(255)
|
||||
);
|
||||
|
||||
CREATE TABLE "station_hints" (
|
||||
"infoLinkURL" varchar(255) PRIMARY KEY,
|
||||
"infoLinkText" varchar(255),
|
||||
"infoText" varchar(2055)
|
||||
);
|
||||
|
||||
CREATE TABLE "depature_requeststation_hints" (
|
||||
"infoLinkUrl" varchar(255) PRIMARY KEY,
|
||||
"depatureRequestId" int
|
||||
);
|
||||
|
||||
CREATE TABLE "serving_line_depature_requests" (
|
||||
"depatureRequestId" int PRIMARY KEY,
|
||||
"servingLineId" varchar(255)
|
||||
);
|
||||
|
||||
ALTER TABLE "arrivals" ADD FOREIGN KEY ("depatureRequestId") REFERENCES "depature_requests" ("depatureRequestId");
|
||||
|
||||
ALTER TABLE "depature_requests" ADD FOREIGN KEY ("stopid") REFERENCES "stop_lists" ("input");
|
||||
|
||||
ALTER TABLE "depature_requeststation_hints" ADD FOREIGN KEY ("infoLinkUrl") REFERENCES "station_hints" ("infoLinkURL");
|
||||
|
||||
ALTER TABLE "depature_requeststation_hints" ADD FOREIGN KEY ("depatureRequestId") REFERENCES "depature_requests" ("depatureRequestId");
|
||||
|
||||
ALTER TABLE "serving_line_depature_requests" ADD FOREIGN KEY ("depatureRequestId") REFERENCES "depature_requests" ("depatureRequestId");
|
||||
|
||||
ALTER TABLE "serving_line_depature_requests" ADD FOREIGN KEY ("servingLineId") REFERENCES "serving_lines" ("servingLineId");
|
9
diesel.toml
Normal file
9
diesel.toml
Normal file
|
@ -0,0 +1,9 @@
|
|||
# For documentation on how to configure this file,
|
||||
# see https://diesel.rs/guides/configuring-diesel-cli
|
||||
|
||||
[print_schema]
|
||||
file = "src/schema.rs"
|
||||
custom_type_derives = ["diesel::query_builder::QueryId", "Clone"]
|
||||
|
||||
[migrations_directory]
|
||||
dir = "/home/bread/Dokumente/willdaten/migrations"
|
465
src/dtos.rs
Normal file
465
src/dtos.rs
Normal file
|
@ -0,0 +1,465 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Root {
|
||||
pub parameters: Vec<Parameter>,
|
||||
pub dm: Dm,
|
||||
pub arr: Arr,
|
||||
pub date_time: DateTime,
|
||||
pub date_range: Vec<DateRange>,
|
||||
pub serving_lines: ServingLines,
|
||||
pub departure_list: Option<Vec<DepartureList>>,
|
||||
pub arrival_list: Option<Vec<ArrivalList>>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Parameter {
|
||||
pub name: String,
|
||||
pub value: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Dm {
|
||||
pub input: Input,
|
||||
pub points: Points,
|
||||
pub itd_odv_assigned_stops: ItdOdvAssignedStops,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Input {
|
||||
pub input: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Points {
|
||||
pub point: Point,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Point {
|
||||
pub usage: String,
|
||||
#[serde(rename = "type")]
|
||||
pub type_field: String,
|
||||
pub name: String,
|
||||
pub stateless: String,
|
||||
pub any_type: String,
|
||||
pub sort: String,
|
||||
pub quality: String,
|
||||
pub best: String,
|
||||
pub object: String,
|
||||
#[serde(rename = "ref")]
|
||||
pub ref_field: Ref,
|
||||
pub infos: Option<Infos>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Ref {
|
||||
pub id: String,
|
||||
pub gid: String,
|
||||
pub omc: String,
|
||||
#[serde(rename = "placeID")]
|
||||
pub place_id: String,
|
||||
pub place: String,
|
||||
pub coords: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Infos {
|
||||
pub info: Info,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Info {
|
||||
pub info_link_text: String,
|
||||
#[serde(rename = "infoLinkURL")]
|
||||
pub info_link_url: String,
|
||||
pub info_text: InfoText,
|
||||
pub param_list: Vec<ParamList>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct InfoText {
|
||||
pub content: String,
|
||||
pub subtitle: String,
|
||||
pub subject: String,
|
||||
pub additional_text: String,
|
||||
pub html_text: String,
|
||||
pub wml_text: String,
|
||||
pub sms_text: String,
|
||||
pub speech_text: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ParamList {
|
||||
#[serde(rename = "type")]
|
||||
pub type_field: String,
|
||||
pub name: String,
|
||||
pub value: String,
|
||||
pub edit: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ItdOdvAssignedStops {
|
||||
#[serde(rename = "stopID")]
|
||||
pub stop_id: String,
|
||||
pub name: String,
|
||||
pub x: String,
|
||||
pub y: String,
|
||||
pub map_name: String,
|
||||
pub value: String,
|
||||
pub place: String,
|
||||
pub name_with_place: String,
|
||||
pub distance_time: String,
|
||||
pub is_transfer_stop: String,
|
||||
pub vm: String,
|
||||
pub gid: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Arr {
|
||||
pub input: Input2,
|
||||
pub points: Value,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Input2 {
|
||||
pub input: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct DateTime {
|
||||
pub deparr: String,
|
||||
pub ttp_from: String,
|
||||
pub ttp_to: String,
|
||||
pub year: String,
|
||||
pub month: String,
|
||||
pub day: String,
|
||||
pub hour: String,
|
||||
pub minute: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct DateRange {
|
||||
pub day: String,
|
||||
pub month: String,
|
||||
pub year: String,
|
||||
pub weekday: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct PtOption {
|
||||
pub active: String,
|
||||
pub max_changes: String,
|
||||
pub max_time: String,
|
||||
pub max_wait: String,
|
||||
pub route_type: String,
|
||||
pub change_speed: String,
|
||||
pub line_restriction: String,
|
||||
pub use_prox_foot_search: String,
|
||||
pub use_prox_foot_search_origin: String,
|
||||
pub use_prox_foot_search_destination: String,
|
||||
pub bike: String,
|
||||
pub plane: String,
|
||||
pub no_crowded: String,
|
||||
pub no_solid_stairs: String,
|
||||
pub no_escalators: String,
|
||||
pub no_elevators: String,
|
||||
pub low_platform_vhcl: String,
|
||||
pub wheelchair: String,
|
||||
pub need_elevated_plt: String,
|
||||
pub assistance: String,
|
||||
#[serde(rename = "SOSAvail")]
|
||||
pub sosavail: String,
|
||||
pub no_lonely_transfer: String,
|
||||
pub illum_transfer: String,
|
||||
pub overground_transfer: String,
|
||||
pub no_insecure_places: String,
|
||||
pub private_transport: String,
|
||||
pub excluded_means: Vec<ExcludedMean>,
|
||||
pub active_imp: String,
|
||||
pub active_com: String,
|
||||
pub active_sec: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ExcludedMean {
|
||||
pub means: String,
|
||||
pub value: String,
|
||||
pub selected: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ServingLines {
|
||||
pub lines: Vec<Line>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Line {
|
||||
pub mode: Mode,
|
||||
pub index: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Mode {
|
||||
pub name: String,
|
||||
pub number: String,
|
||||
pub product: String,
|
||||
pub product_id: String,
|
||||
#[serde(rename = "type")]
|
||||
pub type_field: String,
|
||||
pub code: String,
|
||||
pub destination: String,
|
||||
#[serde(rename = "destID")]
|
||||
pub dest_id: String,
|
||||
pub desc: String,
|
||||
pub timetable_period: String,
|
||||
pub diva: Diva,
|
||||
pub train_type: Option<String>,
|
||||
pub train_name: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Diva {
|
||||
pub branch: String,
|
||||
pub line: String,
|
||||
pub supplement: String,
|
||||
pub dir: String,
|
||||
pub project: String,
|
||||
pub network: String,
|
||||
pub stateless: String,
|
||||
pub trip_code: String,
|
||||
pub operator: String,
|
||||
pub op_code: String,
|
||||
pub v_f: String,
|
||||
pub v_to: String,
|
||||
pub line_display: String,
|
||||
pub attrs: Vec<Attr>,
|
||||
pub op_public_code: Option<String>,
|
||||
pub global_id: Option<String>,
|
||||
pub special_fares: Option<String>,
|
||||
#[serde(rename = "isTTB")]
|
||||
pub is_ttb: Option<String>,
|
||||
#[serde(rename = "isSTT")]
|
||||
pub is_stt: Option<String>,
|
||||
#[serde(rename = "isROP")]
|
||||
pub is_rop: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Attr {
|
||||
pub name: String,
|
||||
pub value: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct DepartureList {
|
||||
#[serde(rename = "stopID")]
|
||||
pub stop_id: i32,
|
||||
pub x: String,
|
||||
pub y: String,
|
||||
pub map_name: String,
|
||||
pub area: String,
|
||||
pub platform: String,
|
||||
pub platform_name: String,
|
||||
pub stop_name: String,
|
||||
#[serde(rename = "nameWO")]
|
||||
pub name_wo: String,
|
||||
pub point_type: Option<String>,
|
||||
pub countdown: String,
|
||||
pub date_time: DateTime2,
|
||||
pub serving_line: ServingLine,
|
||||
pub operator: Option<Operator>,
|
||||
pub attrs: Option<Vec<Attr2>>,
|
||||
pub stop_infos: Option<StopInfos>,
|
||||
pub line_infos: Value,
|
||||
pub trip_infos: Value,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ArrivalList {
|
||||
#[serde(rename = "stopID")]
|
||||
pub stop_id: String,
|
||||
pub x: String,
|
||||
pub y: String,
|
||||
pub map_name: String,
|
||||
pub area: String,
|
||||
pub platform: String,
|
||||
pub platform_name: String,
|
||||
pub stop_name: String,
|
||||
#[serde(rename = "nameWO")]
|
||||
pub name_wo: String,
|
||||
pub countdown: String,
|
||||
pub date_time: DateTime2,
|
||||
pub real_date_time: Option<DateTime2>,
|
||||
pub serving_line: ArrServingLine,
|
||||
pub operator: Option<Operator>,
|
||||
pub attrs: Option<Vec<Attr2>>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ArrServingLine {
|
||||
pub key: String,
|
||||
pub code: String,
|
||||
pub number: String,
|
||||
pub symbol: String,
|
||||
pub mot_type: String,
|
||||
pub mt_subcode: String,
|
||||
pub realtime: String,
|
||||
pub direction: String,
|
||||
pub direction_from: String,
|
||||
pub train_type: Option<String>,
|
||||
pub train_name: Option<String>,
|
||||
pub train_num: Option<String>,
|
||||
pub name: String,
|
||||
pub delay: Option<String>,
|
||||
pub hints: Option<Vec<Hint>>,
|
||||
pub li_erg_ri_proj: ArrLiErgRiProj,
|
||||
#[serde(rename = "destID")]
|
||||
pub dest_id: String,
|
||||
pub stateless: String,
|
||||
pub line_display: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct LiErgRiProj {
|
||||
pub line: String,
|
||||
pub project: String,
|
||||
pub direction: String,
|
||||
pub supplement: String,
|
||||
pub network: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct DateTime2 {
|
||||
pub year: String,
|
||||
pub month: String,
|
||||
pub day: String,
|
||||
pub weekday: String,
|
||||
pub hour: String,
|
||||
pub minute: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ServingLine {
|
||||
pub key: String,
|
||||
pub code: String,
|
||||
pub number: String,
|
||||
pub symbol: String,
|
||||
pub mot_type: String,
|
||||
pub mt_subcode: String,
|
||||
pub realtime: String,
|
||||
pub direction: String,
|
||||
pub direction_from: String,
|
||||
pub name: String,
|
||||
pub li_erg_ri_proj: LiErgRiProj,
|
||||
#[serde(rename = "destID")]
|
||||
pub dest_id: String,
|
||||
pub stateless: String,
|
||||
pub line_display: String,
|
||||
pub train_type: Option<String>,
|
||||
pub train_name: Option<String>,
|
||||
pub train_num: Option<String>,
|
||||
#[serde(default)]
|
||||
pub hints: Vec<Hint>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ArrLiErgRiProj {
|
||||
pub line: String,
|
||||
pub project: String,
|
||||
pub direction: String,
|
||||
pub supplement: String,
|
||||
pub network: String,
|
||||
pub gid: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Hint {
|
||||
pub content: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Operator {
|
||||
pub code: String,
|
||||
pub name: String,
|
||||
pub public_code: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Attr2 {
|
||||
pub name: String,
|
||||
pub value: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct StopInfos {
|
||||
pub stop_info: StopInfo,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct StopInfo {
|
||||
pub info_link_text: String,
|
||||
#[serde(rename = "infoLinkURL")]
|
||||
pub info_link_url: String,
|
||||
pub info_text: InfoText2,
|
||||
pub param_list: Vec<ParamList2>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct InfoText2 {
|
||||
pub content: String,
|
||||
pub subtitle: String,
|
||||
pub subject: String,
|
||||
pub additional_text: String,
|
||||
pub html_text: String,
|
||||
pub wml_text: String,
|
||||
pub sms_text: String,
|
||||
pub speech_text: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ParamList2 {
|
||||
#[serde(rename = "type")]
|
||||
pub type_field: String,
|
||||
pub name: String,
|
||||
pub value: String,
|
||||
pub edit: String,
|
||||
}
|
290
src/main.rs
Normal file
290
src/main.rs
Normal file
|
@ -0,0 +1,290 @@
|
|||
#[macro_use]
|
||||
extern crate diesel;
|
||||
|
||||
mod dtos;
|
||||
mod models;
|
||||
mod schema;
|
||||
|
||||
use chrono::NaiveDate;
|
||||
use chrono::{Local, NaiveDateTime};
|
||||
use diesel::{dsl::insert_into, Connection, PgConnection, RunQueryDsl, SelectableHelper};
|
||||
use dotenvy::dotenv;
|
||||
use dtos::Root;
|
||||
use hex;
|
||||
use models::{
|
||||
Arrival, DepatureRequest, NewDepatureRequest, ServingLine, ServingLineDepatureRequest,
|
||||
StationHint, StopList,
|
||||
};
|
||||
use serde_json;
|
||||
use sha2::Digest;
|
||||
use sha2::Sha256;
|
||||
use std::{env, error::Error, fs, str::FromStr};
|
||||
|
||||
use crate::diesel::OptionalExtension;
|
||||
use crate::schema::arrivals::dsl::arrivals;
|
||||
use crate::schema::depature_requests::dsl::depature_requests;
|
||||
use crate::schema::serving_line_depature_requests::dsl::serving_line_depature_requests;
|
||||
use crate::schema::serving_lines::dsl::serving_lines;
|
||||
use crate::schema::station_hints::dsl::station_hints;
|
||||
use crate::schema::stop_lists::dsl::stop_lists;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn Error>> {
|
||||
dotenv().ok();
|
||||
let url = env::var("DATABASE_URL").expect("DATABASE_URL must be set");
|
||||
let mut conn =
|
||||
PgConnection::establish(&url).unwrap_or_else(|_| panic!("Error connecting to {}", url));
|
||||
|
||||
let src = "/home/bread/Downloads/2025-01-21";
|
||||
//let pool = SqlitePool::connect("sqlite::memory:").await?;
|
||||
|
||||
fs::read_dir(src).unwrap().into_iter().for_each(|path| {
|
||||
let path = path.unwrap();
|
||||
let content = fs::read_to_string(path.path()).unwrap();
|
||||
let data = serde_json::from_str::<Root>(&content).unwrap();
|
||||
let arrival_list = data.arrival_list.unwrap();
|
||||
let _ = insert_into(stop_lists)
|
||||
.values(StopList {
|
||||
input: i32::from_str(&data.dm.input.input).unwrap(),
|
||||
point_dm: Some(data.dm.points.point.usage),
|
||||
point_type: Some(data.dm.points.point.type_field.clone()),
|
||||
point_name: Some(data.dm.points.point.name),
|
||||
point_stopId: i32::from_str(&data.dm.points.point.ref_field.id).ok(),
|
||||
point_stateless: Some(data.dm.points.point.stateless),
|
||||
point_anytype: Some(data.dm.points.point.any_type),
|
||||
point_sort: i32::from_str(&data.dm.points.point.sort).ok(),
|
||||
point_quality: i32::from_str(&data.dm.points.point.quality).ok(),
|
||||
point_best: i32::from_str(&data.dm.points.point.best).ok(),
|
||||
point_object: Some(data.dm.points.point.object),
|
||||
point_ref_id: i32::from_str(&data.dm.points.point.ref_field.id).ok(),
|
||||
point_ref_gid: Some(data.dm.points.point.ref_field.gid),
|
||||
point_ref_omc: i32::from_str(&data.dm.points.point.ref_field.omc).ok(),
|
||||
point_ref_placeID: i32::from_str(&data.dm.points.point.ref_field.place_id).ok(),
|
||||
point_ref_place: Some(data.dm.points.point.ref_field.place),
|
||||
point_ref_coords: Some(data.dm.points.point.ref_field.coords),
|
||||
itdOdvAssignedStops_stopid: i32::from_str(&data.dm.itd_odv_assigned_stops.stop_id)
|
||||
.ok(),
|
||||
itdOdvAssignedStops_name: Some(data.dm.itd_odv_assigned_stops.name),
|
||||
itdOdvAssignedStops_x: f64::from_str(&data.dm.itd_odv_assigned_stops.x).ok(),
|
||||
itdOdvAssignedStops_y: f64::from_str(&data.dm.itd_odv_assigned_stops.y).ok(),
|
||||
itdOdvAssignedStops_mapName: Some(data.dm.itd_odv_assigned_stops.map_name),
|
||||
itdOdvAssignedStops_value: Some(data.dm.itd_odv_assigned_stops.value),
|
||||
itdOdvAssignedStops_place: Some(data.dm.itd_odv_assigned_stops.place),
|
||||
itdOdvAssignedStops_nameWithPlace: Some(
|
||||
data.dm.itd_odv_assigned_stops.name_with_place,
|
||||
),
|
||||
itdOdvAssignedStops_distanceTime: i32::from_str(
|
||||
&data.dm.itd_odv_assigned_stops.distance_time,
|
||||
)
|
||||
.ok(),
|
||||
itdOdvAssignedStops_isTransferStop: i32::from_str(
|
||||
&data.dm.itd_odv_assigned_stops.is_transfer_stop,
|
||||
)
|
||||
.ok(),
|
||||
itdOdvAssignedStops_vm: i32::from_str(&data.dm.itd_odv_assigned_stops.vm).ok(),
|
||||
itdOdvAssignedStops_gid: Some(data.dm.itd_odv_assigned_stops.gid),
|
||||
meta_lastModificationDate: Some(Local::now().naive_local()),
|
||||
})
|
||||
.returning(StopList::as_returning())
|
||||
.on_conflict_do_nothing()
|
||||
.get_result(&mut conn)
|
||||
.optional();
|
||||
let req = insert_into(depature_requests)
|
||||
.values(NewDepatureRequest {
|
||||
stopid: i32::from_str(&data.dm.itd_odv_assigned_stops.stop_id).ok(),
|
||||
serverid: data
|
||||
.parameters
|
||||
.iter()
|
||||
.filter(|p| p.name == "serverID")
|
||||
.map(|p| p.clone().value)
|
||||
.next(),
|
||||
requestid: data
|
||||
.parameters
|
||||
.iter()
|
||||
.filter(|p| p.name == "requestID")
|
||||
.map(|p| p.clone().value)
|
||||
.next(),
|
||||
sessionid: data
|
||||
.parameters
|
||||
.iter()
|
||||
.filter(|p| p.name == "sessionID")
|
||||
.map(|p| p.clone().value)
|
||||
.next(),
|
||||
calcTime: Some(
|
||||
f64::from_str(
|
||||
&data
|
||||
.parameters
|
||||
.iter()
|
||||
.filter(|p| p.name == "calcTime")
|
||||
.map(|p| p.clone().value)
|
||||
.next()
|
||||
.unwrap(),
|
||||
)
|
||||
.unwrap(),
|
||||
),
|
||||
serverTime: data
|
||||
.parameters
|
||||
.iter()
|
||||
.filter(|p| p.name == "serverTime")
|
||||
.map(|p| p.clone().value)
|
||||
.next()
|
||||
.unwrap()
|
||||
.parse::<NaiveDateTime>()
|
||||
.ok(),
|
||||
logRequestId: data
|
||||
.parameters
|
||||
.iter()
|
||||
.filter(|p| p.name == "logRequestId")
|
||||
.map(|p| p.clone().value)
|
||||
.next(),
|
||||
})
|
||||
.returning(DepatureRequest::as_returning())
|
||||
.on_conflict_do_nothing()
|
||||
.get_result(&mut conn)
|
||||
.optional()
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
for line in data.serving_lines.lines {
|
||||
let id = hex::encode(Sha256::digest(
|
||||
serde_json::to_string(&line.mode).unwrap().into_bytes(),
|
||||
));
|
||||
let _ = insert_into(serving_lines)
|
||||
.values(ServingLine {
|
||||
servingLineId: id.clone(),
|
||||
mode_name: Some(line.mode.name),
|
||||
mode_number: Some(line.mode.number),
|
||||
mode_product: Some(line.mode.product),
|
||||
mode_productId: i32::from_str(&line.mode.product_id).ok(),
|
||||
mode_type: i32::from_str(&line.mode.type_field).ok(),
|
||||
mode_code: i32::from_str(&line.mode.code).ok(),
|
||||
mode_destination: Some(line.mode.destination),
|
||||
mode_destID: i32::from_str(&line.mode.dest_id).ok(),
|
||||
mode_desc: Some(line.mode.desc),
|
||||
mode_timetablePeriod: Some(line.mode.timetable_period),
|
||||
diva_branch: Some(line.mode.diva.branch),
|
||||
diva_line: Some(line.mode.diva.line),
|
||||
diva_supplement: Some(line.mode.diva.supplement),
|
||||
diva_dir: Some(line.mode.diva.dir),
|
||||
diva_project: Some(line.mode.diva.project),
|
||||
diva_network: Some(line.mode.diva.network),
|
||||
diva_stateless: Some(line.mode.diva.stateless),
|
||||
diva_tripCode: i32::from_str(&line.mode.diva.trip_code).ok(),
|
||||
diva_operator: Some(line.mode.diva.operator),
|
||||
diva_opPublicCode: line.mode.diva.op_public_code,
|
||||
diva_opCode: Some(line.mode.diva.op_code),
|
||||
diva_Vf: NaiveDate::parse_from_str(&line.mode.diva.v_f, "%Y%m%d").ok(),
|
||||
diva_vTo: NaiveDate::parse_from_str(&line.mode.diva.v_to, "%Y%m%d").ok(),
|
||||
diva_lineDisplay: Some(line.mode.diva.line_display),
|
||||
meta_lastModificationDate: req.serverTime,
|
||||
})
|
||||
.returning(ServingLine::as_returning())
|
||||
.on_conflict_do_nothing()
|
||||
.get_result(&mut conn)
|
||||
.optional()
|
||||
.unwrap();
|
||||
let _ = insert_into(serving_line_depature_requests)
|
||||
.values(ServingLineDepatureRequest {
|
||||
depatureRequestId: req.depatureRequestId,
|
||||
servingLineId: id.clone(),
|
||||
})
|
||||
.returning(ServingLineDepatureRequest::as_returning())
|
||||
.on_conflict_do_nothing()
|
||||
.get_result(&mut conn)
|
||||
.optional()
|
||||
.unwrap();
|
||||
}
|
||||
if let Some(infos) = data.dm.points.point.infos {
|
||||
let _ = insert_into(station_hints).values(StationHint {
|
||||
infoLinkURL: infos.info.info_link_url,
|
||||
infoLinkText: Some(infos.info.info_link_text),
|
||||
infoText: Some(infos.info.info_text.content),
|
||||
});
|
||||
}
|
||||
{
|
||||
let _ = insert_into(arrivals)
|
||||
.values(arrival_list.into_iter().map(|arrival| { Arrival {
|
||||
depatureRequestId: req.depatureRequestId,
|
||||
stopDetailId: 0,
|
||||
stopID: i32::from_str(&arrival.stop_id).ok(),
|
||||
x: f64::from_str(&arrival.x).ok(),
|
||||
y: f64::from_str(&arrival.y).ok(),
|
||||
mapName: Some(arrival.map_name),
|
||||
area: Some(arrival.area),
|
||||
platform: Some(arrival.platform),
|
||||
platformName: Some(arrival.platform_name),
|
||||
stopName: Some(arrival.stop_name),
|
||||
nameWO: Some(arrival.name_wo),
|
||||
pointType: Some(data.dm.points.point.type_field.clone()),
|
||||
countdown: i32::from_str(&arrival.countdown).ok(),
|
||||
arrivalTime: NaiveDate::from_ymd_opt(
|
||||
i32::from_str(&arrival.date_time.year).unwrap(),
|
||||
u32::from_str(&arrival.date_time.month).unwrap(),
|
||||
u32::from_str(&arrival.date_time.day).unwrap(),
|
||||
)
|
||||
.unwrap()
|
||||
.and_hms_opt(
|
||||
u32::from_str(&arrival.date_time.hour).unwrap(),
|
||||
u32::from_str(&arrival.date_time.minute).unwrap(),
|
||||
0,
|
||||
),
|
||||
realArrivalTime: if let Some(date_time) = arrival.real_date_time {
|
||||
NaiveDate::from_ymd_opt(
|
||||
i32::from_str(&date_time.year).unwrap(),
|
||||
u32::from_str(&date_time.month).unwrap(),
|
||||
u32::from_str(&date_time.day).unwrap(),
|
||||
)
|
||||
.unwrap()
|
||||
.and_hms_opt(
|
||||
u32::from_str(&date_time.hour).unwrap(),
|
||||
u32::from_str(&date_time.minute).unwrap(),
|
||||
0,
|
||||
)
|
||||
} else {
|
||||
None
|
||||
},
|
||||
servingLine_key: Some(arrival.serving_line.key),
|
||||
servingLine_code: Some(arrival.serving_line.code),
|
||||
servingLine_number: Some(arrival.serving_line.number),
|
||||
servingLine_symbol: Some(arrival.serving_line.symbol),
|
||||
servingLine_motType: i32::from_str(&arrival.serving_line.mot_type).ok(),
|
||||
servingLine_mtSubcode: i32::from_str(&arrival.serving_line.mt_subcode).ok(),
|
||||
servingLine_realtime: bool::from_str(&arrival.serving_line.realtime).ok(),
|
||||
servingLine_direction: Some(arrival.serving_line.direction),
|
||||
servingLine_directionFrom: Some(arrival.serving_line.direction_from),
|
||||
servingLine_name: Some(arrival.serving_line.name),
|
||||
servingLine_delay: if let Some(delay) = arrival.serving_line.delay {
|
||||
i32::from_str(&delay).ok()
|
||||
} else {
|
||||
None
|
||||
},
|
||||
servingLine_liErgRiProj_line: Some(arrival.serving_line.li_erg_ri_proj.line),
|
||||
servingLine_liErgRiProj_project: Some(
|
||||
arrival.serving_line.li_erg_ri_proj.project,
|
||||
),
|
||||
servingLine_liErgRiProj_direction: Some(
|
||||
arrival.serving_line.li_erg_ri_proj.direction,
|
||||
),
|
||||
servingLine_liErgRiProj_supplement: Some(
|
||||
arrival.serving_line.li_erg_ri_proj.supplement,
|
||||
),
|
||||
servingLine_liErgRiProj_network: Some(
|
||||
arrival.serving_line.li_erg_ri_proj.network,
|
||||
),
|
||||
servingLine_destID: Some(arrival.serving_line.dest_id),
|
||||
servingLine_stateless: Some(arrival.serving_line.stateless),
|
||||
servingLine_lineDisplay: Some(arrival.serving_line.line_display),
|
||||
operator_code: arrival.operator.clone().map(|op| op.code),
|
||||
operator_name: arrival.operator.clone().map(|op| op.name),
|
||||
operator_publicCode: arrival.operator.map(|op| op.public_code),
|
||||
attrs_name: None,
|
||||
attrs_value: None,
|
||||
}}).collect::<Vec<_>>())
|
||||
.returning(Arrival::as_returning())
|
||||
.on_conflict_do_nothing()
|
||||
.get_result(&mut conn)
|
||||
.optional();
|
||||
}
|
||||
});
|
||||
|
||||
Ok(())
|
||||
}
|
175
src/models.rs
Normal file
175
src/models.rs
Normal file
|
@ -0,0 +1,175 @@
|
|||
// Generated by diesel_ext
|
||||
|
||||
#![allow(unused)]
|
||||
#![allow(clippy::all)]
|
||||
|
||||
use crate::schema::*;
|
||||
use chrono::NaiveDate;
|
||||
use chrono::NaiveDateTime;
|
||||
use diesel::pg::Pg;
|
||||
#[derive(Queryable, Selectable, Insertable, Debug, Identifiable, QueryableByName)]
|
||||
#[diesel(table_name = arrivals)]
|
||||
#[diesel(check_for_backend(Pg))]
|
||||
#[diesel(primary_key(stopDetailId))]
|
||||
pub struct Arrival {
|
||||
pub depatureRequestId: i32,
|
||||
pub stopDetailId: i32,
|
||||
pub stopID: Option<i32>,
|
||||
pub x: Option<f64>,
|
||||
pub y: Option<f64>,
|
||||
pub mapName: Option<String>,
|
||||
pub area: Option<String>,
|
||||
pub platform: Option<String>,
|
||||
pub platformName: Option<String>,
|
||||
pub stopName: Option<String>,
|
||||
pub nameWO: Option<String>,
|
||||
pub pointType: Option<String>,
|
||||
pub countdown: Option<i32>,
|
||||
pub arrivalTime: Option<NaiveDateTime>,
|
||||
pub realArrivalTime: Option<NaiveDateTime>,
|
||||
pub servingLine_key: Option<String>,
|
||||
pub servingLine_code: Option<String>,
|
||||
pub servingLine_number: Option<String>,
|
||||
pub servingLine_symbol: Option<String>,
|
||||
pub servingLine_motType: Option<i32>,
|
||||
pub servingLine_mtSubcode: Option<i32>,
|
||||
pub servingLine_realtime: Option<bool>,
|
||||
pub servingLine_direction: Option<String>,
|
||||
pub servingLine_directionFrom: Option<String>,
|
||||
pub servingLine_name: Option<String>,
|
||||
pub servingLine_delay: Option<i32>,
|
||||
pub servingLine_liErgRiProj_line: Option<String>,
|
||||
pub servingLine_liErgRiProj_project: Option<String>,
|
||||
pub servingLine_liErgRiProj_direction: Option<String>,
|
||||
pub servingLine_liErgRiProj_supplement: Option<String>,
|
||||
pub servingLine_liErgRiProj_network: Option<String>,
|
||||
pub servingLine_destID: Option<String>,
|
||||
pub servingLine_stateless: Option<String>,
|
||||
pub servingLine_lineDisplay: Option<String>,
|
||||
pub operator_code: Option<String>,
|
||||
pub operator_name: Option<String>,
|
||||
pub operator_publicCode: Option<String>,
|
||||
pub attrs_name: Option<String>,
|
||||
pub attrs_value: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Queryable, Selectable, Insertable, Debug, QueryableByName)]
|
||||
#[diesel(table_name = depature_requests)]
|
||||
#[diesel(check_for_backend(Pg))]
|
||||
#[diesel(primary_key(depatureRequestId))]
|
||||
pub struct DepatureRequest {
|
||||
pub depatureRequestId: i32,
|
||||
pub stopid: Option<i32>,
|
||||
pub serverid: Option<String>,
|
||||
pub requestid: Option<String>,
|
||||
pub sessionid: Option<String>,
|
||||
pub calcTime: Option<f64>,
|
||||
pub serverTime: Option<NaiveDateTime>,
|
||||
pub logRequestId: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Queryable, Selectable, Insertable, Debug, QueryableByName)]
|
||||
#[diesel(table_name = depature_requests)]
|
||||
pub struct NewDepatureRequest {
|
||||
pub stopid: Option<i32>,
|
||||
pub serverid: Option<String>,
|
||||
pub requestid: Option<String>,
|
||||
pub sessionid: Option<String>,
|
||||
pub calcTime: Option<f64>,
|
||||
pub serverTime: Option<NaiveDateTime>,
|
||||
pub logRequestId: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Queryable, Selectable, Insertable, Debug, Identifiable, QueryableByName)]
|
||||
#[diesel(table_name = depature_requeststation_hints)]
|
||||
#[diesel(check_for_backend(Pg))]
|
||||
#[diesel(primary_key(infoLinkUrl))]
|
||||
pub struct DepatureRequeststationHint {
|
||||
pub infoLinkUrl: String,
|
||||
pub depatureRequestId: Option<i32>,
|
||||
}
|
||||
|
||||
#[derive(Queryable, Selectable, Insertable, Debug, Identifiable, QueryableByName)]
|
||||
#[diesel(table_name = serving_line_depature_requests)]
|
||||
#[diesel(primary_key(depatureRequestId))]
|
||||
pub struct ServingLineDepatureRequest {
|
||||
pub depatureRequestId: i32,
|
||||
pub servingLineId: String,
|
||||
}
|
||||
|
||||
#[derive(Queryable, Selectable, Insertable, Debug, Identifiable, QueryableByName)]
|
||||
#[diesel(table_name = serving_lines)]
|
||||
#[diesel(primary_key(servingLineId))]
|
||||
pub struct ServingLine {
|
||||
pub servingLineId: String,
|
||||
pub mode_name: Option<String>,
|
||||
pub mode_number: Option<String>,
|
||||
pub mode_product: Option<String>,
|
||||
pub mode_productId: Option<i32>,
|
||||
pub mode_type: Option<i32>,
|
||||
pub mode_code: Option<i32>,
|
||||
pub mode_destination: Option<String>,
|
||||
pub mode_destID: Option<i32>,
|
||||
pub mode_desc: Option<String>,
|
||||
pub mode_timetablePeriod: Option<String>,
|
||||
pub diva_branch: Option<String>,
|
||||
pub diva_line: Option<String>,
|
||||
pub diva_supplement: Option<String>,
|
||||
pub diva_dir: Option<String>,
|
||||
pub diva_project: Option<String>,
|
||||
pub diva_network: Option<String>,
|
||||
pub diva_stateless: Option<String>,
|
||||
pub diva_tripCode: Option<i32>,
|
||||
pub diva_operator: Option<String>,
|
||||
pub diva_opPublicCode: Option<String>,
|
||||
pub diva_opCode: Option<String>,
|
||||
pub diva_Vf: Option<NaiveDate>,
|
||||
pub diva_vTo: Option<NaiveDate>,
|
||||
pub diva_lineDisplay: Option<String>,
|
||||
pub meta_lastModificationDate: Option<NaiveDateTime>,
|
||||
}
|
||||
|
||||
#[derive(Queryable, Selectable, Insertable, Debug, Identifiable, QueryableByName)]
|
||||
#[diesel(table_name = station_hints)]
|
||||
#[diesel(primary_key(infoLinkURL))]
|
||||
pub struct StationHint {
|
||||
pub infoLinkURL: String,
|
||||
pub infoLinkText: Option<String>,
|
||||
pub infoText: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Queryable, Selectable, Insertable, Debug, Identifiable, QueryableByName)]
|
||||
#[diesel(table_name = stop_lists)]
|
||||
#[diesel(primary_key(input))]
|
||||
pub struct StopList {
|
||||
pub input: i32,
|
||||
pub point_dm: Option<String>,
|
||||
pub point_type: Option<String>,
|
||||
pub point_name: Option<String>,
|
||||
pub point_stateless: Option<String>,
|
||||
pub point_stopId: Option<i32>,
|
||||
pub point_anytype: Option<String>,
|
||||
pub point_sort: Option<i32>,
|
||||
pub point_quality: Option<i32>,
|
||||
pub point_best: Option<i32>,
|
||||
pub point_object: Option<String>,
|
||||
pub point_ref_id: Option<i32>,
|
||||
pub point_ref_gid: Option<String>,
|
||||
pub point_ref_omc: Option<i32>,
|
||||
pub point_ref_placeID: Option<i32>,
|
||||
pub point_ref_place: Option<String>,
|
||||
pub point_ref_coords: Option<String>,
|
||||
pub itdOdvAssignedStops_stopid: Option<i32>,
|
||||
pub itdOdvAssignedStops_name: Option<String>,
|
||||
pub itdOdvAssignedStops_x: Option<f64>,
|
||||
pub itdOdvAssignedStops_y: Option<f64>,
|
||||
pub itdOdvAssignedStops_mapName: Option<String>,
|
||||
pub itdOdvAssignedStops_value: Option<String>,
|
||||
pub itdOdvAssignedStops_place: Option<String>,
|
||||
pub itdOdvAssignedStops_nameWithPlace: Option<String>,
|
||||
pub itdOdvAssignedStops_distanceTime: Option<i32>,
|
||||
pub itdOdvAssignedStops_isTransferStop: Option<i32>,
|
||||
pub itdOdvAssignedStops_vm: Option<i32>,
|
||||
pub itdOdvAssignedStops_gid: Option<String>,
|
||||
pub meta_lastModificationDate: Option<NaiveDateTime>,
|
||||
}
|
232
src/schema.rs
Normal file
232
src/schema.rs
Normal file
|
@ -0,0 +1,232 @@
|
|||
// @generated automatically by Diesel CLI.
|
||||
|
||||
diesel::table! {
|
||||
arrivals (stopDetailId) {
|
||||
depatureRequestId -> Int4,
|
||||
stopDetailId -> Int4,
|
||||
stopID -> Nullable<Int4>,
|
||||
x -> Nullable<Float8>,
|
||||
y -> Nullable<Float8>,
|
||||
#[max_length = 255]
|
||||
mapName -> Nullable<Varchar>,
|
||||
#[max_length = 50]
|
||||
area -> Nullable<Varchar>,
|
||||
#[max_length = 50]
|
||||
platform -> Nullable<Varchar>,
|
||||
#[max_length = 255]
|
||||
platformName -> Nullable<Varchar>,
|
||||
#[max_length = 255]
|
||||
stopName -> Nullable<Varchar>,
|
||||
#[max_length = 255]
|
||||
nameWO -> Nullable<Varchar>,
|
||||
#[max_length = 50]
|
||||
pointType -> Nullable<Varchar>,
|
||||
countdown -> Nullable<Int4>,
|
||||
arrivalTime -> Nullable<Timestamp>,
|
||||
realArrivalTime -> Nullable<Timestamp>,
|
||||
#[max_length = 255]
|
||||
servingLine_key -> Nullable<Varchar>,
|
||||
#[max_length = 50]
|
||||
servingLine_code -> Nullable<Varchar>,
|
||||
#[max_length = 50]
|
||||
servingLine_number -> Nullable<Varchar>,
|
||||
#[max_length = 50]
|
||||
servingLine_symbol -> Nullable<Varchar>,
|
||||
servingLine_motType -> Nullable<Int4>,
|
||||
servingLine_mtSubcode -> Nullable<Int4>,
|
||||
servingLine_realtime -> Nullable<Bool>,
|
||||
#[max_length = 255]
|
||||
servingLine_direction -> Nullable<Varchar>,
|
||||
#[max_length = 255]
|
||||
servingLine_directionFrom -> Nullable<Varchar>,
|
||||
#[max_length = 255]
|
||||
servingLine_name -> Nullable<Varchar>,
|
||||
servingLine_delay -> Nullable<Int4>,
|
||||
#[max_length = 255]
|
||||
servingLine_liErgRiProj_line -> Nullable<Varchar>,
|
||||
#[max_length = 255]
|
||||
servingLine_liErgRiProj_project -> Nullable<Varchar>,
|
||||
#[max_length = 50]
|
||||
servingLine_liErgRiProj_direction -> Nullable<Varchar>,
|
||||
#[max_length = 50]
|
||||
servingLine_liErgRiProj_supplement -> Nullable<Varchar>,
|
||||
#[max_length = 255]
|
||||
servingLine_liErgRiProj_network -> Nullable<Varchar>,
|
||||
#[max_length = 255]
|
||||
servingLine_destID -> Nullable<Varchar>,
|
||||
#[max_length = 255]
|
||||
servingLine_stateless -> Nullable<Varchar>,
|
||||
#[max_length = 255]
|
||||
servingLine_lineDisplay -> Nullable<Varchar>,
|
||||
#[max_length = 50]
|
||||
operator_code -> Nullable<Varchar>,
|
||||
#[max_length = 255]
|
||||
operator_name -> Nullable<Varchar>,
|
||||
#[max_length = 50]
|
||||
operator_publicCode -> Nullable<Varchar>,
|
||||
#[max_length = 255]
|
||||
attrs_name -> Nullable<Varchar>,
|
||||
#[max_length = 255]
|
||||
attrs_value -> Nullable<Varchar>,
|
||||
}
|
||||
}
|
||||
|
||||
diesel::table! {
|
||||
depature_requests (depatureRequestId) {
|
||||
depatureRequestId -> Int4,
|
||||
stopid -> Nullable<Int4>,
|
||||
#[max_length = 255]
|
||||
serverid -> Nullable<Varchar>,
|
||||
#[max_length = 255]
|
||||
requestid -> Nullable<Varchar>,
|
||||
#[max_length = 255]
|
||||
sessionid -> Nullable<Varchar>,
|
||||
calcTime -> Nullable<Float8>,
|
||||
serverTime -> Nullable<Timestamp>,
|
||||
#[max_length = 255]
|
||||
logRequestId -> Nullable<Varchar>,
|
||||
}
|
||||
}
|
||||
|
||||
diesel::table! {
|
||||
depature_requeststation_hints (infoLinkUrl) {
|
||||
#[max_length = 255]
|
||||
infoLinkUrl -> Varchar,
|
||||
depatureRequestId -> Nullable<Int4>,
|
||||
}
|
||||
}
|
||||
|
||||
diesel::table! {
|
||||
serving_line_depature_requests (depatureRequestId) {
|
||||
depatureRequestId -> Int4,
|
||||
#[max_length = 255]
|
||||
servingLineId -> VarChar,
|
||||
}
|
||||
}
|
||||
|
||||
diesel::table! {
|
||||
serving_lines (servingLineId) {
|
||||
#[max_length = 255]
|
||||
servingLineId -> VarChar,
|
||||
#[max_length = 255]
|
||||
mode_name -> Nullable<Varchar>,
|
||||
#[max_length = 50]
|
||||
mode_number -> Nullable<Varchar>,
|
||||
#[max_length = 255]
|
||||
mode_product -> Nullable<Varchar>,
|
||||
mode_productId -> Nullable<Int4>,
|
||||
mode_type -> Nullable<Int4>,
|
||||
mode_code -> Nullable<Int4>,
|
||||
#[max_length = 255]
|
||||
mode_destination -> Nullable<Varchar>,
|
||||
mode_destID -> Nullable<Int4>,
|
||||
#[max_length = 255]
|
||||
mode_desc -> Nullable<Varchar>,
|
||||
#[max_length = 255]
|
||||
mode_timetablePeriod -> Nullable<Varchar>,
|
||||
#[max_length = 50]
|
||||
diva_branch -> Nullable<Varchar>,
|
||||
#[max_length = 50]
|
||||
diva_line -> Nullable<Varchar>,
|
||||
#[max_length = 50]
|
||||
diva_supplement -> Nullable<Varchar>,
|
||||
#[max_length = 50]
|
||||
diva_dir -> Nullable<Varchar>,
|
||||
#[max_length = 50]
|
||||
diva_project -> Nullable<Varchar>,
|
||||
#[max_length = 50]
|
||||
diva_network -> Nullable<Varchar>,
|
||||
#[max_length = 255]
|
||||
diva_stateless -> Nullable<Varchar>,
|
||||
diva_tripCode -> Nullable<Int4>,
|
||||
#[max_length = 255]
|
||||
diva_operator -> Nullable<Varchar>,
|
||||
#[max_length = 50]
|
||||
diva_opPublicCode -> Nullable<Varchar>,
|
||||
#[max_length = 50]
|
||||
diva_opCode -> Nullable<Varchar>,
|
||||
diva_Vf -> Nullable<Date>,
|
||||
diva_vTo -> Nullable<Date>,
|
||||
#[max_length = 50]
|
||||
diva_lineDisplay -> Nullable<Varchar>,
|
||||
meta_lastModificationDate -> Nullable<Timestamp>,
|
||||
}
|
||||
}
|
||||
|
||||
diesel::table! {
|
||||
station_hints (infoLinkURL) {
|
||||
#[max_length = 255]
|
||||
infoLinkURL -> Varchar,
|
||||
#[max_length = 255]
|
||||
infoLinkText -> Nullable<Varchar>,
|
||||
#[max_length = 2055]
|
||||
infoText -> Nullable<Varchar>,
|
||||
}
|
||||
}
|
||||
|
||||
diesel::table! {
|
||||
stop_lists (input) {
|
||||
input -> Int4,
|
||||
#[max_length = 255]
|
||||
point_dm -> Nullable<Varchar>,
|
||||
#[max_length = 255]
|
||||
point_type -> Nullable<Varchar>,
|
||||
#[max_length = 255]
|
||||
point_name -> Nullable<Varchar>,
|
||||
#[max_length = 255]
|
||||
point_stateless -> Nullable<Varchar>,
|
||||
point_stopId -> Nullable<Int4>,
|
||||
#[max_length = 255]
|
||||
point_anytype -> Nullable<Varchar>,
|
||||
point_sort -> Nullable<Int4>,
|
||||
point_quality -> Nullable<Int4>,
|
||||
point_best -> Nullable<Int4>,
|
||||
#[max_length = 255]
|
||||
point_object -> Nullable<Varchar>,
|
||||
point_ref_id -> Nullable<Int4>,
|
||||
#[max_length = 50]
|
||||
point_ref_gid -> Nullable<Varchar>,
|
||||
point_ref_omc -> Nullable<Int4>,
|
||||
point_ref_placeID -> Nullable<Int4>,
|
||||
#[max_length = 50]
|
||||
point_ref_place -> Nullable<Varchar>,
|
||||
#[max_length = 50]
|
||||
point_ref_coords -> Nullable<Varchar>,
|
||||
itdOdvAssignedStops_stopid -> Nullable<Int4>,
|
||||
#[max_length = 255]
|
||||
itdOdvAssignedStops_name -> Nullable<Varchar>,
|
||||
itdOdvAssignedStops_x -> Nullable<Float8>,
|
||||
itdOdvAssignedStops_y -> Nullable<Float8>,
|
||||
#[max_length = 255]
|
||||
itdOdvAssignedStops_mapName -> Nullable<Varchar>,
|
||||
#[max_length = 255]
|
||||
itdOdvAssignedStops_value -> Nullable<Varchar>,
|
||||
#[max_length = 255]
|
||||
itdOdvAssignedStops_place -> Nullable<Varchar>,
|
||||
#[max_length = 255]
|
||||
itdOdvAssignedStops_nameWithPlace -> Nullable<Varchar>,
|
||||
itdOdvAssignedStops_distanceTime -> Nullable<Int4>,
|
||||
itdOdvAssignedStops_isTransferStop -> Nullable<Int4>,
|
||||
itdOdvAssignedStops_vm -> Nullable<Int4>,
|
||||
#[max_length = 255]
|
||||
itdOdvAssignedStops_gid -> Nullable<Varchar>,
|
||||
meta_lastModificationDate -> Nullable<Timestamp>,
|
||||
}
|
||||
}
|
||||
|
||||
diesel::joinable!(arrivals -> depature_requests (depatureRequestId));
|
||||
diesel::joinable!(depature_requests -> stop_lists (stopid));
|
||||
diesel::joinable!(depature_requeststation_hints -> depature_requests (depatureRequestId));
|
||||
diesel::joinable!(depature_requeststation_hints -> station_hints (infoLinkUrl));
|
||||
diesel::joinable!(serving_line_depature_requests -> depature_requests (depatureRequestId));
|
||||
diesel::joinable!(serving_line_depature_requests -> serving_lines (servingLineId));
|
||||
|
||||
diesel::allow_tables_to_appear_in_same_query!(
|
||||
arrivals,
|
||||
depature_requests,
|
||||
depature_requeststation_hints,
|
||||
serving_line_depature_requests,
|
||||
serving_lines,
|
||||
station_hints,
|
||||
stop_lists,
|
||||
);
|
Loading…
Add table
Reference in a new issue