-
Notifications
You must be signed in to change notification settings - Fork 1
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
[PROD] Ensure Appeals always have a country associated #354
Comments
Thanks @batpad . The reason for this specific case was the missing country info in Apple where IFRC manages appeals and which feeds our incoming api data. It was a human error. |
We will start working on this. Basically, we will need to do this. DB fix:Looking at the production, we have something like this. In [2]: from api.models import Appeal, AppealHistory
In [3]: Appeal.objects.filter(country__isnull=True).count()
Out[3]: 0
In [6]: AppealHistory.objects.filter(country__isnull=True).count()
Out[6]: 4 We will need to update Appeal History, then we can easily do the migration change. Schema fix:Currently, we have |
🙏 Thank you @thenav56 ! Let me know if I can help on fixing those AppealHistory objects? |
I've updated the correct country id-s on Staging and on Prod for the null-Country-having appealhistory records. |
So this action item is done :-) |
Yesterday, we had an error on production after an Appeal was ingested without having a Country attached. We need to make sure this cannot happen again.
If it is legitimate / possible that Appeals can be without a Country, then we should make sure the frontend does not fail if an Appeal is missing a Country.
However, I think in all likelihood, we just want to ensure on the backend that this cannot happen that an Appeal is created without a Country.
We should probably:
null=True
for country on the Appeal model, so that the database does not allow null values: https://github.com/IFRCGo/go-api/blob/develop/api/models.py#L895 - this will require checking all existing appeals in the database and writing a migration if needed.None
country, we should raise an exception: https://github.com/IFRCGo/go-api/blob/develop/api/management/commands/ingest_appeals.py#L191 and I guess catch the exception here and just skip inserting this record in case of failing country lookup: https://github.com/IFRCGo/go-api/blob/develop/api/management/commands/ingest_appeals.py#L206 ?We should discuss this - if we think that we want to continue allowing Null values for country on the backend in case the country look-up fails, then we would need to rather make changes on the client to deal with null values for country.
For this particular Appeal where we had the country come in as null, we should investigate why that happened: was this information missing in the upstreeam data, or did we fail to match the country code correctly, or .. ?
cc @frozenhelium @thenav56 @szabozoltan69 @tovari
The text was updated successfully, but these errors were encountered: