bcgov / cas-registration

A web app for Registration in OBPS under the Clean Growth branch
Apache License 2.0
1 stars 1 forks source link

Replace django's update_or_create with custom_update_or_create #2273

Open BCerki opened 1 month ago

BCerki commented 1 month ago

Description of the Tech Debt

Django's update_or_create can't handle a None foreign key: django.core.exceptions.ValidationError: {'id': ['This field cannot be null.']}. We created custom_update_or_create that can manage a None key (which is needed because anytime you create, the key is None), so this ticket is about replacing the update_or_create with the custom function.

Tech Debt Triage

The purpose of our technical debt triage process is to analyze technical debt to determine risk level of the technical debt and the value in tackling that technical debt.

Risk Value Scoring:

Level Value
High 3
Medium 2
Low 1
Technical Debt - Risk Types Level Value
Business Area Risk - Risk of business area visibility / damage to user experience
Developer Fault Risk - How likely will this tech debt cause a future error related to coding on top of it
System Fault Risk - Risk of system errors or application downtime
Time Scale Risk - Compound risk effect if left alone. How much more difficult to fix or dangerous will this become over time?
Time Sink Risk - How much will this tech debt slow the development process down
TOTAL SCORE:
BCerki commented 1 month ago

@Sepehr-Sobhani would you like to add anything to this?

Sepehr-Sobhani commented 1 month ago

@Sepehr-Sobhani would you like to add anything to this?

We currently have this new method as a Django model method. We need to pass the model as the first argument. However, if we want to mirror the behavior of the built-in update_or_create function, we need to add it to the model manager so that we can call it like Model.objects.custom_update_or_create(...).