-
Notifications
You must be signed in to change notification settings - Fork 148
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
Importer doesn't create general contributions #1839
Comments
Hm, shouldn't the questionnaire assign view just create it if users tried to use the general contribution? Or, if we dont want to allow that, it shouldnt display an option to assign to the general questionnaire, right? Do we currently have some invariants about what questionnaires exist for an evaluation? If so, we should probably enforce them with database contraints (#1800 could get another point) |
So the problem is that the importer uses I wouldn't want to duplicate the "when a new evaluation is created, we also must create a general contribution for it" logic across the codebase. We could defer creation of the general contribution to its first access using the getter for the If we use I would really like to keep the bulk operations for performance, but the only way to make them work with As a quick fix, we can revert to For production right now, calling the |
After #1841, it's ~7s (bulk_create) vs ~12s (save) for me locally for a 6000 rows import file. Probably acceptable for now, as it only affects the import run and not test runs. |
Sooooo, should we take the 8s hit in a hotfix now-ish, and make it faster again next year? Or should I review the performance PR and we merge that in the next couple of days? |
The performance PR should be unrelated, I just wanted to have it to have some numbers regarding performance impact of I just stumbled across this test: EvaP/evap/evaluation/tests/test_models.py Lines 212 to 220 in e889dce
and I was a bit confused here. We create an evaluation without a Also, the getter for the general contribution explicitly handles the "does not exist yet" state, and explicitly returns EvaP/evap/evaluation/models.py Lines 776 to 784 in e889dce
Is the intention here to handle I guess this comes back to @niklasmohrin's point in #1839 (comment): What is our invariant? I see three possibilities
We considered allowing not to have a general contribution in #1246, it seems there was no good fundamental reason to enfore existence of the general contribution, it just happened to be what we first implemented. We didn't consider Related (and funny) PR / issue combination: #1259 and #1260. |
If that's the case, I suppose the try-except could be obsolete with the I was trying to come up with a good solution for thirty minutes or so and I always come back wondering whether we should have Maybe at the other end: If we keep the models as they are: I don't know, I think always having the general contribution seems like the easier invariant to reason about.
Yeah, probably. Let's annoy our future selves and just throw an exception in the |
…eate Importers: Use .save() instead of `bulk_` operations to fix #1839
When importing enrollment data, no
general_contribution
s are created for the newly added evaluations. This prevents managers from, e.g., using the "assign questionnaires" feature which fails with anAttributeError
:The importer should make sure that every new evaluation has a
general_contribution
.The text was updated successfully, but these errors were encountered: