Skip to content
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

Updated settings to avoid concurrency updates #165

Merged
merged 4 commits into from
Jun 27, 2024

Conversation

tfnribeiro
Copy link
Collaborator

@tfnribeiro tfnribeiro commented Jun 20, 2024

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:

  • Removed code that is not used anymore related to language_level_data.
  • Whenever we call user.set_learned_language, we now can pass the cefr_level, to ensure the object is updated with the right level.
  • Update test to also check for cefr_level when it's updated

Depends on:

zeeguu/web#406

Copy link
Member

@mircealungu mircealungu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall looking good. one single comment for you to look at

@@ -131,23 +131,20 @@ def user_settings():
user.set_native_language(submitted_native_language_code)

# deprecating the larned_language_code
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why this message is here.

Could it be that it refers to the choosing learned_langauge_code or learned_language? We should look in the web, see which is the one used, and only keep that. The same above with native_language_code and native_language.

@mircealungu
Copy link
Member

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

@tfnribeiro
Copy link
Collaborator Author

tfnribeiro commented Jun 27, 2024

@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": "[email protected]",
    "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"
}

@mircealungu mircealungu merged commit 2494d02 into zeeguu:master Jun 27, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants