-
Notifications
You must be signed in to change notification settings - Fork 9
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
Patient model (from bacherlor thesis) #490
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't tested it out yet.
...ges/exercises/exercise/shared/exercise-map/shared/patient-popup/patient-popup.component.html
Outdated
Show resolved
Hide resolved
@@ -98,7 +102,36 @@ <h5 class="popover-header"> | |||
Verletzungs-Geschwindigkeit: | |||
</th> | |||
<td class="font-monospace"> | |||
×{{ patient.timeSpeed }} | |||
<select |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a dropdown here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would mean writing code, just to end up with a self implemented select input.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Dassderdie What do you think?
...ges/exercises/exercise/shared/exercise-map/shared/patient-popup/patient-popup.component.html
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still haven't tried it out, but the code looks much better now.
frontend/src/app/pages/exercises/exercise/shared/utility/parse-csv.ts
Outdated
Show resolved
Hide resolved
frontend/src/app/pages/exercises/exercise/shared/utility/parse-csv.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix these visual bugs (especially the one with the colors), then I can review this further.
...src/app/pages/exercises/exercise/shared/trainer-map-editor/trainer-map-editor.component.html
Outdated
Show resolved
Hide resolved
frontend/src/app/pages/exercises/exercise/shared/utility/parse-csv.ts
Outdated
Show resolved
Hide resolved
frontend/src/app/pages/exercises/exercise/shared/utility/parse-csv.ts
Outdated
Show resolved
Hide resolved
frontend/src/app/pages/exercises/exercise/shared/utility/parse-csv.ts
Outdated
Show resolved
Hide resolved
return 'black'; | ||
case 'blau': | ||
return 'blue'; | ||
default: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe throw something here? Or use as 'blau' | 'gelb' | 'grün' | 'rot' | 'schwarz'
in the switch (color[0])
line?
But don't have an empty default
and then just return something you know will never match. Probably as
is the better solution. @Dassderdie Any thoughts on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of a switch statement you should use an object literal as a map.
This should then result in something like:
colorTranslationMap[color[0]]!;
...src/app/pages/exercises/exercise/shared/trainer-map-editor/trainer-map-editor.component.html
Show resolved
Hide resolved
...src/app/pages/exercises/exercise/shared/trainer-map-editor/trainer-map-editor.component.html
Outdated
Show resolved
Hide resolved
) {} | ||
} | ||
|
||
function generateHealthStates( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something about the generation of the condition parameters seems to be wrong, only two of the templates of the CSV actually have conditions. For this reason, the patients don't change their state.
@hpistudent72 Are you planning to finish this or should someone else continue this PR? |
@Dassderdie @ClFeSc One of you interested in continuing this? I could also try to get this done. |
I could try to do it. |
Ok, if you need help, just write. |
@ClFeSc are you still working on this? This feature would be interesting for our future development. We could also try to support you on this, this way we could also get familiar with the new features quickly. |
currentPatient.treatmentHistory.shift(); | ||
currentPatient.treatmentHistory.push( | ||
patientUpdate.newTreatment | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably a big performance problem as this means that for every tick for every patient, a new array with 60 items is created (immutability via the immer.js proxy).
Here is a proposal for a better solution:
This value probably doesn't change very often. Therefore, one could compress intervals with the same treatment status.
interface Interval {
/**
* Corresponds to the exerciseTime
*/
startTime: number,
value: { gf: number, .... }
}
class TreatmentHistory {
// in seconds
static readonly maxLength = 60;
// If the newTreatment is different to the treatment in the last interval, add it (with the current exerciseTime)
// and remove all intervals that are older than (exerciseTime - maxLength)
// else do nothing
static addTreatment(intervalls: Intervall[], newTreatment: {gf: number, ...}, exerciseTime)
static getAverageTreatment(...)
}
A Patient would then have treatmentHistory: Intervall[]
or something like this.
This would reduce write time (expensive due to immutability) and slightly increase read time (not done very often).
One could also either remove the PatientUpdates from the Tick action or at least only send those for patients that changed their treatment. This would reduce the state-history size by a lot and could either slightly reduce or increase the performance (more calculation on the client vs. less parsing, reduced usage of the WebSocket connection, and less overhead on the server). This would also have big repercussions on the migrations.
Guidelines: "Premature optimization is the root of all evil.", Use the benchmark script.
Generally, yes. However, currently, I'm a bit short of time. But I'll look into resolving the merge conflicts this weekend, and we can see where we'll go from there. |
Co-authored-by: Florian <[email protected]> * Continuation of #490
* Continuation of #490 Co-authored-by: Florian <[email protected]>
* Continuation of #490 Co-authored-by: Florian <[email protected]>
Closes #335
Closes #402