bcgov / bcgov/cas-reporting

Remove references to `deepcopy`

Open
#699 0 comments 0 reactions 0 assignees View on GitHub
attn: Devs BACKLOG Backlog Refinement Tech Debt
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

#### Description of the Tech Debt

The ReportSupplementaryVersionService makes extensive use of the `copy.deepcopy` method to clone a report version.
This is at the same time poor practice and slow, this method deep-copies every single attribute of our django models, including all the django internals, when only a few fields should be duplicated.

We could solve it by passing the scope of the copy to the `deepcopy` method, but there is an official, much easier method for duplicating django models: https://docs.djangoproject.com/en/5.0/topics/db/queries/#copying-model-instances

This card is about refactoring the service and removing the use of `deepcopy` in our entire app.

#### 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 | 0 | 0 |
| Developer Fault Risk - How likely will this tech debt cause a future error related to coding on top of it | 0 | 0 |
| System Fault Risk - Risk of system errors or application downtime | 0 | 0 |
| Time Scale Risk - Compound risk effect if left alone. How much more difficult to fix or dangerous will this become over time? | 0 | 0 |
| Time Sink Risk - How much will this tech debt slow the development process down | 0 | 0 |
|

**TOTAL SCORE:** | 0 | 0 |

#### Development Checklist:

- [ ] Checklist item
- [ ] Checklist item
- [ ] Checklist item

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating ReportSupplementaryVersionService and search the application for uses of copy.deepcopy. Read Django's documented model-copying approach linked in the issue, then identify each affected model-copy path. Done means the application's deepcopy references for this work are removed and the relevant behavior remains covered by the existing test suite.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python
Domain
backend, database
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.