Skip to content

Commit

Permalink
Merge branch 'develop' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
jekutzsche committed Mar 14, 2022
2 parents 4902abd + e2cbe3c commit e60676f
Show file tree
Hide file tree
Showing 17 changed files with 299 additions and 46 deletions.
19 changes: 19 additions & 0 deletions infrastructure/deployment/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ services:
depends_on:
- logger
restart: unless-stopped
labels:
- "com.centurylinklabs.watchtower.scope=${IRIS_CLIENT_DOMAIN}"

# IRIS Client backend for frontend
iris-client:
Expand Down Expand Up @@ -63,6 +65,8 @@ services:
timeout: 3s
retries: 2
start_period: 10s
labels:
- "com.centurylinklabs.watchtower.scope=${IRIS_CLIENT_DOMAIN}"

# IRIS Client Frontend for users
iris-frontend:
Expand All @@ -78,6 +82,8 @@ services:
depends_on:
- iris-client
restart: unless-stopped
labels:
- "com.centurylinklabs.watchtower.scope=${IRIS_CLIENT_DOMAIN}"

# Endpoint server to communicate with Apps and IRIS Connect central services
eps:
Expand All @@ -98,6 +104,8 @@ services:
EPS_CLIENT_CERT:
EPS_CLIENT_CERT_KEY:
restart: unless-stopped
labels:
- "com.centurylinklabs.watchtower.scope=${IRIS_CLIENT_DOMAIN}"

# Proxy for inbound connections.
private-proxy:
Expand All @@ -124,6 +132,8 @@ services:
- logger
- private-proxy-eps
restart: unless-stopped
labels:
- "com.centurylinklabs.watchtower.scope=${IRIS_CLIENT_DOMAIN}"

private-proxy-eps:
image: inoeg/iris-client-eps:1.5-latest
Expand All @@ -143,6 +153,8 @@ services:
depends_on:
- logger
restart: unless-stopped
labels:
- "com.centurylinklabs.watchtower.scope=${IRIS_CLIENT_DOMAIN}"

# Reverse Proxy
nginx:
Expand All @@ -159,6 +171,8 @@ services:
- iris-client
- iris-frontend
restart: unless-stopped
labels:
- "com.centurylinklabs.watchtower.scope=${IRIS_CLIENT_DOMAIN}"

# Watchtower for auto-updates
watchtower:
Expand All @@ -172,9 +186,12 @@ services:
TZ: Europe/Berlin
WATCHTOWER_SCHEDULE: 0 0 3 * * *
WATCHTOWER_NO_PULL: "true"
WATCHTOWER_SCOPE: "${IRIS_CLIENT_DOMAIN}"
depends_on:
- nginx
restart: unless-stopped
labels:
- "com.centurylinklabs.watchtower.scope=${IRIS_CLIENT_DOMAIN}"

# Log shipper
logger:
Expand All @@ -196,6 +213,8 @@ services:
- ${LOG_FOLDER:-./logs}:/srv/logs
- /var/run/docker.sock:/var/run/docker.sock
restart: unless-stopped
labels:
- "com.centurylinklabs.watchtower.scope=${IRIS_CLIENT_DOMAIN}"

volumes:
psqldata_iris:
Expand Down
25 changes: 22 additions & 3 deletions infrastructure/dev/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,16 @@ services:
timeout: 3s
retries: 4
start_period: 30s
labels:
- "com.centurylinklabs.watchtower.scope=${IRIS_CLIENT_DOMAIN}"

