zeeguu / api

API for tracking a learner's progress when reading materials in a foreign language and recommending further personalized exercises and readings.
https://zeeguu.org
MIT License
8 stars 23 forks source link

Updated settings to avoid concurrency updates #165

Closed tfnribeiro closed 4 months ago

tfnribeiro commented 4 months ago

Changes to avoid conflicts when a user changes to a new language in the front-end settings.

The issue involves changing to a language that the user has not studied and it can reliably cause a concurrency issue in the backend which also causes a failure at the front end.

To solve this, I made that whenever the endpoint is called from the frontend - all the updates are made in the same session and then committed, avoiding the concurrency.

Implementation:

Depends on:

https://github.com/zeeguu/web/pull/406

mircealungu commented 4 months ago

@tfnribeiro - is this ready to merge Tiago? I forgot.

tfnribeiro commented 4 months ago

@mircealungu should be ready to merge!

I removed the native_language_code and learned_language_code, and left only the native_language and learned_language which is the one we are using in the frontend, example:

{
    "email": "rodney@email.com",
    "name": "Rodney Nelson",
    "learned_language": "da",
    "native_language": "en",
    "is_teacher": true,
    "is_student": false,
    "da_min": 0,
    "da_max": 11,
    "da_reading": true,
    "da_exercises": true,
    "da_cefr_level": 5,
    "en_min": 0,
    "en_max": 10,
    "en_reading": false,
    "en_exercises": false,
    "en_cefr_level": 4,
    "es_min": 0,
    "es_max": 10,
    "es_reading": false,
    "es_exercises": false,
    "es_cefr_level": 3,
    "it_min": 0,
    "it_max": 10,
    "it_reading": false,
    "it_exercises": false,
    "it_cefr_level": 0,
    "nl_min": 0,
    "nl_max": 10,
    "nl_reading": false,
    "nl_exercises": false,
    "nl_cefr_level": 4,
    "no_min": 0,
    "no_max": 10,
    "no_reading": false,
    "no_exercises": false,
    "no_cefr_level": 0,
    "pt_min": 0,
    "pt_max": 10,
    "pt_reading": false,
    "pt_exercises": false,
    "pt_cefr_level": 5,
    "hu_min": 0,
    "hu_max": 10,
    "hu_reading": false,
    "hu_exercises": false,
    "hu_cefr_level": 4,
    "features": [
        "extension_experiment_1",
        "tiago_exercises",
        "merle_exercises"
    ],
    "cefr_level": "4"
}