Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: format data class #257

Merged
merged 1 commit into from
Jan 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ export class HealthProfessionalInfoUpdatedCommandIndexer {
accountId: string;
constructor(data: Array<any>, public readonly blockMetaData: BlockMetaData) {
this.accountId = data[0].toString();
this.healthProfessionalInfo = new HealthProfessionalInfo(data[1]);
this.healthProfessionalInfo = new HealthProfessionalInfo(data[1].toHuman());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,25 @@ export class HealthProfessionalInfoUpdatedHandler
async execute(
command: HealthProfessionalInfoUpdatedCommandIndexer,
): Promise<any> {
const { accountId, healthProfessionalInfo, blockMetaData } = command;
const {
accountId,
healthProfessionalInfo: {
anonymous,
box_public_key,
category,
date_of_birth,
email,
first_name,
gender,
last_name,
myriad_username,
phone_number,
profile_image,
profile_link,
role,
},
blockMetaData,
} = command;

await this.elasticsearchService.update({
id: accountId,
Expand All @@ -22,7 +40,19 @@ export class HealthProfessionalInfoUpdatedHandler
body: {
doc: {
info: {
...healthProfessionalInfo,
anonymous: anonymous,
box_public_key: box_public_key,
category: category,
date_of_birth: date_of_birth,
email: email,
first_name: first_name,
gender: gender,
last_name: last_name,
myriad_username: myriad_username,
phone_number: phone_number,
profile_image: profile_image,
profile_link: profile_link,
role: role,
},
blockMetaData: blockMetaData,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ export class HealthProfessionalRegisteredCommandIndexer {
accountId: string;
constructor(data: Array<any>, public readonly blockMetaData: BlockMetaData) {
this.accountId = data[0].toString();
this.healthProfessional = new HealthProfessional(data[1]);
this.healthProfessional = new HealthProfessional(data[1].toHuman());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,62 @@ export class HealthProfessionalRegisteredHandler
async execute(
command: HealthProfessionalRegisteredCommandIndexer,
): Promise<any> {
const { accountId, healthProfessional, blockMetaData } = command;
const {
accountId,
healthProfessional: {
account_id,
availability_status,
info: {
anonymous: anonymous,
box_public_key: box_public_key,
category: category,
date_of_birth: date_of_birth,
email: email,
first_name: first_name,
gender: gender,
last_name: last_name,
myriad_username: myriad_username,
phone_number: phone_number,
profile_image: profile_image,
profile_link: profile_link,
role: role,
},
qualifications,
unstaked_at,
stake_amount,
stake_status,
verification_status,
},
blockMetaData,
} = command;

await this.elasticsearchService.create({
id: accountId,
index: 'health-professional',
refresh: 'wait_for',
body: {
...healthProfessional,
account_id: account_id,
availability_status: availability_status,
info: {
anonymous,
box_public_key,
category,
date_of_birth,
email,
first_name,
gender,
last_name,
myriad_username,
phone_number,
profile_image,
profile_link,
role,
},
qualifications: qualifications,
unstaked_at: unstaked_at,
stake_amount: stake_amount,
stake_status: stake_status,
verification_status: verification_status,
blockMetaData: blockMetaData,
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class HealthProfessionalVerificationStatusHandler
refresh: 'wait_for',
body: {
doc: {
availability_status: verificationStatus,
verification_status: verificationStatus,
blockMetaData: blockMetaData,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,39 @@ export class OpinionRequestedHandler
constructor(private readonly elasticsearchService: ElasticsearchService) {}

async execute(command: OpinionRequestedCommandIndexer) {
const { opinionRequestor, blockMetaData } = command;
const {
opinionRequestor: {
id,
account_id,
info: {
category,
description,
genetic_data_ids,
opinion_ids,
myriad_url,
},
created_at,
updated_at,
},
blockMetaData,
} = command;

await this.elasticsearchService.create({
index: 'opinion-requestor',
id: opinionRequestor.id,
id: id,
refresh: 'wait_for',
body: {
...opinionRequestor,
id: id,
account_id: account_id,
info: {
category: category,
description: description,
genetic_data_ids: genetic_data_ids,
opinion_ids: opinion_ids,
myriad_url: myriad_url,
},
created_at: created_at,
updated_at: updated_at,
blockMetaData: blockMetaData,
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,35 @@ export class OpinionAddedHandler
constructor(private readonly elasticsearchService: ElasticsearchService) {}

async execute(command: OpinionAddedCommandIndexer) {
const { opinion, blockMetaData } = command;
const {
opinion: {
id,
requestor_id,
professional_id,
info: { description, myriad_url, asset_id, currency, amount },
status,
created_at,
},
blockMetaData,
} = command;

await this.elasticsearchService.create({
index: 'opinion',
id: opinion.id,
id: id,
refresh: 'wait_for',
body: {
...opinion,
id: id,
requestor_id: requestor_id,
professional_id: professional_id,
info: {
description: description,
myriad_url: myriad_url,
asset_id: asset_id,
currency: currency,
amount: amount,
},
status: status,
created_at: created_at,
blockMetaData: blockMetaData,
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@ export class OpinionUpdatedHandler

async execute(command: OpinionUpdatedCommandIndexer) {
const {
opinion: { info, id },
opinion: {
id,
requestor_id,
professional_id,
info: { description, myriad_url, asset_id, currency, amount },
status,
created_at,
},
blockMetaData,
} = command;

Expand All @@ -22,9 +29,17 @@ export class OpinionUpdatedHandler
refresh: 'wait_for',
body: {
doc: {
requestor_id: requestor_id,
professional_id: professional_id,
info: {
...info,
description: description,
myriad_url: myriad_url,
asset_id: asset_id,
currency: currency,
amount: amount,
},
status: status,
created_at: created_at,
blockMetaData: blockMetaData,
},
},
Expand Down
6 changes: 3 additions & 3 deletions src/indexer/models/health-professional/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ export class HealthProfessional {
this.verification_status = data.verification_status;
this.availability_status = data.availability_status;
this.unstaked_at = data.unstaked_at
? new Date(Number((data.unstaked_at as string).split(',').join('')))
? Number((data.unstaked_at as string).split(',').join(''))
: null;
}

account_id: string;
qualifications: string;
qualifications: string[];
info: HealthProfessionalInfo;
stake_amount: string;
stake_status: StakeStatus;
verification_status: VerificationStatus;
availability_status: AvailabilityStatus;
unstaked_at: Date;
unstaked_at: number;
}
8 changes: 4 additions & 4 deletions src/indexer/models/opinion-requestor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ export class OpinionRequestor {
this.account_id = data.account_id;
this.info = new RequestorInfo(data.info);
this.created_at = data.created_at
? new Date(Number(String(data.created_at).split(',').join('')))
? Number(String(data.created_at).split(',').join(''))
: null;
this.updated_at = data.updated_at
? new Date(Number(String(data.updated_at).split(',').join('')))
? Number(String(data.updated_at).split(',').join(''))
: null;
}

id: string;
account_id: string;
info: RequestorInfo;
created_at: Date;
updated_at: Date;
created_at: number;
updated_at: number;
}
6 changes: 4 additions & 2 deletions src/indexer/models/opinion/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ export class Opinion {
this.professional_id = data.professional_id;
this.info = new OpinionInfo(data.info);
this.status = data.status;
this.created_at = data.created_at;
this.created_at = data.created_at
? Number(String(data.created_at).split(',').join(''))
: null;
}

id: string;
requestor_id: string;
professional_id: string;
info: OpinionInfo;
status: string;
created_at: Date;
created_at: number;
}