# IRIS Client backend for frontend (autoupdated by watchtower)
iris-client:
image: inoeg/iris-client-bff:${CLIENT_VERSION}
expose:
- 8092
labels:
- "com.centurylinklabs.watchtower.enable=true"
- "com.centurylinklabs.watchtower.scope=${IRIS_CLIENT_DOMAIN}"
environment:
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/${POSTGRES_USER}
SPRING_DATASOURCE_USERNAME: ${POSTGRES_USER}
Expand Down Expand Up @@ -83,7 +85,7 @@ services:
expose:
- 28080
labels:
- "com.centurylinklabs.watchtower.enable=true"
- "com.centurylinklabs.watchtower.scope=${IRIS_CLIENT_DOMAIN}"
environment:
SORMAS_SIDECAR_BASE_URL: /api
CSV_EXPORT_STANDARD_ATOMIC_ADDRESS: "true"
Expand All @@ -104,14 +106,16 @@ services:
environment:
- EPS_SETTINGS=settings/roles/hd-1
command: ["--level", "debug", "server", "run"]
labels:
- "com.centurylinklabs.watchtower.scope=${IRIS_CLIENT_DOMAIN}"

# Reverse Proxy
nginx:
image: inoeg/iris-client-nginx:develop
ports:
- ${NGINX_PORT}:443
labels:
- "com.centurylinklabs.watchtower.enable=true"
- "com.centurylinklabs.watchtower.scope=${IRIS_CLIENT_DOMAIN}"
environment:
IRIS_CLIENT_DOMAIN:
IRIS_CLIENT_DOMAIN_CERT:
Expand All @@ -135,6 +139,8 @@ services:
- PROXY_SETTINGS=settings/roles/private-proxy-1
- MOUNT_POINTS=/app/settings,/private-proxy
command: [ "--level", "trace", "run", "private" ]
labels:
- "com.centurylinklabs.watchtower.scope=${IRIS_CLIENT_DOMAIN}"

private-proxy-1:
image: inoeg/eps:${EPS_VERSION}
Expand All @@ -146,6 +152,19 @@ services:
environment:
- EPS_SETTINGS=settings/roles/private-proxy-eps-1
command: [ "--level", "trace", "server", "run" ]
labels:
- "com.centurylinklabs.watchtower.scope=${IRIS_CLIENT_DOMAIN}"

watchtower:
image: containrrr/watchtower
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
TZ: Europe/Berlin
WATCHTOWER_POLL_INTERVAL: 60
WATCHTOWER_SCOPE: "${IRIS_CLIENT_DOMAIN}"
labels:
- "com.centurylinklabs.watchtower.scope=${IRIS_CLIENT_DOMAIN}"

volumes:
psqldata_iris:
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package iris.client_bff.vaccination_info;

import static iris.client_bff.vaccination_info.VaccinationStatus.*;

import iris.client_bff.core.Aggregate;
import iris.client_bff.core.Id;
import iris.client_bff.core.Sex;
Expand All @@ -18,16 +20,9 @@
import java.time.LocalDate;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.*;

import org.hibernate.search.engine.backend.types.Sortable;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField;
Expand All @@ -44,7 +39,6 @@
@Data
@Setter(AccessLevel.PACKAGE)
@EqualsAndHashCode(callSuper = true, of = {})
@AllArgsConstructor(staticName = "of")
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class VaccinationInfo extends Aggregate<VaccinationInfo, VaccinationInfoIdentifier> {

Expand All @@ -61,6 +55,34 @@ public class VaccinationInfo extends Aggregate<VaccinationInfo, VaccinationInfoI
@JoinColumn(name = "vaccination_info_id", nullable = false)
private Set<Employee> employees;

@IndexedEmbedded
private final VaccinationStatusCount vaccinationStatusCount = new VaccinationStatusCount();

public static VaccinationInfo of(String externalId, Facility facility, Set<Employee> createEmployees) {
return new VaccinationInfo(externalId, facility, createEmployees);
}

VaccinationInfo(String externalId, Facility facility, Set<Employee> employees) {

this.externalId = externalId;
this.facility = facility;
this.employees = employees;

determineStatusCounts();
}

@PrePersist
@PostLoad
void determineStatusCounts() {
vaccinationStatusCount.determineCounts(getEmployees());
}

void setEmployees(Set<Employee> employees) {

this.employees = employees;
determineStatusCounts();
}

@Embeddable
@EqualsAndHashCode
@RequiredArgsConstructor(staticName = "of")
Expand Down Expand Up @@ -89,6 +111,43 @@ public String toString() {
}
}

