-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: health professional indexer (#255)
* health professional indexer * update indexer module and route
- Loading branch information
1 parent
afef91f
commit 8e87af6
Showing
23 changed files
with
427 additions
and
0 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
...al-availability-status-updated/health-professional-availability-status-updated.command.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { AvailabilityStatus } from '@indexer/models/availability-status'; | ||
import { BlockMetaData } from '../../../../models/block-meta-data'; | ||
|
||
export class HealthProfessionalAvailabilityStatusCommandIndexer { | ||
availabilityStatus: AvailabilityStatus; | ||
accountId: string; | ||
constructor(data: Array<any>, public readonly blockMetaData: BlockMetaData) { | ||
this.accountId = data[0].toString(); | ||
this.availabilityStatus = data[1].toString() as AvailabilityStatus; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...al-availability-status-updated/health-professional-availability-status-updated.handler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { CommandHandler, ICommandHandler } from '@nestjs/cqrs'; | ||
import { ElasticsearchService } from '@nestjs/elasticsearch'; | ||
import { HealthProfessionalAvailabilityStatusCommandIndexer } from './health-professional-availability-status-updated.command'; | ||
|
||
@Injectable() | ||
@CommandHandler(HealthProfessionalAvailabilityStatusCommandIndexer) | ||
export class HealthProfessionalAvailabilityStatusHandler | ||
implements | ||
ICommandHandler<HealthProfessionalAvailabilityStatusCommandIndexer> | ||
{ | ||
constructor(private readonly elasticsearchService: ElasticsearchService) {} | ||
|
||
async execute( | ||
command: HealthProfessionalAvailabilityStatusCommandIndexer, | ||
): Promise<any> { | ||
const { accountId, availabilityStatus, blockMetaData } = command; | ||
|
||
await this.elasticsearchService.update({ | ||
id: accountId, | ||
index: 'health-professional', | ||
refresh: 'wait_for', | ||
body: { | ||
doc: { | ||
availability_status: availabilityStatus, | ||
blockMetaData: blockMetaData, | ||
}, | ||
}, | ||
}); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...nal/commands/health-professional-info-updated/health-professional-info-updated.command.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { HealthProfessionalInfo } from '@indexer/models/health-professional/info'; | ||
import { BlockMetaData } from '../../../../models/block-meta-data'; | ||
|
||
export class HealthProfessionalInfoUpdatedCommandIndexer { | ||
healthProfessionalInfo: HealthProfessionalInfo; | ||
accountId: string; | ||
constructor(data: Array<any>, public readonly blockMetaData: BlockMetaData) { | ||
this.accountId = data[0].toString(); | ||
this.healthProfessionalInfo = new HealthProfessionalInfo(data[1]); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...nal/commands/health-professional-info-updated/health-professional-info-updated.handler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { CommandHandler, ICommandHandler } from '@nestjs/cqrs'; | ||
import { ElasticsearchService } from '@nestjs/elasticsearch'; | ||
import { HealthProfessionalInfoUpdatedCommandIndexer } from './health-professional-info-updated.command'; | ||
|
||
@Injectable() | ||
@CommandHandler(HealthProfessionalInfoUpdatedCommandIndexer) | ||
export class HealthProfessionalInfoUpdatedHandler | ||
implements ICommandHandler<HealthProfessionalInfoUpdatedCommandIndexer> | ||
{ | ||
constructor(private readonly elasticsearchService: ElasticsearchService) {} | ||
|
||
async execute( | ||
command: HealthProfessionalInfoUpdatedCommandIndexer, | ||
): Promise<any> { | ||
const { accountId, healthProfessionalInfo, blockMetaData } = command; | ||
|
||
await this.elasticsearchService.update({ | ||
id: accountId, | ||
index: 'health-professional', | ||
refresh: 'wait_for', | ||
body: { | ||
doc: { | ||
info: { | ||
...healthProfessionalInfo, | ||
}, | ||
blockMetaData: blockMetaData, | ||
}, | ||
}, | ||
}); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...ssional/commands/health-professional-registered/health-professional-registered.command.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { HealthProfessional } from '@indexer/models/health-professional'; | ||
import { BlockMetaData } from '../../../../models/block-meta-data'; | ||
|
||
export class HealthProfessionalRegisteredCommandIndexer { | ||
healthProfessional: HealthProfessional; | ||
accountId: string; | ||
constructor(data: Array<any>, public readonly blockMetaData: BlockMetaData) { | ||
this.accountId = data[0].toString(); | ||
this.healthProfessional = new HealthProfessional(data[1]); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...ssional/commands/health-professional-registered/health-professional-registered.handler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { CommandHandler, ICommandHandler } from '@nestjs/cqrs'; | ||
import { ElasticsearchService } from '@nestjs/elasticsearch'; | ||
import { HealthProfessionalRegisteredCommandIndexer } from './health-professional-registered.command'; | ||
|
||
@Injectable() | ||
@CommandHandler(HealthProfessionalRegisteredCommandIndexer) | ||
export class HealthProfessionalRegisteredHandler | ||
implements ICommandHandler<HealthProfessionalRegisteredCommandIndexer> | ||
{ | ||
constructor(private readonly elasticsearchService: ElasticsearchService) {} | ||
|
||
async execute( | ||
command: HealthProfessionalRegisteredCommandIndexer, | ||
): Promise<any> { | ||
const { accountId, healthProfessional, blockMetaData } = command; | ||
|
||
await this.elasticsearchService.create({ | ||
id: accountId, | ||
index: 'health-professional', | ||
refresh: 'wait_for', | ||
body: { | ||
...healthProfessional, | ||
blockMetaData: blockMetaData, | ||
}, | ||
}); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...th-professional/commands/health-professional-staked/health-professional-staked.command.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { BlockMetaData } from '../../../../models/block-meta-data'; | ||
|
||
export class HealthProfessionalStakedCommandIndexer { | ||
balance: string; | ||
accountId: string; | ||
constructor(data: Array<any>, public readonly blockMetaData: BlockMetaData) { | ||
this.accountId = data[0].toString(); | ||
this.balance = data[1].toString(); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...th-professional/commands/health-professional-staked/health-professional-staked.handler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { StakeStatus } from '@indexer/models/stake-status'; | ||
import { Injectable } from '@nestjs/common'; | ||
import { CommandHandler, ICommandHandler } from '@nestjs/cqrs'; | ||
import { ElasticsearchService } from '@nestjs/elasticsearch'; | ||
import { HealthProfessionalStakedCommandIndexer } from './health-professional-staked.command'; | ||
|
||
@Injectable() | ||
@CommandHandler(HealthProfessionalStakedCommandIndexer) | ||
export class HealthProfessionalStakedHandler | ||
implements ICommandHandler<HealthProfessionalStakedCommandIndexer> | ||
{ | ||
constructor(private readonly elasticsearchService: ElasticsearchService) {} | ||
|
||
async execute(command: HealthProfessionalStakedCommandIndexer): Promise<any> { | ||
const { accountId, balance, blockMetaData } = command; | ||
|
||
await this.elasticsearchService.create({ | ||
id: accountId, | ||
index: 'health-professional', | ||
refresh: 'wait_for', | ||
body: { | ||
stake_amount: balance, | ||
stake_status: StakeStatus.Staked, | ||
blockMetaData: blockMetaData, | ||
}, | ||
}); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...nal/commands/health-professional-unregistered/health-professional-unregistered.command.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { HealthProfessional } from '@indexer/models/health-professional'; | ||
import { BlockMetaData } from '../../../../models/block-meta-data'; | ||
|
||
export class HealthProfessionalUnregisteredCommandIndexer { | ||
accountId: string; | ||
constructor(data: Array<any>, public readonly blockMetaData: BlockMetaData) { | ||
this.accountId = data[0].toString(); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...nal/commands/health-professional-unregistered/health-professional-unregistered.handler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { CommandHandler, ICommandHandler } from '@nestjs/cqrs'; | ||
import { ElasticsearchService } from '@nestjs/elasticsearch'; | ||
import { HealthProfessionalUnregisteredCommandIndexer } from './health-professional-unregistered.command'; | ||
|
||
@Injectable() | ||
@CommandHandler(HealthProfessionalUnregisteredCommandIndexer) | ||
export class HealthProfessionalUnregisteredHandler | ||
implements ICommandHandler<HealthProfessionalUnregisteredCommandIndexer> | ||
{ | ||
constructor(private readonly elasticsearchService: ElasticsearchService) {} | ||
|
||
async execute( | ||
command: HealthProfessionalUnregisteredCommandIndexer, | ||
): Promise<any> { | ||
const { accountId } = command; | ||
|
||
await this.elasticsearchService.delete({ | ||
id: accountId, | ||
index: 'health-professional', | ||
refresh: 'wait_for', | ||
}); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...mmands/health-professional-unstaked-amount/health-professional-unstaked-amount.command.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { BlockMetaData } from '../../../../models/block-meta-data'; | ||
|
||
export class HealthProfessionalUnstakedAmountCommandIndexer { | ||
balance: string; | ||
accountId: string; | ||
constructor(data: Array<any>, public readonly blockMetaData: BlockMetaData) { | ||
this.accountId = data[0].toString(); | ||
this.balance = data[1].toString(); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...mmands/health-professional-unstaked-amount/health-professional-unstaked-amount.handler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { StakeStatus } from '@indexer/models/stake-status'; | ||
import { Injectable } from '@nestjs/common'; | ||
import { CommandHandler, ICommandHandler } from '@nestjs/cqrs'; | ||
import { ElasticsearchService } from '@nestjs/elasticsearch'; | ||
import { HealthProfessionalUnstakedAmountCommandIndexer } from './health-professional-unstaked-amount.command'; | ||
|
||
@Injectable() | ||
@CommandHandler(HealthProfessionalUnstakedAmountCommandIndexer) | ||
export class HealthProfessionalUnstakedAmountHandler | ||
implements ICommandHandler<HealthProfessionalUnstakedAmountCommandIndexer> | ||
{ | ||
constructor(private readonly elasticsearchService: ElasticsearchService) {} | ||
|
||
async execute( | ||
command: HealthProfessionalUnstakedAmountCommandIndexer, | ||
): Promise<any> { | ||
const { accountId, balance, blockMetaData } = command; | ||
|
||
await this.elasticsearchService.create({ | ||
id: accountId, | ||
index: 'health-professional', | ||
refresh: 'wait_for', | ||
body: { | ||
stake_amount: balance, | ||
stake_status: StakeStatus.Unstaked, | ||
blockMetaData: blockMetaData, | ||
}, | ||
}); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...rofessional/commands/health-professional-unstaked/health-professional-unstaked.command.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { BlockMetaData } from '../../../../models/block-meta-data'; | ||
|
||
export class HealthProfessionalUnstakedCommandIndexer { | ||
accountId: string; | ||
constructor(data: Array<any>, public readonly blockMetaData: BlockMetaData) { | ||
this.accountId = data[0].toString(); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...rofessional/commands/health-professional-unstaked/health-professional-unstaked.handler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { StakeStatus } from '@indexer/models/stake-status'; | ||
import { Injectable } from '@nestjs/common'; | ||
import { CommandHandler, ICommandHandler } from '@nestjs/cqrs'; | ||
import { ElasticsearchService } from '@nestjs/elasticsearch'; | ||
import { HealthProfessionalUnstakedCommandIndexer } from './health-professional-unstaked.command'; | ||
|
||
@Injectable() | ||
@CommandHandler(HealthProfessionalUnstakedCommandIndexer) | ||
export class HealthProfessionalUnstakedHandler | ||
implements ICommandHandler<HealthProfessionalUnstakedCommandIndexer> | ||
{ | ||
constructor(private readonly elasticsearchService: ElasticsearchService) {} | ||
|
||
async execute( | ||
command: HealthProfessionalUnstakedCommandIndexer, | ||
): Promise<any> { | ||
const { accountId, blockMetaData } = command; | ||
|
||
await this.elasticsearchService.create({ | ||
id: accountId, | ||
index: 'health-professional', | ||
refresh: 'wait_for', | ||
body: { | ||
stake_status: StakeStatus.Unstaked, | ||
blockMetaData: blockMetaData, | ||
}, | ||
}); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...al-verification-status-updated/health-professional-verification-status-updated.command.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { VerificationStatus } from '@indexer/models/verification-status'; | ||
import { BlockMetaData } from '../../../../models/block-meta-data'; | ||
|
||
export class HealthProfessionalVerificationStatusCommandIndexer { | ||
verificationStatus: VerificationStatus; | ||
accountId: string; | ||
constructor(data: Array<any>, public readonly blockMetaData: BlockMetaData) { | ||
this.accountId = data[0].toString(); | ||
this.verificationStatus = data[1].toString() as VerificationStatus; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...al-verification-status-updated/health-professional-verification-status-updated.handler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { CommandHandler, ICommandHandler } from '@nestjs/cqrs'; | ||
import { ElasticsearchService } from '@nestjs/elasticsearch'; | ||
import { HealthProfessionalVerificationStatusCommandIndexer } from './health-professional-verification-status-updated.command'; | ||
|
||
@Injectable() | ||
@CommandHandler(HealthProfessionalVerificationStatusCommandIndexer) | ||
export class HealthProfessionalVerificationStatusHandler | ||
implements | ||
ICommandHandler<HealthProfessionalVerificationStatusCommandIndexer> | ||
{ | ||
constructor(private readonly elasticsearchService: ElasticsearchService) {} | ||
|
||
async execute( | ||
command: HealthProfessionalVerificationStatusCommandIndexer, | ||
): Promise<any> { | ||
const { accountId, verificationStatus, blockMetaData } = command; | ||
|
||
await this.elasticsearchService.update({ | ||
id: accountId, | ||
index: 'health-professional', | ||
refresh: 'wait_for', | ||
body: { | ||
doc: { | ||
availability_status: verificationStatus, | ||
blockMetaData: blockMetaData, | ||
}, | ||
}, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
export * from './commands/health-professional-availability-status-updated/health-professional-availability-status-updated.command'; | ||
export * from './commands/health-professional-info-updated/health-professional-info-updated.command'; | ||
export * from './commands/health-professional-registered/health-professional-registered.command'; | ||
export * from './commands/health-professional-staked/health-professional-staked.command'; | ||
export * from './commands/health-professional-unregistered/health-professional-unregistered.command'; | ||
export * from './commands/health-professional-unstaked/health-professional-unstaked.command'; | ||
export * from './commands/health-professional-unstaked-amount/health-professional-unstaked-amount.command'; | ||
export * from './commands/health-professional-verification-status-updated/health-professional-verification-status-updated.command'; | ||
|
||
import { HealthProfessionalAvailabilityStatusHandler } from './commands/health-professional-availability-status-updated/health-professional-availability-status-updated.handler'; | ||
import { HealthProfessionalInfoUpdatedHandler } from './commands/health-professional-info-updated/health-professional-info-updated.handler'; | ||
import { HealthProfessionalRegisteredHandler } from './commands/health-professional-registered/health-professional-registered.handler'; | ||
import { HealthProfessionalStakedHandler } from './commands/health-professional-staked/health-professional-staked.handler'; | ||
import { HealthProfessionalUnregisteredHandler } from './commands/health-professional-unregistered/health-professional-unregistered.handler'; | ||
import { HealthProfessionalUnstakedHandler } from './commands/health-professional-unstaked/health-professional-unstaked.handler'; | ||
import { HealthProfessionalUnstakedAmountHandler } from './commands/health-professional-unstaked-amount/health-professional-unstaked-amount.handler'; | ||
import { HealthProfessionalVerificationStatusHandler } from './commands/health-professional-verification-status-updated/health-professional-verification-status-updated.handler'; | ||
|
||
export const HealthProfessionalHandlers = [ | ||
HealthProfessionalAvailabilityStatusHandler, | ||
HealthProfessionalInfoUpdatedHandler, | ||
HealthProfessionalRegisteredHandler, | ||
HealthProfessionalStakedHandler, | ||
HealthProfessionalUnregisteredHandler, | ||
HealthProfessionalUnstakedHandler, | ||
HealthProfessionalUnstakedAmountHandler, | ||
HealthProfessionalVerificationStatusHandler, | ||
]; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.