Skip to content

Commit

Permalink
Fix test logic for inst assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
simonfernandes authored and deepaksftc committed Aug 13, 2024
1 parent 1c7d775 commit 64f7f18
Show file tree
Hide file tree
Showing 2 changed files with 644 additions and 569 deletions.
17 changes: 12 additions & 5 deletions apps/backend/src/datasources/postgres/TechniqueDataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,19 @@ export default class PostgresTechniqueDataSource
instrumentIds: number[]
): Promise<Technique[]> {
try {
const uniqueTechniqueIds = await database('technique_has_instruments')
.whereIn('instrument_id', instrumentIds)
.distinct()
.pluck('technique_id');
const uniqueTechniques: TechniqueRecord[] = await database(
'techniques as t'
)
.select('t.*')
.join('technique_has_instruments as thi', {
'thi.technique_id': 't.technique_id',
})
.whereIn('thi.instrument_id', instrumentIds)
.distinct();

return this.getTechniquesByIds(uniqueTechniqueIds);
return uniqueTechniques
? uniqueTechniques.map((tech) => this.createTechniqueObject(tech))
: [];
} catch (error) {
throw new Error(`Error getting techniques by instrument IDs: ${error}`);
}
Expand Down
Loading

0 comments on commit 64f7f18

Please sign in to comment.