Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
distribution: 'adopt'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5
uses: gradle/actions/setup-gradle@v6

- name: Execute Tests
run: ./gradlew test
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ jobs:
run: echo "branchTag=${TAG##*:}" >> $GITHUB_OUTPUT

- name: Wait for website Docker image
uses: lewagon/wait-on-check-action@v1.5.0
uses: lewagon/wait-on-check-action@v1.6.0
with:
ref: ${{ github.sha }}
check-name: Build Website Docker Image
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 10
- name: Wait for backend Docker image
uses: lewagon/wait-on-check-action@v1.5.0
uses: lewagon/wait-on-check-action@v1.6.0
with:
ref: ${{ github.sha }}
check-name: Build Backend Docker Image
Expand All @@ -65,7 +65,7 @@ jobs:
if: github.ref != 'refs/heads/main'
run: npm run e2e:chromium

- uses: actions/upload-artifact@v6
- uses: actions/upload-artifact@v7
if: ${{ !cancelled() }}
with:
name: playwright-report
Expand Down
28 changes: 27 additions & 1 deletion backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,40 @@ You have to provide config information to the backend:
* Dashboards configuration, e.g. the LAPIS instances of the organisms.
We have profiles available that only need to be activated via `spring.profiles.active`.
* Database connection configuration: values need to be passed via [external properties](https://docs.spring.io/spring-boot/reference/features/external-config.html).
For local development, we have a `local-db` profile available.
For local development, we have a `local-db` profile available.
You can also check that for required properties.

### Start local database

Start the local PostgreSQL database using Docker Compose (from the repo root):

```bash
docker compose up -d database
```

Stop the database:

```bash
docker compose down database
```

Stop and remove data volumes:

```bash
docker compose down -v database
```

### Run the backend

To run the backend locally, you can use the following command:
```bash
./gradlew bootRun --args='--spring.profiles.active=local-db,dashboards-prod'
```

The backend will be available at:
- Base URL: `http://localhost:8080`
- Swagger UI: `http://localhost:8080/swagger-ui/index.html`

Run tests:

```bash
Expand Down
4 changes: 2 additions & 2 deletions backend/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ dependencies {
exclude(group = "org.mockito")
}
testImplementation("com.ninja-squad:springmockk:4.0.2")
testImplementation("org.testcontainers:testcontainers:2.0.3")
testImplementation("org.testcontainers:testcontainers-postgresql:2.0.3")
testImplementation("org.testcontainers:testcontainers:2.0.4")
testImplementation("org.testcontainers:testcontainers-postgresql:2.0.4")
testImplementation("org.mock-server:mockserver-netty:5.15.0")
testImplementation("org.mock-server:mockserver-spring-test-listener:5.15.0")

Expand Down
2 changes: 1 addition & 1 deletion backend/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion backend/gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package org.genspectrum.dashboardsbackend.api

import io.swagger.v3.oas.annotations.media.Schema

@Schema(
description = "A collection of variants",
example = """
{
"id": 1,
"name": "My Collection",
"ownedBy": "user123",
"organism": "covid",
"description": "A collection of interesting variants",
"variants": []
}
""",
)
data class Collection(
val id: Long,
val name: String,
val ownedBy: String,
val organism: String,
val description: String?,
val variants: List<Variant>,
)

@Schema(
description = "Request to create a collection",
example = """
{
"name": "My Collection",
"organism": "covid",
"description": "A collection of interesting variants",
"variants": [
{
"type": "query",
"name": "BA.2 in USA",
"description": "BA.2 lineage cases in USA",
"countQuery": "country='USA' & lineage='BA.2'",
"coverageQuery": "country='USA'"
}
]
}
""",
)
data class CollectionRequest(
val name: String,
val organism: String,
val description: String? = null,
val variants: List<VariantRequest>,
)

@Schema(
description = "Request to update a collection",
example = """
{
"name": "Updated Collection Name",
"description": "Updated description",
"variants": [
{
"type": "query",
"id": 1,
"name": "BA.2 in USA",
"description": "BA.2 lineage cases in USA",
"countQuery": "country='USA' & lineage='BA.2'",
"coverageQuery": "country='USA'"
},
{
"type": "query",
"name": "New Variant Without ID",
"countQuery": "country='Germany'"
}
]
}
""",
)
data class CollectionUpdate(
val name: String? = null,
val description: String? = null,
val variants: List<VariantUpdate>? = null,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package org.genspectrum.dashboardsbackend.api

import com.fasterxml.jackson.annotation.JsonAnyGetter
import com.fasterxml.jackson.annotation.JsonAnySetter
import com.fasterxml.jackson.annotation.JsonInclude

/**
* A JSON object with mutation lists (keys: aminoAcidMutations, nucleotideMutations, ...)
* as well as arbitrary extra properties (e.g. lineage filters) as top-level fields.
* In a validation step, the extra properties are validated to make sure only valid
* fields are used.
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
class FilterObject {
var aminoAcidMutations: List<String>? = null
var nucleotideMutations: List<String>? = null
var aminoAcidInsertions: List<String>? = null
var nucleotideInsertions: List<String>? = null

private val filters: MutableMap<String, String> = mutableMapOf()

@JsonAnyGetter
fun getFilters(): Map<String, String> = filters

@JsonAnySetter
fun set(key: String, value: String) {
filters[key] = value
}

override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is FilterObject) return false
return aminoAcidMutations == other.aminoAcidMutations &&
nucleotideMutations == other.nucleotideMutations &&
aminoAcidInsertions == other.aminoAcidInsertions &&
nucleotideInsertions == other.nucleotideInsertions &&
filters == other.filters
}

override fun hashCode(): Int = arrayOf(
aminoAcidMutations,
nucleotideMutations,
aminoAcidInsertions,
nucleotideInsertions,
filters,
).contentHashCode()
}
Loading
Loading