@Embeddable
@Data
@Setter(AccessLevel.PACKAGE)
@AllArgsConstructor(staticName = "of")
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public static class VaccinationStatusCount {

@Column(name = "status_vaccinated_count")
@GenericField(sortable = Sortable.YES)
private long vaccinated;

@Column(name = "status_not_vaccinated_count")
@GenericField(sortable = Sortable.YES)
private long notVaccinated;

@Column(name = "status_suspicious_proof_count")
@GenericField(sortable = Sortable.YES)
private long suspiciousProof;

@Column(name = "status_unknown_count")
@GenericField(sortable = Sortable.YES)
private long unknown;

void determineCounts(Set<Employee> employees) {

var statusCountMap = employees.stream()
.collect(Collectors.groupingBy(
VaccinationInfo.Employee::getVaccinationStatus,
Collectors.counting()));

vaccinated = statusCountMap.getOrDefault(VACCINATED, 0l);
notVaccinated = statusCountMap.getOrDefault(NOT_VACCINATED, 0l);
suspiciousProof = statusCountMap.getOrDefault(SUSPICIOUS_PROOF, 0l);
unknown = statusCountMap.getOrDefault(UNKNOWN, 0l);
}
}

@Embeddable
@Data
@Setter(AccessLevel.PACKAGE)
Expand Down Expand Up @@ -155,4 +214,5 @@ public static class Employee {
@GenericField(sortable = Sortable.YES)
private VaccinationStatus vaccinationStatus;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
import java.util.stream.Collectors;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.http.HttpStatus;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -42,13 +44,31 @@ public Page<VaccinationReportDto> getVaccinationInfos(
@RequestParam Optional<@NoSignOfAttack String> search,
Pageable pageable) {

var newPageable = adaptPageable(pageable);

var vaccInfos = search
.map(it -> service.search(it, pageable))
.orElseGet(() -> service.getAll(pageable));
.orElseGet(() -> service.getAll(newPageable));

return vaccInfos.map(this::map);
}

private PageRequest adaptPageable(Pageable pageable) {

var sort = pageable.getSort();
var orders = sort.map(it -> {
if (it.getProperty().equals("reportedAt")) {
return it.withProperty("metadata.created");
}

return it;
}).toList();

sort = Sort.by(orders);

return PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), sort);
}

@GetMapping("/{id}")
public VaccinationReportDetailsDto getDetails(@PathVariable VaccinationInfoIdentifier id) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ CREATE TABLE vaccination_infos (
facility_contact_last_name varchar(100) NULL,
facility_contact_email varchar(100) NULL,
facility_contact_phone varchar(100) NULL,
status_vaccinated_count bigint NOT NULL,
status_not_vaccinated_count bigint NOT NULL,
status_suspicious_proof_count bigint NOT NULL,
status_unknown_count bigint NOT NULL,
created timestamp NOT NULL,
last_modified timestamp NOT NULL,
created_by uuid NULL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ CREATE TABLE vaccination_infos (
facility_contact_last_name varchar(100) NULL,
facility_contact_email varchar(100) NULL,
facility_contact_phone varchar(100) NULL,
status_vaccinated_count bigint NOT NULL,
status_not_vaccinated_count bigint NOT NULL,
status_suspicious_proof_count bigint NOT NULL,
status_unknown_count bigint NOT NULL,
created datetime2 NOT NULL,
last_modified datetime2 NOT NULL,
created_by binary(255) NULL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ CREATE TABLE vaccination_infos (
facility_contact_last_name varchar(100) NULL,
facility_contact_email varchar(100) NULL,
facility_contact_phone varchar(100) NULL,
status_vaccinated_count bigint NOT NULL,
status_not_vaccinated_count bigint NOT NULL,
status_suspicious_proof_count bigint NOT NULL,
status_unknown_count bigint NOT NULL,
created datetime NOT NULL,
last_modified datetime NOT NULL,
created_by binary(16) NULL,
Expand Down
Loading

0 comments on commit e60676f

Please sign in to comment.