Skip to content

Commit

Permalink
Merge pull request #747 from hpi-sam/release/v0.2.0
Browse files Browse the repository at this point in the history
Release v0.2.0
  • Loading branch information
Greenscreen23 authored Mar 10, 2023
2 parents 278a970 + 7c3d826 commit 4167831
Show file tree
Hide file tree
Showing 140 changed files with 4,260 additions and 1,504 deletions.
9 changes: 0 additions & 9 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,3 @@
* text=auto
# docker-entrypoint.sh needs LF (see https://github.com/hpi-sam/digital-fuesim-manv/issues/479)
docker/docker-entrypoint.sh eol=lf

# Git lfs
*.jpg filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.jpeg filter=lfs diff=lfs merge=lfs -text
*.mp4 filter=lfs diff=lfs merge=lfs -text
*.mov filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text

12 changes: 0 additions & 12 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,6 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
lfs: 'true'
- uses: actions/setup-node@v3
with:
node-version: '18'
Expand Down Expand Up @@ -259,11 +257,6 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
lfs: 'true'
- name: checkoutLFS
uses: actions/checkout@v3
- run: git lfs pull
# Source: https://docs.docker.com/ci-cd/github-actions/
- name: Login to docker
uses: docker/login-action@v2
Expand Down Expand Up @@ -293,15 +286,10 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
lfs: 'true'
- name: checkoutLFS
uses: actions/checkout@v3
- name: Extract version
run: |
versionName=`jq -jM .version package.json`
echo "version_name=$versionName" >> "$GITHUB_ENV"
- run: git lfs pull
# Source: https://docs.docker.com/ci-cd/github-actions/
- name: Login to docker
uses: docker/login-action@v2
Expand Down
35 changes: 34 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,38 @@ and this project does **not** adhere to [Semantic Versioning](https://semver.org

## [Unreleased]

## [0.2.0] - 2023-03-10

### Added

- The popup of a simulated region now has five tabs: _Overview_, _Patients, \_Transfers_, _Hospitals_ and _Behaviors_
- The _Overview_ tab allows setting the name of the simulated region and shows the current number of patients, vehicles, personnel and material
- The _Patients_ tab lists all patients in the simulated region and allows inspecting their detailed information.
When clicking on a patient somewhere else in the popup (e.g. in the treat patients behavior details), the patient will be shown in this tab.
- The _Transfers_ tab allows setting up transfer connections from/to other simulated regions and/or transfer points
- The _Hospitals_ tab allows setting up transfer connections to hospitals
- The _Behaviors_ tab allows adding and removing behaviors from simulated regions, inspect their current state and customize their settings
- For the assign leader behavior, the type of the currently assigned leader is shown
- For the treat patients behavior, the current treatment phase is shown. Additionally the matching from patients to personnel is shown, including information on how many patients are treated by the same personnel at a time and the visible status and progression of the patients. There are also settings for how often the matching is recalculated and how long it takes to count patients.
- For the unload arrived vehicles behavior, the unload duration can be set and all currently unloading vehicles are listed with their remaining time
- To manage exercises with a large amount of simulated regions easily, a large modal has been added that can be used to manage all simulated regions
- Every simulated region popup shows a button to view the current simulated region in this modal
- Simulated Regions now act as transfer points, meaning that they can be start and destination of a transfer
- Connection lines will be shown for transfer connections from/to simulated regions, too

### Changed

- Images are now stored in git and not git lfs anymore
- Patients, vehicles, personnel and material inside a simulated region are now deleted, when the simulated region is deleted. For vehicles, personnel, and material, they will only be deleted if all that belong together are in the same simulated region.

### Fixed

- Making a _Gruppenführer_ leader of a simulated region if the region already had a leader did not work. Now, if there already is a leader, better personnel (i.e. the old leader was not a _Gruppenführer_ but the new one is) will be chosen as new leader
- When a _Gruppenführer_ is leader of a simulated region, the treat patients behavior no longer stops working
- Errors in migrating exercises lo longer crash the backend
- If the history of an exercise cannot be restored, it is now dropped and the current state is used
- Actions that affect vehicles that are not fully loaded will now be removed in migrations, enabling the restoration of most of the history

## [0.1.0] - 2023-03-01

### Added
Expand Down Expand Up @@ -44,6 +76,7 @@ and this project does **not** adhere to [Semantic Versioning](https://semver.org

### Initial unstable release of Digitale FüSim MANV

[Unreleased]: https://github.com/hpi-sam/digital-fuesim-manv/compare/0.1.0...HEAD
[Unreleased]: https://github.com/hpi-sam/digital-fuesim-manv/compare/0.2.0...HEAD
[0.2.0]: https://github.com/hpi-sam/digital-fuesim-manv/compare/0.1.0...0.2.0
[0.1.0]: https://github.com/hpi-sam/digital-fuesim-manv/compare/v0.0.0...0.1.0
[0.0.0]: https://github.com/hpi-sam/digital-fuesim-manv/compare/37bd43bc1beb4aa9ad597b1ac763dd71b5709737...v0.0.0
19 changes: 8 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,16 @@ This project is currently developed as a [bachelor project](https://hpi.de/en/st

## Installation

1. Make sure to have [git lfs](https://git-lfs.github.com/) installed.
2. Install [NodeJs](https://nodejs.org/) (at least version 18.x) (if you need different node versions on your machine we recommend [nvm](https://github.com/nvm-sh/nvm) or [nvm for windows](https://github.com/coreybutler/nvm-windows))
3. [npm](https://www.npmjs.com/) should already come with NodeJs - if not install it
4. Clone this repository
5. Run `npm run setup` from the root folder
6. Copy the [`.env.example`](./.env.example) file to `./.env` and adjust the settings as you need them. Note that some of the variables are explained under the next point.
7. Choose whether you want to use a database:
1. Install [NodeJs](https://nodejs.org/) (at least version 18.x) (if you need different node versions on your machine we recommend [nvm](https://github.com/nvm-sh/nvm) or [nvm for windows](https://github.com/coreybutler/nvm-windows))
2. [npm](https://www.npmjs.com/) should already come with NodeJs - if not install it
3. Clone this repository
4. Run `npm run setup` from the root folder
5. Copy the [`.env.example`](./.env.example) file to `./.env` and adjust the settings as you need them. Note that some of the variables are explained under the next point.
6. Choose whether you want to use a database:
You can (optionally) use a database for the persistence of exercise data. Look at the [relevant section](./backend/README.md#database) in the backend README for further information.
Note that to not use the database you have to edit an environment variable, see the [relevant section](./backend/README.md#without-a-database).
8. (Optional) We have a list of recommended [vscode](https://code.visualstudio.com/) extensions. We strongly recommend you to use them if you are developing. You can see them via [the `@recommended` filter in the extensions panel](https://code.visualstudio.com/docs/editor/extension-marketplace#_recommended-extensions).
9. (Optional) We have prepared default settings, tasks and debug configurations for VS Code. You can find them in `.vscode/*.example`. Crete a copy of those files removing the `.example` and adjust them to your needs. The files without `.example`-Extensions are untracked so your adjustments won't be committed automatically.
7. (Optional) We have a list of recommended [vscode](https://code.visualstudio.com/) extensions. We strongly recommend you to use them if you are developing. You can see them via [the `@recommended` filter in the extensions panel](https://code.visualstudio.com/docs/editor/extension-marketplace#_recommended-extensions).
8. (Optional) We have prepared default settings, tasks and debug configurations for VS Code. You can find them in `.vscode/*.example`. Crete a copy of those files removing the `.example` and adjust them to your needs. The files without `.example`-Extensions are untracked so your adjustments won't be committed automatically.

## Starting for development

Expand Down Expand Up @@ -95,8 +94,6 @@ Note the database requirements depicted in [the installation section](#installat

## Before you commit

- We are using [git lfs](https://git-lfs.github.com/). You can see the file types that currently use git lfs in [.gitattributes](.gitattributes). If you add another binary (or very large) file type to the repository you should add it there too.
- To see the images stored in [git lfs](https://git-lfs.github.com/) in diff views in vscode we recommend running the following command once: `git config diff.lfs.textconv cat`.
- We are using [prettier](https://prettier.io/) as our code formatter. Run it via `npm run prettier` or `npm run prettier:windows` in the root to format all files and make the CI happy. Please use the [vscode extension](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode).
- We are using [eslint](https://eslint.org/) as our linter. Run it via `npm run lint:fix` in the root to lint (and auto fix if possible) all files. Please use the [vscode extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint).

Expand Down
6 changes: 3 additions & 3 deletions backend/package-lock.json

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

2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "digital-fuesim-manv-backend",
"version": "0.1.0",
"version": "0.2.0",
"type": "module",
"scripts": {
"start:once:linux-macos": "NODE_ENV=production node --experimental-specifier-resolution=node dist/src/index.js",
Expand Down
109 changes: 57 additions & 52 deletions backend/src/database/migrate-in-database.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { UUID } from 'digital-fuesim-manv-shared';
import type { ExerciseState, Mutable, UUID } from 'digital-fuesim-manv-shared';
import { applyMigrations } from 'digital-fuesim-manv-shared';
import type { EntityManager } from 'typeorm';
import { RestoreError } from '../utils/restore-error';
Expand All @@ -18,77 +18,82 @@ export async function migrateInDatabase(
exerciseId
);
}
const initialState = JSON.parse(exercise.initialStateString);
const currentState = JSON.parse(exercise.currentStateString);
const actions = (
const loadedInitialState = JSON.parse(exercise.initialStateString);
const loadedCurrentState = JSON.parse(exercise.currentStateString);
const loadedActions = (
await entityManager.find(ActionWrapperEntity, {
where: { exercise: { id: exerciseId } },
select: { actionString: true },
order: { index: 'ASC' },
})
).map((action) => JSON.parse(action.actionString));
const newVersion = applyMigrations(exercise.stateVersion, {
currentState,
const {
newVersion,
migratedProperties: { currentState, history },
} = applyMigrations(exercise.stateVersion, {
currentState: loadedCurrentState,
history: {
initialState,
actions,
initialState: loadedInitialState,
actions: loadedActions,
},
});
const initialState: Mutable<ExerciseState> =
history?.initialState ?? currentState;
const actions = history?.actions ?? [];

exercise.stateVersion = newVersion;
// Save exercise wrapper
const patch: Partial<ExerciseWrapperEntity> = {
stateVersion: exercise.stateVersion,
initialStateString: JSON.stringify(initialState),
currentStateString: JSON.stringify(currentState),
};
patch.initialStateString = JSON.stringify(initialState);
patch.currentStateString = JSON.stringify(currentState);
await entityManager.update(
ExerciseWrapperEntity,
{ id: exerciseId },
patch
);
// Save actions
if (actions !== undefined) {
let patchedActionsIndex = 0;
const indicesToRemove: number[] = [];
const actionsToUpdate: {
previousIndex: number;
newIndex: number;
actionString: string;
}[] = [];
actions.forEach((action, i) => {
if (action === null) {
indicesToRemove.push(i);
return;
}
actionsToUpdate.push({
previousIndex: i,
newIndex: patchedActionsIndex++,
actionString: JSON.stringify(action),
});
});
if (indicesToRemove.length > 0) {
await entityManager
.createQueryBuilder()
.delete()
.from(ActionWrapperEntity)
// eslint-disable-next-line unicorn/string-content
.where('index IN (:...ids)', { ids: indicesToRemove })
.execute();
}
if (actionsToUpdate.length > 0) {
await Promise.all(
actionsToUpdate.map(
async ({ previousIndex, newIndex, actionString }) =>
entityManager.update(
ActionWrapperEntity,
{
index: previousIndex,
exercise: { id: exerciseId },
},
{ actionString, index: newIndex }
)
)
);
let patchedActionsIndex = 0;
const indicesToRemove: number[] = [];
const actionsToUpdate: {
previousIndex: number;
newIndex: number;
actionString: string;
}[] = [];
actions.forEach((action, i) => {
if (action === null) {
indicesToRemove.push(i);
return;
}
actionsToUpdate.push({
previousIndex: i,
newIndex: patchedActionsIndex++,
actionString: JSON.stringify(action),
});
});
if (indicesToRemove.length > 0) {
await entityManager
.createQueryBuilder()
.delete()
.from(ActionWrapperEntity)
// eslint-disable-next-line unicorn/string-content
.where('index IN (:...ids)', { ids: indicesToRemove })
.execute();
}
if (actionsToUpdate.length > 0) {
await Promise.all(
actionsToUpdate.map(
async ({ previousIndex, newIndex, actionString }) =>
entityManager.update(
ActionWrapperEntity,
{
index: previousIndex,
exercise: { id: exerciseId },
},
{ actionString, index: newIndex }
)
)
);
}
}
6 changes: 3 additions & 3 deletions benchmark/package-lock.json

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

2 changes: 1 addition & 1 deletion benchmark/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "digital-fuesim-manv-benchmark",
"version": "0.1.0",
"version": "0.2.0",
"type": "module",
"scripts": {
"lint": "eslint --max-warnings 0 --ignore-path .gitignore \"./**/*.{ts,js,yml,html}\"",
Expand Down
2 changes: 1 addition & 1 deletion docs/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ openapi: 3.0.3
info:
title: Digital Fuesim MANV HTTP API
description: HTTP API of the digital-fuesim-manv project
version: 0.1.0
version: 0.2.0
paths:
/api/health:
get:
Expand Down
6 changes: 3 additions & 3 deletions frontend/cypress/e2e/exercise.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,8 @@ describe('A trainer on the exercise page', () => {
cy.getState().its('exerciseState').its('hospitals').should('be.empty');
});

it('can manage transfer points and transfer vehicles', () => {
cy.dragToMap('[data-cy=draggableTransferPointDiv]');
it('can manage transfer points (within simulated regions) and transfer vehicles', () => {
cy.dragToMap('[data-cy=draggableSimulatedRegionDiv]');
cy.dragToMap('[data-cy=draggableTransferPointDiv]');

cy.wait(commonErrorTimeout);
Expand Down Expand Up @@ -652,7 +652,7 @@ describe('A trainer on the exercise page', () => {
.itsValues()
.firstElement()
.its('position')
.should('have.property', 'type', 'coordinates');
.should('have.property', 'type', 'simulatedRegion');
});

it('can start and stop an exercise', () => {
Expand Down
6 changes: 3 additions & 3 deletions frontend/package-lock.json

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

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "digital-fuesim-manv-frontend",
"version": "0.1.0",
"version": "0.2.0",
"type": "module",
"scripts": {
"cy:open": "cypress open",
Expand Down
Loading

0 comments on commit 4167831

Please sign in to comment.