Commit 44dc25fd authored by Emmanuel Raviart's avatar Emmanuel Raviart

Improve GraphQL of "amendements" & "textes législatifs".

parent 3e30dd7c
Pipeline #100008 passed with stage
in 2 minutes and 22 seconds
......@@ -130,8 +130,16 @@ graphql_object!(Amendement: Context |&self| {
&self.pointeur_fragment_texte
}
field representations() -> &Option<Representations> {
&self.representations
field representations(&executor) -> Vec<&Representation> {
match self.representations {
None => vec![],
Some(ref representations) => {
let context = &executor.context();
representations.representations
.iter()
.collect()
},
}
}
field seance_discussion() -> Option<&str> {
......@@ -402,12 +410,11 @@ pub struct Contenu {
pub document_uri: Option<String>,
}
#[derive(Debug, Deserialize, GraphQLObject)]
#[derive(Debug, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct Corps {
#[serde(rename = "annexeExposeSommaire")]
pub annexe_expose_sommaire: Option<EmptyChoice>,
#[serde(rename = "dispositif")]
pub dispositif: Option<String>,
#[serde(rename = "cartoucheDelaiDepotDepasse")]
pub cartouche_delai_depot_depasse: Option<String>,
......@@ -421,6 +428,41 @@ pub struct Corps {
pub total_cp: Option<TotalMontants>,
}
graphql_object!(Corps: Context |&self| {
field dispositif() -> Option<&str> {
match &self.dispositif {
None => None,
Some(ref s) => Some(s.as_str()),
}
}
field cartouche_delai_depot_depasse() -> Option<&str> {
match &self.cartouche_delai_depot_depasse {
None => None,
Some(ref s) => Some(s.as_str()),
}
}
field dispositif_amdt_credit() -> &Option<ListeProgrammes> {
&self.dispositif_amdt_credit
}
field expose_sommaire() -> Option<&str> {
match &self.expose_sommaire {
None => None,
Some(ref s) => Some(s.as_str()),
}
}
field total_ae() -> &Option<TotalMontants> {
&self.total_ae
}
field total_cp() -> &Option<TotalMontants> {
&self.total_cp
}
});
#[derive(Debug, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct Cosignataires {
......@@ -481,17 +523,39 @@ pub struct LignesCredits {
pub lignes_credits: Vec<LigneCredit>,
}
#[derive(Debug, Deserialize, GraphQLObject)]
#[derive(Debug, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct ListeProgrammes {
#[serde(rename = "listeProgrammes")]
pub liste_programmes: Option<Programme>,
pub liste_programmes: Option<Programmes>,
#[serde(rename = "totalAE")]
pub total_ae: Option<TotalMontants>,
#[serde(rename = "totalCP")]
pub total_cp: Option<TotalMontants>,
}
graphql_object!(ListeProgrammes: Context |&self| {
field liste_programmes(&executor) -> Vec<&Programme> {
match self.liste_programmes {
None => vec![],
Some(ref liste_programmes) => {
let context = &executor.context();
liste_programmes.programmes
.iter()
.collect()
},
}
}
field total_ae() -> &Option<TotalMontants> {
&self.total_ae
}
field total_cp() -> &Option<TotalMontants> {
&self.total_cp
}
});
#[derive(Debug, Deserialize, GraphQLObject)]
#[serde(deny_unknown_fields)]
pub struct LoiReference {
......@@ -534,37 +598,77 @@ pub struct PointeurFragmentTexte {
pub mission_visee: Option<MissionVisee>,
}
#[derive(Debug, Deserialize, GraphQLObject)]
#[derive(Debug, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct Programme {
#[serde(deserialize_with = "map_to_vec", rename = "programme")]
pub programme: Vec<ProgrammeObject>,
}
#[derive(Debug, Deserialize, GraphQLObject)]
#[serde(deny_unknown_fields)]
pub struct ProgrammeObject {
pub action: Option<String>,
#[serde(rename = "AE")]
pub ae: Option<Montants>,
#[serde(rename = "CP")]
pub cp: Option<Montants>,
#[serde(rename = "action")]
pub action: Option<String>,
#[serde(rename = "id")]
pub id: Option<String>,
pub libelle: Option<String>,
#[serde(rename = "lignesCredits")]
pub lignes_credits: Option<LignesCredits>,
}
graphql_object!(Programme: Context |&self| {
field action() -> Option<&str> {
match &self.action {
None => None,
Some(ref s) => Some(s.as_str()),
}
}
field ae() -> &Option<Montants> {
&self.ae
}
field cp() -> &Option<Montants> {
&self.cp
}
field id() -> Option<&str> {
match &self.id {
None => None,
Some(ref s) => Some(s.as_str()),
}
}
field libelle() -> Option<&str> {
match &self.libelle {
None => None,
Some(ref s) => Some(s.as_str()),
}
}
field lignes_credits(&executor) -> Vec<&LigneCredit> {
match self.lignes_credits {
None => vec![],
Some(ref lignes_credits) => {
let context = &executor.context();
lignes_credits.lignes_credits
.iter()
.collect()
},
}
}
});
#[derive(Debug, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct Programmes {
#[serde(deserialize_with = "map_to_vec", rename = "programme")]
pub programmes: Vec<Programme>,
}
#[derive(Debug, Deserialize, GraphQLObject)]
#[serde(deny_unknown_fields)]
pub struct Representation {
#[serde(rename = "contenu")]
pub contenu: Option<Contenu>,
#[serde(rename = "dateDispoRepresentation")]
pub date_dispo_representation: Option<String>,
#[serde(rename = "nom")]
pub nom: Option<String>,
pub offset: Option<EmptyChoice>,
#[serde(rename = "repSource")]
......@@ -575,11 +679,11 @@ pub struct Representation {
pub type_mime: TypeMime,
}
#[derive(Debug, Deserialize, GraphQLObject)]
#[derive(Debug, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct Representations {
#[serde(rename = "representation")]
pub representation: Option<Representation>,
#[serde(deserialize_with = "map_to_vec", rename = "representation")]
pub representations: Vec<Representation>,
}
#[derive(Debug, Deserialize, GraphQLObject)]
......@@ -722,7 +826,6 @@ pub struct TotalMontants {
pub montant_negatif: Option<String>,
#[serde(rename = "montantPositif")]
pub montant_positif: Option<String>,
#[serde(rename = "solde")]
pub solde: Option<String>,
}
......
......@@ -13,7 +13,7 @@ pub struct AccordInternational {
pub classification: Classification,
pub correction: Option<Correction>,
#[serde(rename = "cycleDeVie")]
pub cycle_de_vie: CycleDeVie,
pub cycle_de_vie: CycleDeVieDocument,
#[serde(rename = "denominationStructurelle")]
pub denomination_structurelle: String,
pub divisions: Option<Divisions>,
......@@ -42,7 +42,7 @@ graphql_object!(AccordInternational: Context |&self| {
&self.correction
}
field cycle_de_vie() -> &CycleDeVie {
field cycle_de_vie() -> &CycleDeVieDocument {
&self.cycle_de_vie
}
......@@ -215,7 +215,7 @@ pub struct AvisConseilEtat {
pub classification: Classification,
pub correction: Option<Correction>,
#[serde(rename = "cycleDeVie")]
pub cycle_de_vie: CycleDeVie,
pub cycle_de_vie: CycleDeVieDocument,
#[serde(rename = "denominationStructurelle")]
pub denomination_structurelle: String,
pub divisions: Option<Divisions>,
......@@ -244,7 +244,7 @@ graphql_object!(AvisConseilEtat: Context |&self| {
&self.correction
}
field cycle_de_vie() -> &CycleDeVie {
field cycle_de_vie() -> &CycleDeVieDocument {
&self.cycle_de_vie
}
......@@ -300,7 +300,7 @@ graphql_object!(AvisConseilEtat: Context |&self| {
#[derive(Debug, Deserialize, GraphQLObject)]
#[serde(deny_unknown_fields)]
pub struct Chrono {
pub struct ChronoDocument {
#[serde(rename = "dateCreation")]
date_creation: Option<DateTime<FixedOffset>>,
#[serde(rename = "dateDepot")]
......@@ -367,8 +367,8 @@ pub struct Cosignataires {
#[derive(Debug, Deserialize, GraphQLObject)]
#[serde(deny_unknown_fields)]
pub struct CycleDeVie {
pub chrono: Chrono,
pub struct CycleDeVieDocument {
pub chrono: ChronoDocument,
}
#[derive(Debug, Deserialize, GraphQLObject)]
......@@ -443,7 +443,7 @@ impl Document {
// }
// }
// pub fn cycle_de_vie(&self) -> &CycleDeVie {
// pub fn cycle_de_vie(&self) -> &CycleDeVieDocument {
// match *self {
// Document::AccordInternational(AccordInternational {
// ref cycle_de_vie, ..
......@@ -620,7 +620,7 @@ graphql_union!(Document: Context |&self| {
// self.correction()
// }
// field cycle_de_vie() -> &CycleDeVie {
// field cycle_de_vie() -> &CycleDeVieDocument {
// self.cycle_de_vie()
// }
......@@ -695,7 +695,7 @@ pub struct DocumentEtudeImpact {
pub classification: Classification,
pub correction: Option<Correction>,
#[serde(rename = "cycleDeVie")]
pub cycle_de_vie: CycleDeVie,
pub cycle_de_vie: CycleDeVieDocument,
#[serde(rename = "denominationStructurelle")]
pub denomination_structurelle: String,
pub divisions: Option<Divisions>,
......@@ -724,7 +724,7 @@ graphql_object!(DocumentEtudeImpact: Context |&self| {
&self.correction
}
field cycle_de_vie() -> &CycleDeVie {
field cycle_de_vie() -> &CycleDeVieDocument {
&self.cycle_de_vie
}
......@@ -825,7 +825,7 @@ pub struct RapportParlementaire {
pub classification: Classification,
pub correction: Option<Correction>,
#[serde(rename = "cycleDeVie")]
pub cycle_de_vie: CycleDeVie,
pub cycle_de_vie: CycleDeVieDocument,
#[serde(rename = "denominationStructurelle")]
pub denomination_structurelle: String,
pub divisions: Option<Divisions>,
......@@ -854,7 +854,7 @@ graphql_object!(RapportParlementaire: Context |&self| {
&self.correction
}
field cycle_de_vie() -> &CycleDeVie {
field cycle_de_vie() -> &CycleDeVieDocument {
&self.cycle_de_vie
}
......@@ -926,7 +926,7 @@ pub struct TexteLoi {
#[serde(rename = "coSignataires")]
pub cosignataires: Option<Cosignataires>,
#[serde(rename = "cycleDeVie")]
pub cycle_de_vie: CycleDeVie,
pub cycle_de_vie: CycleDeVieDocument,
#[serde(rename = "denominationStructurelle")]
pub denomination_structurelle: String,
#[serde(rename = "depotAmendements")]
......@@ -964,7 +964,7 @@ graphql_object!(TexteLoi: Context |&self| {
}
}
field cycle_de_vie() -> &CycleDeVie {
field cycle_de_vie() -> &CycleDeVieDocument {
&self.cycle_de_vie
}
......
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