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

✔ Fix the DB storage format #490

Open
Tracked by #601 ...
jon-nfc opened this issue Jan 24, 2025 · 0 comments · Fixed by #605
Open
Tracked by #601 ...

✔ Fix the DB storage format #490

jon-nfc opened this issue Jan 24, 2025 · 0 comments · Fixed by #605
Assignees
Labels
Milestone

Comments

@jon-nfc
Copy link
Member

jon-nfc commented Jan 24, 2025

fix the storage format of history entries.

Details

It has also been discovered that the history entries as they are saved to the database, are being saved as a json string. This is not desirable. Whilst this is not a war stopper and it has enabled the current UI to function, the new UI and API will not be modified to cater for this mishap.

Implementing a fix for the DB format error will break the current interface as far as viewing history is concerned. Whilst currently the new UI can view the history (once the above query is fixed), it's not correctly formatted within the interface, which lowers the UX.

Moving forward the query related fix for the UI will be implemented with the correction to the storage format being corrected when the new UI becomes more stable.

``` diff

diff --git a/app/core/mixin/history_save.py b/app/core/mixin/history_save.py
index e0574d7d..413e62fc 100644
--- a/app/core/mixin/history_save.py
+++ b/app/core/mixin/history_save.py
@@ -67,7 +67,7 @@ class SaveHistory(models.Model):
            if entry not in remove_keys:
                clean[entry] = value

-        before_json = json.dumps(clean)
+        before_json = clean

        clean = {}
        for entry in after:
@@ -107,7 +107,7 @@ class SaveHistory(models.Model):
                clean[entry] = value


-        after_json = json.dumps(clean)
+        after_json = clean

        item_parent_pk = None
        item_parent_class = None

```
- [ ] Create Migration to correct storage format of before and after fields
@jon-nfc jon-nfc changed the title Fix the DB storage format ⚠️ see notes above will need a migration to correct the previous entries diff --git a/app/core/mixin/history_save.py b/app/core/mixin/history_save.py index e0574d7d..413e62fc 100644 --- a/app/core/mixin/history_save.py +++ b/app/core/mixin/history_save.py @@ -67,7 +67,7 @@ class SaveHistory(models.Model): if entry not in remove_keys: clean[entry] = value - before_json = json.dumps(clean) + before_json = clean clean = {} for entry in after: @@ -107,7 +107,7 @@ class SaveHistory(models.Model): clean[entry] = value - after_json = json.dumps(clean) + after_json = clean item_parent_pk = None item_parent_class = None Fix the DB storage format Jan 24, 2025
@jon-nfc jon-nfc added this to the v2.0.0 milestone Jan 24, 2025
@jon-nfc jon-nfc moved this to Backlog in Centurion ERP Jan 24, 2025
@jon-nfc jon-nfc moved this from Backlog to Planning in Centurion ERP Jan 24, 2025
@jon-nfc jon-nfc moved this from Planning to In progress in Centurion ERP Feb 15, 2025
@jon-nfc jon-nfc modified the milestones: v2.0.0, Next Release Feb 15, 2025
@jon-nfc jon-nfc self-assigned this Feb 15, 2025
@jon-nfc jon-nfc changed the title Fix the DB storage format ✔ Fix the DB storage format Feb 15, 2025
@jon-nfc jon-nfc moved this from In progress to Done in Centurion ERP Feb 15, 2025
@jon-nfc jon-nfc linked a pull request Feb 15, 2025 that will close this issue
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant