Skip to content

Commit d12f712

Browse files
committed
chore(entity-archival): rebase
gh-1778
1 parent 77184d1 commit d12f712

File tree

4 files changed

+21
-12
lines changed

4 files changed

+21
-12
lines changed

packages/archival/src/aws-s3/import-archive-data.provider.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
} from '@loopback/core';
77
import {AnyObject} from '@loopback/repository';
88
import {HttpErrors} from '@loopback/rest';
9+
// eslint-disable-next-line @typescript-eslint/naming-convention
910
import AWS from 'aws-sdk';
1011
import {ImportDataExternalSystem} from '../types';
1112

@@ -32,10 +33,10 @@ export class ImportArchiveDataProvider
3233
Bucket: process.env.AWS_S3_BUCKET_NAME as string,
3334
Key: fileName,
3435
};
35-
let data;
36+
let s3Response;
3637
try {
37-
data = await s3.getObject(params).promise();
38-
const csvData = data.Body!.toString('utf-8');
38+
s3Response = await s3.getObject(params).promise();
39+
const csvData = s3Response.Body!.toString('utf-8');
3940

4041
const jsonArray: AnyObject[] = await new Promise((resolve, reject) => {
4142
const results: AnyObject[] = [];
@@ -48,6 +49,7 @@ export class ImportArchiveDataProvider
4849
const headers = Object.keys(jsonArray[0]);
4950
for (const entry of jsonArray) {
5051
for (const key of headers) {
52+
//sonarignore:start
5153
const value = entry[key];
5254
if (value === '') {
5355
entry[key] = null;
@@ -58,6 +60,7 @@ export class ImportArchiveDataProvider
5860
entry[key] = new Date(value);
5961
} else entry[key] = value;
6062
}
63+
//sonarignore:end
6164
}
6265
return jsonArray;
6366
} catch (error) {

packages/archival/src/mixins/archival.mixin.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
User,
2525
} from '../types';
2626

27+
// NOSONAR - ignore camelCase naming convention
2728
export function ArchivalRepositoryMixin<
2829
T extends UserModifiableEntity,
2930
ID,

packages/archival/src/services/import-archived-data.service.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ import {
2828

2929
@injectable({scope: BindingScope.TRANSIENT})
3030
export class ImportArchivedDataService {
31-
repo: AnyObject;
31+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
32+
repo: any;
3233
constructor(
3334
@repository(JobDetailsRepository)
3435
public jobDetailsRepo: JobDetailsRepository,
@@ -59,7 +60,6 @@ export class ImportArchivedDataService {
5960
const jobDetails = await this.jobDetailsRepo.findById(jobId);
6061
const modelName = jobDetails.entity;
6162
const filter = jobDetails.filterInquired;
62-
const importData: AnyObject = {};
6363

6464
const archiveFilter: Filter<ArchiveMapping> =
6565
await this.buildWhereConditionService.buildConditionForFetch(
@@ -69,7 +69,7 @@ export class ImportArchivedDataService {
6969

7070
const archivedEntries = await this.archivalMappingRepo.find(archiveFilter);
7171

72-
let data: AnyObject[] = [];
72+
const data: AnyObject[] = [];
7373

7474
for (const entry of archivedEntries) {
7575
const fileContent = await this.importArchiveData(entry.key);
@@ -105,26 +105,29 @@ export class ImportArchivedDataService {
105105
status: JobStatus.SUCCESS,
106106
result: JSON.stringify(allRecords),
107107
});
108-
this.processImportedData(allRecords);
108+
await this.processImportedData(allRecords);
109109
}
110110

111-
async getFilteredData() {}
112-
113111
// sonarignore:start
114112
private async getRepositoryByModelName<T extends Entity>(
115113
modelName: string,
114+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
116115
): Promise<DefaultCrudRepository<T, any> | undefined> {
117116
// Find all bindings with keys matching 'repositories.*'
118117
const repositoryBindings =
118+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
119119
this.context.find<DefaultCrudRepository<any, any>>('repositories.*');
120120

121121
// Iterate through the bindings to find the matching repository
122122
for (const binding of repositoryBindings) {
123-
const repository = await this.context.get<
123+
const repoName = await this.context.get<
124+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
124125
DefaultCrudRepository<any, any>
126+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
125127
>(binding.key as unknown as BindingKey<DefaultCrudRepository<any, any>>);
126-
if (repository.entityClass.name === modelName) {
127-
return repository as DefaultCrudRepository<T, any>;
128+
if (repoName.entityClass.name === modelName) {
129+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
130+
return repoName as DefaultCrudRepository<T, any>;
128131
}
129132
}
130133
// sonarignore:end

packages/archival/src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ export type MixinBaseClass<T> = AbstractConstructor<T>;
2525

2626
export type ArchiveMixinBase<
2727
T extends UserModifiableEntity,
28+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
2829
ID,
30+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
2931
Relations,
3032
> = MixinBaseClass<{
3133
entityClass: typeof UserModifiableEntity & {

0 commit comments

Comments
 (0)