Skip to content

Commit

Permalink
feat(backend): import strong data via generic csv
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnisDa committed Dec 3, 2024
1 parent c4e146c commit a2fdeac
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 42 deletions.
16 changes: 1 addition & 15 deletions crates/models/media/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -929,20 +929,6 @@ pub struct DeployMalImportInput {
pub manga_path: Option<String>,
}

#[derive(Debug, InputObject, Serialize, Deserialize, Clone)]
pub struct StrongAppImportMapping {
pub source_name: String,
pub target_name: String,
pub multiplier: Option<Decimal>,
}

#[derive(Debug, InputObject, Serialize, Deserialize, Clone)]
pub struct DeployStrongAppImportInput {
// The path to the CSV file in the local file system.
pub export_path: String,
pub mapping: Vec<StrongAppImportMapping>,
}

#[derive(Debug, InputObject, Serialize, Deserialize, Clone)]
pub struct DeployIgdbImportInput {
// The path to the CSV file in the local file system.
Expand Down Expand Up @@ -977,7 +963,7 @@ pub struct DeployImportJobInput {
pub trakt: Option<DeployTraktImportInput>,
pub movary: Option<DeployMovaryImportInput>,
pub generic_json: Option<DeployJsonImportInput>,
pub strong_app: Option<DeployStrongAppImportInput>,
pub strong_app: Option<DeployGenericCsvImportInput>,
pub url_and_key: Option<DeployUrlAndKeyImportInput>,
pub generic_csv: Option<DeployGenericCsvImportInput>,
pub jellyfin: Option<DeployUrlAndKeyAndUsernameImportInput>,
Expand Down
6 changes: 3 additions & 3 deletions crates/services/importer/src/strong_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use fitness_models::{
};
use importer_models::{ImportFailStep, ImportFailedItem};
use itertools::Itertools;
use media_models::DeployStrongAppImportInput;
use media_models::DeployGenericCsvImportInput;
use rust_decimal::Decimal;
use rust_decimal_macros::dec;
use sea_orm::{ColumnTrait, EntityTrait, QueryFilter};
Expand Down Expand Up @@ -48,10 +48,10 @@ struct Entry {
}

pub async fn import(
input: DeployStrongAppImportInput,
input: DeployGenericCsvImportInput,
ss: &Arc<SupportingService>,
) -> Result<ImportResult> {
let file_string = fs::read_to_string(&input.export_path)?;
let file_string = fs::read_to_string(&input.csv_path)?;
// DEV: Delimiter is `;` on android and `,` on iOS, so we determine it by reading the first line
let data = file_string.clone();
let first_line = data.lines().next().unwrap();
Expand Down
13 changes: 1 addition & 12 deletions libs/generated/src/graphql/backend/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ export type DeployImportJobInput = {
mal?: InputMaybe<DeployMalImportInput>;
movary?: InputMaybe<DeployMovaryImportInput>;
source: ImportSource;
strongApp?: InputMaybe<DeployStrongAppImportInput>;
strongApp?: InputMaybe<DeployGenericCsvImportInput>;
trakt?: InputMaybe<DeployTraktImportInput>;
urlAndKey?: InputMaybe<DeployUrlAndKeyImportInput>;
};
Expand All @@ -424,11 +424,6 @@ export type DeployMovaryImportInput = {
watchlist: Scalars['String']['input'];
};

export type DeployStrongAppImportInput = {
exportPath: Scalars['String']['input'];
mapping: Array<StrongAppImportMapping>;
};

export type DeployTraktImportInput = {
username: Scalars['String']['input'];
};
Expand Down Expand Up @@ -2125,12 +2120,6 @@ export type StringIdObject = {
id: Scalars['String']['output'];
};

export type StrongAppImportMapping = {
multiplier?: InputMaybe<Scalars['Decimal']['input']>;
sourceName: Scalars['String']['input'];
targetName: Scalars['String']['input'];
};

export type UpdateComplexJsonInput = {
/** Dot delimited path to the property that needs to be changed. */
property: Scalars['String']['input'];
Expand Down
13 changes: 1 addition & 12 deletions libs/generated/src/graphql/backend/types.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ export type DeployImportJobInput = {
mal?: InputMaybe<DeployMalImportInput>;
movary?: InputMaybe<DeployMovaryImportInput>;
source: ImportSource;
strongApp?: InputMaybe<DeployStrongAppImportInput>;
strongApp?: InputMaybe<DeployGenericCsvImportInput>;
trakt?: InputMaybe<DeployTraktImportInput>;
urlAndKey?: InputMaybe<DeployUrlAndKeyImportInput>;
};
Expand All @@ -411,11 +411,6 @@ export type DeployMovaryImportInput = {
watchlist: Scalars['String']['input'];
};

export type DeployStrongAppImportInput = {
exportPath: Scalars['String']['input'];
mapping: Array<StrongAppImportMapping>;
};

export type DeployTraktImportInput = {
username: Scalars['String']['input'];
};
Expand Down Expand Up @@ -2191,12 +2186,6 @@ export type StringIdObject = {
id: Scalars['String']['output'];
};

export type StrongAppImportMapping = {
multiplier?: InputMaybe<Scalars['Decimal']['input']>;
sourceName: Scalars['String']['input'];
targetName: Scalars['String']['input'];
};

export type UpdateComplexJsonInput = {
/** Dot delimited path to the property that needs to be changed. */
property: Scalars['String']['input'];
Expand Down

0 comments on commit a2fdeac

Please sign in to comment.