use crate::db_object::{DBObject, OrderTypes};
use crate::df_world::{DBDFWorld, HistoricalEvent};
use crate::schema::historical_events_a_a;
use crate::DbConnection;
use df_st_core::fillable::{Fillable, Filler};
use df_st_core::item_count::ItemCount;
use df_st_derive::Fillable;
use diesel::expression_methods::ExpressionMethods;
use diesel::prelude::*;
use diesel::query_dsl::RunQueryDsl;
use failure::Error;
use std::collections::HashMap;
use std::hash::{Hash, Hasher};
#[derive(
Clone, Debug, AsChangeset, Identifiable, Associations, Queryable, Insertable, Fillable, Default,
)]
#[table_name = "historical_events_a_a"]
#[primary_key(he_id)]
#[belongs_to(HistoricalEvent, foreign_key = "he_id")]
pub struct HistoricalEventAA {
pub he_id: i32,
pub world_id: i32,
pub a_leader_hf_id: Option<i32>,
pub a_leadership_roll: Option<i32>,
pub a_squad_id: Option<i32>,
pub a_support_merc_en_id: Option<i32>,
pub a_tactician_hf_id: Option<i32>,
pub a_tactics_roll: Option<i32>,
pub abandoned: Option<bool>,
pub account_shift: Option<i32>,
pub acquirer_en_id: Option<i32>,
pub acquirer_hf_id: Option<i32>,
pub action: Option<String>,
pub actor_hf_id: Option<i32>,
pub agreement_id: Option<i32>,
pub allotment: Option<i32>,
pub allotment_index: Option<i32>,
pub ally_defense_bonus: Option<i32>,
pub appointer_hf_id: Option<i32>,
pub arresting_en_id: Option<i32>,
pub art_id: Option<i32>,
pub art_sub_id: Option<i32>,
pub artifact_id: Option<i32>,
pub attacker_civ_id: Option<i32>,
pub attacker_general_hf_id: Option<i32>,
pub attacker_hf_id: Option<i32>,
pub attacker_merc_en_id: Option<i32>,
pub abuse_type: Option<String>,
pub anon_3: Option<i32>,
pub anon_4: Option<i32>,
}
impl HistoricalEventAA {
pub fn new() -> Self {
Self::default()
}
}
impl DBObject<df_st_core::HistoricalEvent, HistoricalEventAA> for HistoricalEventAA {
fn add_missing_data_advanced(_core_world: &df_st_core::DFWorld, _world: &mut DBDFWorld) {
}
#[rustfmt::skip]
#[cfg(feature = "postgres")]
fn insert_into_db(conn: &DbConnection, historical_events_a_a: &[HistoricalEventAA]) {
use diesel::pg::upsert::excluded;
diesel::insert_into(historical_events_a_a::table)
.values(historical_events_a_a)
.on_conflict((
historical_events_a_a::he_id,
historical_events_a_a::world_id,
))
.do_update()
.set((
historical_events_a_a::a_leader_hf_id.eq(excluded(historical_events_a_a::a_leader_hf_id)),
historical_events_a_a::a_leadership_roll.eq(excluded(historical_events_a_a::a_leadership_roll)),
historical_events_a_a::a_squad_id.eq(excluded(historical_events_a_a::a_squad_id)),
historical_events_a_a::a_support_merc_en_id.eq(excluded(historical_events_a_a::a_support_merc_en_id)),
historical_events_a_a::a_tactician_hf_id.eq(excluded(historical_events_a_a::a_tactician_hf_id)),
historical_events_a_a::a_tactics_roll.eq(excluded(historical_events_a_a::a_tactics_roll)),
historical_events_a_a::abandoned.eq(excluded(historical_events_a_a::abandoned)),
historical_events_a_a::account_shift.eq(excluded(historical_events_a_a::account_shift)),
historical_events_a_a::acquirer_en_id.eq(excluded(historical_events_a_a::acquirer_en_id)),
historical_events_a_a::acquirer_hf_id.eq(excluded(historical_events_a_a::acquirer_hf_id)),
historical_events_a_a::action.eq(excluded(historical_events_a_a::action)),
historical_events_a_a::actor_hf_id.eq(excluded(historical_events_a_a::actor_hf_id)),
historical_events_a_a::agreement_id.eq(excluded(historical_events_a_a::agreement_id)),
historical_events_a_a::allotment.eq(excluded(historical_events_a_a::allotment)),
historical_events_a_a::allotment_index.eq(excluded(historical_events_a_a::allotment_index)),
historical_events_a_a::ally_defense_bonus.eq(excluded(historical_events_a_a::ally_defense_bonus)),
historical_events_a_a::appointer_hf_id.eq(excluded(historical_events_a_a::appointer_hf_id)),
historical_events_a_a::arresting_en_id.eq(excluded(historical_events_a_a::arresting_en_id)),
historical_events_a_a::art_id.eq(excluded(historical_events_a_a::art_id)),
historical_events_a_a::art_sub_id.eq(excluded(historical_events_a_a::art_sub_id)),
historical_events_a_a::artifact_id.eq(excluded(historical_events_a_a::artifact_id)),
historical_events_a_a::attacker_civ_id.eq(excluded(historical_events_a_a::attacker_civ_id)),
historical_events_a_a::attacker_general_hf_id.eq(excluded(historical_events_a_a::attacker_general_hf_id)),
historical_events_a_a::attacker_hf_id.eq(excluded(historical_events_a_a::attacker_hf_id)),
historical_events_a_a::attacker_merc_en_id.eq(excluded(historical_events_a_a::attacker_merc_en_id)),
historical_events_a_a::abuse_type.eq(excluded(historical_events_a_a::abuse_type)),
historical_events_a_a::anon_3.eq(excluded(historical_events_a_a::anon_3)),
historical_events_a_a::anon_4.eq(excluded(historical_events_a_a::anon_4)),
))
.execute(conn)
.expect("Error saving historical_events_a_a");
}
#[cfg(not(feature = "postgres"))]
fn insert_into_db(conn: &DbConnection, historical_events_a_a: &[HistoricalEventAA]) {
diesel::insert_into(historical_events_a_a::table)
.values(historical_events_a_a)
.execute(conn)
.expect("Error saving historical_events_a_a");
}
fn find_db_list(
_conn: &DbConnection,
_id_filter: HashMap<String, i32>,
_string_filter: HashMap<String, String>,
_offset: i64,
_limit: i64,
_order: Option<OrderTypes>,
_order_by: Option<String>,
_id_list: Option<Vec<i32>>,
) -> Result<Vec<HistoricalEventAA>, Error> {
Ok(vec![])
}
fn find_db_item(
conn: &DbConnection,
id_filter: HashMap<String, i32>,
) -> Result<Option<HistoricalEventAA>, Error> {
use crate::schema::historical_events_a_a::dsl::*;
let query = historical_events_a_a;
let query = query.filter(world_id.eq(id_filter.get("world_id").unwrap_or(&0)));
let query = query.filter(he_id.eq(id_filter.get("he_id").unwrap_or(&0)));
Ok(query.first::<HistoricalEventAA>(conn).optional()?)
}
fn match_field_by(field: String) -> String {
match field.as_ref() {
"a_leader_hf_id" => "a_leader_hf_id",
"a_leadership_roll" => "a_leadership_roll",
"a_squad_id" => "a_squad_id",
"a_support_merc_en_id" => "a_support_merc_en_id",
"a_tactician_hf_id" => "a_tactician_hf_id",
"a_tactics_roll" => "a_tactics_roll",
"abandoned" => "abandoned",
"account_shift" => "account_shift",
"acquirer_en_id" => "acquirer_en_id",
"acquirer_hf_id" => "acquirer_hf_id",
"action" => "action",
"actor_hf_id" => "actor_hf_id",
"agreement_id" => "agreement_id",
"allotment" => "allotment",
"allotment_index" => "allotment_index",
"ally_defense_bonus" => "ally_defense_bonus",
"appointer_hf_id" => "appointer_hf_id",
"arresting_en_id" => "arresting_en_id",
"art_id" => "art_id",
"art_sub_id" => "art_sub_id",
"artifact_id" => "artifact_id",
"attacker_civ_id" => "attacker_civ_id",
"attacker_general_hf_id" => "attacker_general_hf_id",
"attacker_hf_id" => "attacker_hf_id",
"attacker_merc_en_id" => "attacker_merc_en_id",
"abuse_type" => "abuse_type",
"anon_3" => "anon_3",
"anon_4" => "anon_4",
_ => "he_id",
}
.to_owned()
}
fn add_nested_items(
_conn: &DbConnection,
_db_list: &[HistoricalEventAA],
core_list: Vec<df_st_core::HistoricalEvent>,
) -> Result<Vec<df_st_core::HistoricalEvent>, Error> {
Ok(core_list)
}
fn get_count_from_db(
_conn: &DbConnection,
_id_filter: HashMap<String, i32>,
_string_filter: HashMap<String, String>,
_offset: u32,
_limit: u32,
_group_by_opt: Option<String>,
_id_list: Option<Vec<i32>>,
) -> Result<Vec<ItemCount>, Error> {
Ok(vec![])
}
}
#[rustfmt::skip]
impl Filler<HistoricalEventAA, df_st_core::HistoricalEvent> for HistoricalEventAA {
fn add_missing_data(&mut self, source: &df_st_core::HistoricalEvent) {
self.he_id.add_missing_data(&source.id);
self.a_leader_hf_id.add_missing_data(&source.a_leader_hf_id);
self.a_leadership_roll.add_missing_data(&source.a_leadership_roll);
self.a_squad_id.add_missing_data(&source.a_squad_id);
self.a_support_merc_en_id.add_missing_data(&source.a_support_merc_en_id);
self.a_tactician_hf_id.add_missing_data(&source.a_tactician_hf_id);
self.a_tactics_roll.add_missing_data(&source.a_tactics_roll);
self.abandoned.add_missing_data(&source.abandoned);
self.account_shift.add_missing_data(&source.account_shift);
self.acquirer_en_id.add_missing_data(&source.acquirer_en_id);
self.acquirer_hf_id.add_missing_data(&source.acquirer_hf_id);
self.action.add_missing_data(&source.action);
self.actor_hf_id.add_missing_data(&source.actor_hf_id);
self.agreement_id.add_missing_data(&source.agreement_id);
self.allotment.add_missing_data(&source.allotment);
self.allotment_index.add_missing_data(&source.allotment_index);
self.ally_defense_bonus.add_missing_data(&source.ally_defense_bonus);
self.appointer_hf_id.add_missing_data(&source.appointer_hf_id);
self.arresting_en_id.add_missing_data(&source.arresting_en_id);
self.art_id.add_missing_data(&source.art_id);
self.art_sub_id.add_missing_data(&source.art_sub_id);
self.artifact_id.add_missing_data(&source.artifact_id);
self.attacker_civ_id.add_missing_data(&source.attacker_civ_id);
self.attacker_general_hf_id.add_missing_data(&source.attacker_general_hf_id);
self.attacker_hf_id.add_missing_data(&source.attacker_hf_id);
self.attacker_merc_en_id.add_missing_data(&source.attacker_merc_en_id);
self.abuse_type.add_missing_data(&source.abuse_type);
self.anon_3.add_missing_data(&source.anon_3);
self.anon_4.add_missing_data(&source.anon_4);
}
}
#[rustfmt::skip]
impl Filler<df_st_core::HistoricalEvent, HistoricalEventAA> for df_st_core::HistoricalEvent {
fn add_missing_data(&mut self, source: &HistoricalEventAA) {
self.id.add_missing_data(&source.he_id);
self.a_leader_hf_id.add_missing_data(&source.a_leader_hf_id);
self.a_leadership_roll.add_missing_data(&source.a_leadership_roll);
self.a_squad_id.add_missing_data(&source.a_squad_id);
self.a_support_merc_en_id.add_missing_data(&source.a_support_merc_en_id);
self.a_tactician_hf_id.add_missing_data(&source.a_tactician_hf_id);
self.a_tactics_roll.add_missing_data(&source.a_tactics_roll);
self.abandoned.add_missing_data(&source.abandoned);
self.account_shift.add_missing_data(&source.account_shift);
self.acquirer_en_id.add_missing_data(&source.acquirer_en_id);
self.acquirer_hf_id.add_missing_data(&source.acquirer_hf_id);
self.action.add_missing_data(&source.action);
self.actor_hf_id.add_missing_data(&source.actor_hf_id);
self.agreement_id.add_missing_data(&source.agreement_id);
self.allotment.add_missing_data(&source.allotment);
self.allotment_index.add_missing_data(&source.allotment_index);
self.ally_defense_bonus.add_missing_data(&source.ally_defense_bonus);
self.appointer_hf_id.add_missing_data(&source.appointer_hf_id);
self.arresting_en_id.add_missing_data(&source.arresting_en_id);
self.art_id.add_missing_data(&source.art_id);
self.art_sub_id.add_missing_data(&source.art_sub_id);
self.artifact_id.add_missing_data(&source.artifact_id);
self.attacker_civ_id.add_missing_data(&source.attacker_civ_id);
self.attacker_general_hf_id.add_missing_data(&source.attacker_general_hf_id);
self.attacker_hf_id.add_missing_data(&source.attacker_hf_id);
self.attacker_merc_en_id.add_missing_data(&source.attacker_merc_en_id);
self.abuse_type.add_missing_data(&source.abuse_type);
self.anon_3.add_missing_data(&source.anon_3);
self.anon_4.add_missing_data(&source.anon_4);
}
}
impl PartialEq for HistoricalEventAA {
fn eq(&self, other: &Self) -> bool {
self.he_id == other.he_id
}
}
impl Hash for HistoricalEventAA {
fn hash<H: Hasher>(&self, state: &mut H) {
self.he_id.hash(state);
}
}
impl PartialEq<HistoricalEventAA> for df_st_core::HistoricalEvent {
fn eq(&self, other: &HistoricalEventAA) -> bool {
self.id == other.he_id
}
}
impl PartialEq<df_st_core::HistoricalEvent> for HistoricalEventAA {
fn eq(&self, other: &df_st_core::HistoricalEvent) -> bool {
self.he_id == other.id
}
}