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: details does no longer return insertions #715

Merged
merged 1 commit into from
Mar 26, 2024
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 @@ -139,7 +139,9 @@ fun buildOpenApiSchema(
"The key 'count' is always present.",
)
.required(listOf(COUNT_PROPERTY))
.properties(getAggregatedResponseProperties(metadataFieldSchemas(databaseConfig))),
.properties(
getAggregatedResponseProperties(aggregatedMetadataFieldSchemas(databaseConfig)),
),
),
)
.addSchemas(
Expand All @@ -150,7 +152,7 @@ fun buildOpenApiSchema(
.description(
"The response contains the metadata of every sequence matching the sequence filters.",
)
.properties(metadataFieldSchemas(databaseConfig)),
.properties(detailsMetadataFieldSchemas(databaseConfig)),
),
)
.addSchemas(
Expand Down Expand Up @@ -299,9 +301,15 @@ private fun infoResponseSchema() =
)
.required(listOf("dataVersion"))

private fun metadataFieldSchemas(databaseConfig: DatabaseConfig) =
private fun aggregatedMetadataFieldSchemas(databaseConfig: DatabaseConfig) =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it also weird to allow aggregation by insertions?

databaseConfig.schema.metadata.associate { it.name to Schema<String>().type(mapToOpenApiType(it.type)) }

private fun detailsMetadataFieldSchemas(databaseConfig: DatabaseConfig) =
databaseConfig.schema.metadata.filter {
it.type != MetadataType.AMINO_ACID_INSERTION && it.type != MetadataType.NUCLEOTIDE_INSERTION
}
.associate { it.name to Schema<String>().type(mapToOpenApiType(it.type)) }

private fun mapToOpenApiType(type: MetadataType): String =
when (type) {
MetadataType.STRING -> "string"
Expand Down
8 changes: 0 additions & 8 deletions siloLapisTests/test/details.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ describe('The /details endpoint', () => {

expect(result.data).to.have.length(2);
expect(result.data[0]).to.be.deep.equal({
aaInsertions: undefined,
insertions: undefined,
age: undefined,
country: undefined,
date: undefined,
Expand All @@ -34,8 +32,6 @@ describe('The /details endpoint', () => {

expect(result.data).to.have.length(2);
expect(result.data[0]).to.be.deep.equal({
aaInsertions: undefined,
insertions: '25701:CCC',
age: 54,
country: 'Switzerland',
date: '2021-07-19',
Expand Down Expand Up @@ -136,13 +132,11 @@ Solothurn B.1 key_1002052

it('should correctly handle nucleotide insertion requests', async () => {
const expectedResultWithNucleotideInsertion = {
aaInsertions: undefined,
age: 57,
country: 'Switzerland',
date: '2021-05-12',
division: 'Zürich',
primaryKey: 'key_3578231',
insertions: '25701:CCC,5959:TAT',
pangoLineage: 'P.1',
qcValue: 0.93,
region: 'Europe',
Expand All @@ -160,8 +154,6 @@ Solothurn B.1 key_1002052

it('should correctly handle amino acid insertion requests', async () => {
const expectedResultWithAminoAcidInsertion = {
aaInsertions: 'S:143:T,ORF1a:3602:FEP',
insertions: undefined,
age: 52,
country: 'Switzerland',
date: '2021-07-04',
Expand Down
Loading