Commit a6264a68 authored by Emmanuel Raviart's avatar Emmanuel Raviart

Improve source code using clippy.

parent d439cea9
Pipeline #107146 passed with stage
in 2 minutes and 48 seconds
......@@ -2,6 +2,7 @@
name = "tricoteuses_api_assemblee_config"
version = "0.1.0"
authors = ["Emmanuel Raviart <emmanuel@raviart.com>"]
edition = "2018"
[dependencies]
serde = "1"
......
......@@ -2,6 +2,7 @@
name = "tricoteuses_api_assemblee_data"
version = "0.1.0"
authors = ["Emmanuel Raviart <emmanuel@raviart.com>"]
edition = "2018"
[dependencies]
chrono = { version = "0.4", features = ["serde"] }
......
use acteurs::Acteur;
use agendas::Reunion;
use chrono::{Date, DateTime, FixedOffset};
use commun::{Codier, EmptyChoice, InfoJo, Rapporteur};
use contexts::Context;
use mandats::Mandat;
use organes::Organe;
use points_odj::PointOdj;
use scrutins::Scrutin;
use serde_utils::{map_to_vec, str_to_vec};
use std::cmp;
use textes_legislatifs::Document;
use crate::acteurs::Acteur;
use crate::agendas::Reunion;
use crate::commun::{Codier, EmptyChoice, InfoJo, Rapporteur};
use crate::contexts::Context;
use crate::mandats::Mandat;
use crate::organes::Organe;
use crate::points_odj::PointOdj;
use crate::scrutins::Scrutin;
use crate::serde_utils::{map_to_vec, str_to_vec};
use crate::textes_legislatifs::Document;
#[derive(Clone, Debug, Deserialize)]
#[serde(tag = "@xsi:type")]
......@@ -705,7 +706,7 @@ graphql_object!(ActeurInitiateur: Context |&self| {
None => None,
Some(ref acteur) => {
for mandat in &acteur.mandats.mandats {
if mandat.uid() == &self.mandat_ref {
if mandat.uid() == self.mandat_ref {
return Some(mandat)
}
}
......@@ -715,7 +716,7 @@ graphql_object!(ActeurInitiateur: Context |&self| {
}
field mandat_ref() -> &str {
return &self.mandat_ref
&self.mandat_ref
}
});
......@@ -1986,7 +1987,7 @@ impl Etape {
pub fn index_actes_legislatifs(&mut self, index: &mut i32) {
let mut actes_indexes: Vec<i32> = Vec::new();
if let Some(ref mut actes_legislatifs) = self.actes_legislatifs {
for mut acte in &mut actes_legislatifs.actes {
for acte in &mut actes_legislatifs.actes {
actes_indexes.push(*index);
*index += 1;
if let ActeLegislatif::Etape(ref mut etape) = acte {
......
use commun::{Ident, Uid};
use contexts::Context;
use mandats::{Mandat, MandatTrait, Mandats};
use organes::{GroupePolitique, Organe, OrganeParlementaire};
use photos::PhotoDepute;
use types_organes::CodeTypeOrgane;
use crate::commun::{Ident, Uid};
use crate::contexts::Context;
use crate::mandats::{Mandat, MandatTrait, Mandats};
use crate::organes::{GroupePolitique, Organe, OrganeParlementaire};
use crate::photos::PhotoDepute;
use crate::types_organes::CodeTypeOrgane;
#[derive(Debug, Deserialize)]
#[serde(deny_unknown_fields)]
......@@ -65,16 +65,16 @@ impl Acteur {
.mandats
.mandats
.iter()
.filter_map(|mandat| {
let date: &str = date.as_ref();
.filter(|mandat| {
let date: &str = date;
if date >= mandat.date_debut() {
match mandat.date_fin() {
None => Some(mandat),
Some(ref date_fin) if date <= date_fin => Some(mandat),
_ => None,
None => true,
Some(ref date_fin) if date <= date_fin => true,
_ => false,
}
} else {
None
false
}
})
.collect::<Vec<&Mandat>>(),
......@@ -118,17 +118,11 @@ graphql_object!(Acteur: Context |&self| {
}
field photo() -> Option<&PhotoDepute> {
match &self.photo {
None => None,
Some(ref photo) => Some(photo),
}
self.photo.as_ref()
}
field profession() -> Option<&Profession> {
match &self.profession {
None => None,
Some(ref profession) => Some(profession),
}
self.profession.as_ref()
}
field uid() -> &str {
......
use acteurs::Acteurs;
use commun::XmlNamespace;
use organes::Organes;
use crate::acteurs::Acteurs;
use crate::commun::XmlNamespace;
use crate::organes::Organes;
#[derive(Debug, Deserialize)]
#[serde(deny_unknown_fields)]
......
use chrono::{DateTime, FixedOffset};
use acteurs::Acteur;
use commun::{CycleDeVie, EmptyChoice, Ident, ListePays, Uid, XmlNamespace};
use contexts::Context;
use organes::Organe;
use points_odj::{PointOdj, PointsOdj};
use serde_utils::{map_to_vec, str_to_bool, str_to_option_bool, str_to_vec};
use crate::acteurs::Acteur;
use crate::commun::{CycleDeVie, EmptyChoice, Ident, ListePays, Uid, XmlNamespace};
use crate::contexts::Context;
use crate::organes::Organe;
use crate::points_odj::{PointOdj, PointsOdj};
use crate::serde_utils::{map_to_vec, str_to_bool, str_to_option_bool, str_to_vec};
#[derive(Clone, Debug, Deserialize)]
#[serde(deny_unknown_fields)]
......
use acteurs::Acteur;
use commun::{EmptyChoice, XmlNamespace};
use contexts::Context;
use organes::Organe;
use serde_utils::{map_to_vec, str_to_bool, str_to_option_bool, str_to_vec};
use textes_legislatifs::Document;
use crate::acteurs::Acteur;
use crate::commun::{EmptyChoice, XmlNamespace};
use crate::contexts::Context;
use crate::organes::Organe;
use crate::serde_utils::{map_to_vec, str_to_bool, str_to_option_bool, str_to_vec};
use crate::textes_legislatifs::Document;
#[derive(Debug, Deserialize, GraphQLObject)]
#[serde(deny_unknown_fields)]
......
// use actes_legislatifs::ActeLegislatif;
use dossiers_legislatifs::ExportJsonWrapper;
// use crate::actes_legislatifs::ActeLegislatif;
use crate::dossiers_legislatifs::ExportJsonWrapper;
pub fn check_data(dossiers_legislatifs_wrapper: &ExportJsonWrapper) {
for dossier in &dossiers_legislatifs_wrapper
......@@ -7,14 +7,11 @@ pub fn check_data(dossiers_legislatifs_wrapper: &ExportJsonWrapper) {
.dossiers_legislatifs
.dossiers
{
assert!(
dossier
.dossier_parlementaire
.actes_legislatifs()
.actes
.len()
>= 1
);
assert!(!dossier
.dossier_parlementaire
.actes_legislatifs()
.actes
.is_empty());
// let max_depth = max_depth_actes_legislatifs(dossier_parlementaire.actes_legislatifs().actes);
// assert!(max_depth <= 4, "Profondeur maximale des actes législatifs du dossier parlementaire \"{}\" = {}", dossier_parlementaire.titre_dossier().titre, max_depth);
}
......
use acteurs::Acteur;
use contexts::Context;
use serde_utils::str_to_vec;
use textes_legislatifs::Document;
use crate::acteurs::Acteur;
use crate::contexts::Context;
use crate::serde_utils::str_to_vec;
use crate::textes_legislatifs::Document;
#[derive(Clone, Debug, Deserialize, GraphQLObject)]
#[serde(deny_unknown_fields)]
......
use acteurs::Acteur;
use acteurs_et_organes;
use agendas::{self, Reunion};
use amendements::{self, Amendement, TexteLeg};
use chrono::{DateTime, Utc};
use dossiers_legislatifs::{self, DossierParlementaire};
use juniper;
use organes::Organe;
use scrutins::{self, Scrutin};
use std::collections::HashMap;
use std::mem;
use textes_legislatifs::Document;
use crate::acteurs::Acteur;
use crate::acteurs_et_organes;
use crate::agendas::{self, Reunion};
use crate::amendements::{self, Amendement, TexteLeg};
use crate::dossiers_legislatifs::{self, DossierParlementaire};
use crate::organes::Organe;
use crate::scrutins::{self, Scrutin};
use crate::textes_legislatifs::Document;
pub struct Context {
pub acteur_by_uid: HashMap<String, *const Acteur>,
......@@ -36,21 +36,19 @@ impl Context {
pub fn get_acteur_at_uid(&self, uid: &str) -> Option<&Acteur> {
self.acteur_by_uid
.get(&uid.to_string())
.map(|acteur| unsafe { mem::transmute::<*const Acteur, &Acteur>(*acteur) })
.map(|acteur| unsafe { &*(*acteur) })
}
pub fn get_amendement_at_uid(&self, uid: &str) -> Option<&Amendement> {
self.amendement_by_uid
.get(&uid.to_string())
.map(|amendement| unsafe {
mem::transmute::<*const Amendement, &Amendement>(*amendement)
})
.map(|amendement| unsafe { &*(*amendement) })
}
pub fn get_document_at_uid(&self, uid: &str) -> Option<&Document> {
self.document_by_uid
.get(&uid.to_string())
.map(|document| unsafe { mem::transmute::<*const Document, &Document>(*document) })
.map(|document| unsafe { &*(*document) })
}
pub fn get_dossier_parlementaire_at_segment(
......@@ -59,9 +57,7 @@ impl Context {
) -> Option<&DossierParlementaire> {
self.dossier_parlementaire_by_segment
.get(&segment.to_string())
.map(|dossier| unsafe {
mem::transmute::<*const DossierParlementaire, &DossierParlementaire>(*dossier)
})
.map(|dossier| unsafe { &*(*dossier) })
}
pub fn get_dossier_parlementaire_at_signet_senat(
......@@ -70,36 +66,32 @@ impl Context {
) -> Option<&DossierParlementaire> {
self.dossier_parlementaire_by_signet_senat
.get(&signet_senat.to_string())
.map(|dossier| unsafe {
mem::transmute::<*const DossierParlementaire, &DossierParlementaire>(*dossier)
})
.map(|dossier| unsafe { &*(*dossier) })
}
pub fn get_dossier_parlementaire_at_uid(&self, uid: &str) -> Option<&DossierParlementaire> {
self.dossier_parlementaire_by_uid
.get(&uid.to_string())
.map(|dossier| unsafe {
mem::transmute::<*const DossierParlementaire, &DossierParlementaire>(*dossier)
})
.map(|dossier| unsafe { &*(*dossier) })
}
pub fn get_organe_at_uid(&self, uid: &str) -> Option<&Organe> {
self.organe_by_uid
.get(&uid.to_string())
.map(|organe| unsafe { mem::transmute::<*const Organe, &Organe>(*organe) })
.map(|organe| unsafe { &*(*organe) })
}
pub fn get_reunion_at_uid(&self, uid: &str) -> Option<&Reunion> {
self.reunion_by_uid
.get(&uid.to_string())
.map(|reunion| unsafe { mem::transmute::<*const Reunion, &Reunion>(*reunion) })
.map(|reunion| unsafe { &*(*reunion) })
}
pub fn get_reunions_at_date(&self, date: &str) -> Option<&Vec<&Reunion>> {
self.reunions_by_date
.get(&date.to_string())
.map(|reunions| unsafe {
mem::transmute::<&Vec<*const Reunion>, &Vec<&Reunion>>(reunions)
&*(reunions as *const Vec<*const agendas::Reunion> as *const Vec<&agendas::Reunion>)
})
}
......@@ -107,20 +99,20 @@ impl Context {
self.reunions_by_dossier_uid
.get(&id.to_string())
.map(|reunions| unsafe {
mem::transmute::<&Vec<*const Reunion>, &Vec<&Reunion>>(reunions)
&*(reunions as *const Vec<*const agendas::Reunion> as *const Vec<&agendas::Reunion>)
})
}
pub fn get_scrutin_at_uid(&self, uid: &str) -> Option<&Scrutin> {
self.scrutin_by_uid
.get(&uid.to_string())
.map(|scrutin| unsafe { mem::transmute::<*const Scrutin, &Scrutin>(*scrutin) })
.map(|scrutin| unsafe { &*(*scrutin) })
}
pub fn get_texte_leg_at_uid(&self, uid: &str) -> Option<&TexteLeg> {
self.texte_leg_by_uid
.get(&uid.to_string())
.map(|texte_leg| unsafe { mem::transmute::<*const TexteLeg, &TexteLeg>(*texte_leg) })
.map(|texte_leg| unsafe { &*(*texte_leg) })
}
}
......
use actes_legislatifs::{ActeLegislatif, ActesLegislatifs, Initiateur};
use chrono::{Date, FixedOffset};
use commun::{Indexation, Rapporteur, XmlNamespace};
use contexts::Context;
use organes::Organe;
use serde_utils::map_to_vec;
use std::cmp;
use textes_legislatifs::{Document, TextesLegislatifs};
use crate::actes_legislatifs::{ActeLegislatif, ActesLegislatifs, Initiateur};
use crate::commun::{Indexation, Rapporteur, XmlNamespace};
use crate::contexts::Context;
use crate::organes::Organe;
use crate::serde_utils::map_to_vec;
use crate::textes_legislatifs::{Document, TextesLegislatifs};
#[derive(Clone, Copy, Debug, Deserialize, GraphQLEnum)]
pub enum CauseFusionDossier {
......@@ -473,7 +474,7 @@ impl DossierParlementaire {
}) => {
let mut actes_indexes: Vec<i32> = Vec::new();
let mut index: i32 = 0;
for mut acte in &mut actes_legislatifs.actes {
for acte in &mut actes_legislatifs.actes {
actes_indexes.push(index);
index += 1;
if let ActeLegislatif::Etape(ref mut etape) = acte {
......
......@@ -32,23 +32,24 @@ mod serde_utils;
mod textes_legislatifs;
mod types_organes;
pub use acteurs::Acteur;
pub use agendas::Reunion;
pub use amendements::{Amendement, TexteLeg, TextesEtAmendements};
use chrono::prelude::Utc;
use config::{Config, Verbosity};
pub use contexts::{Context, Statut};
pub use dossiers_legislatifs::DossierParlementaire;
pub use mandats::Mandat;
pub use organes::Organe;
pub use photos::PhotoDepute;
use regex::Regex;
pub use scrutins::Scrutin;
use std::collections::HashMap;
use std::fs::{self, File};
use std::path::Path;
pub use textes_legislatifs::Document;
pub use types_organes::{CodeTypeOrgane, FonctionOrgane, FONCTIONS_ORGANES};
pub use crate::acteurs::Acteur;
pub use crate::agendas::Reunion;
pub use crate::amendements::{Amendement, TexteLeg, TextesEtAmendements};
use crate::config::{Config, Verbosity};
pub use crate::contexts::{Context, Statut};
pub use crate::dossiers_legislatifs::DossierParlementaire;
pub use crate::mandats::Mandat;
pub use crate::organes::Organe;
pub use crate::photos::PhotoDepute;
pub use crate::scrutins::Scrutin;
pub use crate::textes_legislatifs::Document;
pub use crate::types_organes::{CodeTypeOrgane, FonctionOrgane, FONCTIONS_ORGANES};
pub struct EnabledDatasets {
pub acteurs_et_organes: bool,
......@@ -242,13 +243,13 @@ pub fn load(
}
// Index recursive structures to allow them to be flattened for GraphQL transmission.
for mut wrapper in &mut dossiers_legislatifs_wrappers {
for mut document in &mut wrapper.export.textes_legislatifs.documents {
for wrapper in &mut dossiers_legislatifs_wrappers {
for document in &mut wrapper.export.textes_legislatifs.documents {
let mut index: i32 = 0;
document.index_document(&mut index);
}
for mut dossier in &mut wrapper.export.dossiers_legislatifs.dossiers {
for dossier in &mut wrapper.export.dossiers_legislatifs.dossiers {
dossier.dossier_parlementaire.index_actes_legislatifs();
}
}
......@@ -354,7 +355,7 @@ pub fn load(
reunions_by_date
.entry(format!("{}", reunion.timestamp_debut.format("%Y-%m-%d")))
.and_modify(|reunions| reunions.push(reunion))
.or_insert(vec![reunion]);
.or_insert_with(|| vec![reunion]);
}
}
......@@ -371,7 +372,7 @@ pub fn load(
reunions_by_dossier_uid
.entry(dossier_ref.clone())
.and_modify(|reunions| reunions.push(reunion))
.or_insert(vec![reunion]);
.or_insert_with(|| vec![reunion]);
}
}
}
......
use acteurs::Acteur;
use commun::EmptyChoice;
use contexts::Context;
use organes::Organe;
use serde_utils::{map_to_vec, str_to_bool, str_to_vec};
use types_organes::CodeTypeOrgane;
use crate::acteurs::Acteur;
use crate::commun::EmptyChoice;
use crate::contexts::Context;
use crate::organes::Organe;
use crate::serde_utils::{map_to_vec, str_to_bool, str_to_vec};
use crate::types_organes::CodeTypeOrgane;
#[derive(Clone, Debug, Deserialize, GraphQLObject)]
#[serde(deny_unknown_fields)]
......
use commun::{EmptyChoice, ListePays};
use contexts::Context;
use types_organes::CodeTypeOrgane;
use crate::commun::{EmptyChoice, ListePays};
use crate::contexts::Context;
use crate::types_organes::CodeTypeOrgane;
#[derive(Clone, Debug, Deserialize)]
#[serde(deny_unknown_fields)]
......
use commun::{CycleDeVie, EmptyChoice};
use contexts::Context;
use dossiers_legislatifs::DossierParlementaire;
use serde_utils::{map_to_vec, str_to_bool, str_to_vec};
use crate::commun::{CycleDeVie, EmptyChoice};
use crate::contexts::Context;
use crate::dossiers_legislatifs::DossierParlementaire;
use crate::serde_utils::{map_to_vec, str_to_bool, str_to_vec};
#[derive(Clone, Debug, Deserialize)]
#[serde(deny_unknown_fields)]
......
use commun::{EmptyChoice, XmlNamespace};
use contexts::Context;
use serde_utils::{map_to_vec, str_to_option_bool};
use crate::commun::{EmptyChoice, XmlNamespace};
use crate::contexts::Context;
use crate::serde_utils::{map_to_vec, str_to_option_bool};
#[derive(Clone, Copy, Debug, Deserialize, GraphQLEnum)]
pub enum CausePositionVote {
......
use acteurs::Acteur;
use chrono::{DateTime, FixedOffset};
use commun::{EmptyChoice, Indexation};
use contexts::Context;
use dossiers_legislatifs::DossierParlementaire;
use mandats::Mandat;
use organes::Organe;
use serde_utils::{map_to_vec, str_to_bool};
use crate::acteurs::Acteur;
use crate::commun::{EmptyChoice, Indexation};
use crate::contexts::Context;
use crate::dossiers_legislatifs::DossierParlementaire;
use crate::mandats::Mandat;
use crate::organes::Organe;
use crate::serde_utils::{map_to_vec, str_to_bool};
#[derive(Debug, Deserialize)]
#[serde(deny_unknown_fields)]
......@@ -36,7 +37,7 @@ pub struct AccordInternational {
impl AccordInternational {
pub fn index_divisions(&mut self, index: &mut i32, documents_indexes: &mut Vec<i32>) {
if let Some(ref mut divisions) = self.divisions {
for mut division in &mut divisions.divisions {
for division in &mut divisions.divisions {
documents_indexes.push(*index);
division.index_document(index);
}
......@@ -262,7 +263,7 @@ pub struct AvisConseilEtat {
impl AvisConseilEtat {
pub fn index_divisions(&mut self, index: &mut i32, documents_indexes: &mut Vec<i32>) {
if let Some(ref mut divisions) = self.divisions {
for mut division in &mut divisions.divisions {
for division in &mut divisions.divisions {
documents_indexes.push(*index);
division.index_document(index);
}
......@@ -1020,7 +1021,7 @@ pub struct DocumentEtudeImpact {
impl DocumentEtudeImpact {
pub fn index_divisions(&mut self, index: &mut i32, documents_indexes: &mut Vec<i32>) {
if let Some(ref mut divisions) = self.divisions {
for mut division in &mut divisions.divisions {
for division in &mut divisions.divisions {
documents_indexes.push(*index);
division.index_document(index);
}
......@@ -1196,7 +1197,7 @@ pub struct RapportParlementaire {
impl RapportParlementaire {
pub fn index_divisions(&mut self, index: &mut i32, documents_indexes: &mut Vec<i32>) {
if let Some(ref mut divisions) = self.divisions {
for mut division in &mut divisions.divisions {
for division in &mut divisions.divisions {
documents_indexes.push(*index);
division.index_document(index);
}
......@@ -1329,7 +1330,7 @@ pub struct TexteLoi {
impl TexteLoi {
pub fn index_divisions(&mut self, index: &mut i32, documents_indexes: &mut Vec<i32>) {
if let Some(ref mut divisions) = self.divisions {
for mut division in &mut divisions.divisions {
for division in &mut divisions.divisions {
documents_indexes.push(*index);
division.index_document(index);
}
......
......@@ -121,7 +121,7 @@ pub struct TypeOrgane {
libelle_pluriel: &'static str,
}
pub const FONCTIONS_ORGANES: &'static [&'static FonctionOrgane] = &[
pub const FONCTIONS_ORGANES: &[&FonctionOrgane] = &[
&FonctionOrgane {
code: CodeFonctionOrgane::AppartenancePolitique,
libelle: "Appartenance politique",
......
......@@ -2,6 +2,7 @@
name = "tricoteuses_api_assemblee_open_data_fetcher"
version = "0.1.0"
authors = ["Emmanuel Raviart <emmanuel@raviart.com>"]
edition = "2018"
[dependencies]
clap = "2.32"
......
......@@ -122,7 +122,7 @@ fn main() {
let uid = reunion["uid"].as_str().unwrap();
let captures = reunion_uid_regex
.captures(&uid)
.expect(&format!("Unexpected uid for reunion: {}", uid));
.unwrap_or_else(|| panic!("Unexpected uid for reunion: {}", uid));
let organe_dir = reunions_dir.join(captures[1].to_string());
if !organe_dir.exists() {
fs::create_dir(&organe_dir).expect("Creation of organe directory failed");
......
......@@ -2,6 +2,7 @@
name = "tricoteuses_api_assemblee_photos_fetcher"
version = "0.1.0"
authors = ["Emmanuel Raviart <emmanuel@raviart.com>"]
edition = "2018"
[dependencies]
clap = "2.32"
......
......@@ -11,7 +11,6 @@ use data::{Acteur, CodeTypeOrgane, EnabledDatasets, Mandat, PhotoDepute, NO_DATA
use rayon::prelude::*;
use std::collections::HashMap;
use std::fs::{self, File};
use std::mem;
use std::path::Path;
use std::process::Command;
......@@ -71,7 +70,7 @@ fn main() {
for acteur in context
.acteur_by_uid
.values()
.map(|acteur| unsafe { mem::transmute::<*const Acteur, &Acteur>(*acteur) })
.map(|acteur| unsafe { &*(*acteur) })
{
for mandat in acteur.mandats(Some(&chrono::Local::today().format("%Y-%m-%d").to_string())) {
if let Mandat::MandatParlementaire(mandat_parlementaire) = mandat {
......
......@@ -2,6 +2,7 @@
name = "tricoteuses_api_assemblee"
version = "0.1.0"
authors = ["Emmanuel Raviart <emmanuel@raviart.com>"]
edition = "2018"
[dependencies]
chrono = { version = "0.4", features = ["serde"] }
......
......@@ -28,7 +28,6 @@ use rocket::http::Method;
use rocket::response::{content, NamedFile};
use rocket::State;
use rocket_cors::AllowedOrigins;
use std::mem;
use std::path::{Path, PathBuf};
struct Query;
......@@ -41,15 +40,15 @@ graphql_object!(Query: Context |&self| {
field acteurs(&executor) -> FieldResult<Vec<&Acteur>> {
let acteurs: Vec<&Acteur> = executor.context().acteur_by_uid
.values()
.map(|acteur| unsafe { mem::transmute::<*const Acteur, &Acteur>(*acteur) })
.map(|acteur| unsafe { &*(*acteur) })
.collect();
Ok(acteurs)
}
field agenda(&executor, acteur_uid: Option<String>, date_debut: Option<String>, date_fin: Option<String>) -> FieldResult<Vec<&Reunion>> {
let context = executor.context();
let date_debut = date_debut.map(|date_debut| DateTime::parse_from_rfc3339(&date_debut).expect(&format!("Invalid date & time: {}", date_debut)).date());
let date_fin = date_fin.map(|date_fin| DateTime::parse_from_rfc3339(&date_fin).expect(&format!("Invalid date & time: {}", date_fin)).date());
let date_debut = date_debut.map(|date_debut| DateTime::parse_from_rfc3339(&date_debut).unwrap_or_else(|_| panic!("Invalid date & time: {}", date_debut)).date());
let date_fin = date_fin.map(|date_fin| DateTime::parse_from_rfc3339(&date_fin).unwrap_or_else(|_| panic!("Invalid date & time: {}", date_fin)).date());
let dates_debut_et_fin = match (date_debut, date_fin) {
(None, None) => None,
(None, Some(date_fin)) => Some((date_fin, date_fin)),
......@@ -326,7 +325,7 @@ graphql_object!(Query: Context |&self| {
for acteur in executor.context().acteur_by_uid
.values()
.map(|acteur| unsafe { mem::transmute::<*const Acteur, &Acteur>(*acteur) })
.map(|acteur| unsafe { &*(*acteur) })
{
for mandat in acteur.mandats(date) {
if let Mandat::MandatParlementaire(mandat_parlementaire) = mandat {
......@@ -378,7 +377,7 @@ graphql_object!(Query: Context |&self| {
}
field dossiers_parlementaires_futurs(&executor, date: String) -> FieldResult<Vec<&DossierParlementaire>> {
let date_time = DateTime::parse_from_rfc3339(&date).expect(&format!("Invalid date & time: {}", date));
let date_time = DateTime::parse_from_rfc3339(&date).unwrap_or_else(|_| panic!("Invalid date & time: {}", date));
let date = date_time.date();
let mut dossiers_parlementaires: Vec<&DossierParlementaire> = Vec::new();
for wrapper in &executor.context().dossiers_legislatifs_wrappers {
......@@ -426,7 +425,7 @@ graphql_object!(Query: Context |&self| {
}
field dossiers_parlementaires_prochains(&executor, date: String) -> FieldResult<Vec<&DossierParlementaire>> {
let date_time = DateTime::parse_from_rfc3339(&date).expect(&format!("Invalid date & time: {}", date));
let date_time = DateTime::parse_from_rfc3339(&date).unwrap_or_else(|_| panic!("Invalid date & time: {}", date));
let date = date_time.date();
let mut dossiers_parlementaires: Vec<&DossierParlementaire> = Vec::new();
for wrapper in &executor.context().dossiers_legislatifs_wrappers {
......@@ -442,7 +441,7 @@ graphql_object!(Query: Context |&self| {
}
field dossiers_parlementaires_recents(&executor, date: String) -> FieldResult<Vec<&DossierParlementaire>> {
let date_time = DateTime::parse_from_rfc3339(&date).expect(&format!("Invalid date & time: {}", date));
let date_time = DateTime::parse_from_rfc3339(&date).unwrap_or_else(|_| panic!("Invalid date & time: {}", date));
let date = date_time.date();
let mut dossiers_parlementaires: Vec<&DossierParlementaire> = Vec::new();
for wrapper in &executor.context().dossiers_legislatifs_wrappers {
......@@ -472,7 +471,7 @@ graphql_object!(Query: Context |&self| {
field organes(&executor) -> FieldResult<Vec<&Organe>> {
let organes: Vec<&Organe> = executor.context().organe_by_uid
.values()
.map(|organe| unsafe { mem::transmute::<*const Organe, &Organe>(*organe) })
.map(|organe| unsafe { &*(*organe) })
.collect();
Ok(organes)
}
......@@ -598,7 +597,7 @@ fn main() {
);
assert!(failed_origins.is_empty());
let cors = rocket_cors::Cors {
allowed_origins: allowed_origins,
allowed_origins,
allowed_methods: vec![Method::Get, Method::Post]
.into_iter()
.map(From::from)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment