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

History does not appear to be working for self #414

Open
3 tasks
Tracked by #408
jon-nfc opened this issue Nov 30, 2024 · 1 comment
Open
3 tasks
Tracked by #408

History does not appear to be working for self #414

jon-nfc opened this issue Nov 30, 2024 · 1 comment
Labels
bug::regression Bug reason type::bug Issue Type v1.2-beta Version Affected. v1.2.0 Version Affected. v1.2.1 Version Affected. v1.2.2 Version Affected. v1.3.0 Version Affected. v1.3.1 Version Affected. v1.4.0 Version Affected. v1.4.1 Version Affected.
Milestone

Comments

@jon-nfc
Copy link
Member

jon-nfc commented Nov 30, 2024

On a fresh install, after adding a device, software and device type there is no create history for the model.

for sub models when they are added to the primary model, it does create a history entry.


After looking into this issue, the history is still being created the bug is that the query for the history items is incorrect.

self.queryset = queryset.filter(
item_parent_class = self.kwargs['model_class'],
item_parent_pk = self.kwargs['model_id']
).order_by('-created')

The above is only querying for child models and not the actual model like this one.

Q(item_pk = model_pk, item_class = model_name)
|
Q(item_parent_pk = model_pk, item_parent_class = model_name)

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.

Task

  • Correct API DB history query

  • 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
    
    • Create Migration to correct storage format of before and after fields
@jon-nfc jon-nfc added type::bug Issue Type bug::regression Bug reason labels Nov 30, 2024
@jon-nfc jon-nfc added this to the next release milestone Nov 30, 2024
@jon-nfc jon-nfc moved this to Planning in Centurion ERP Nov 30, 2024
@jon-nfc jon-nfc added v1.4.0 Version Affected. v1.4.1 Version Affected. labels Dec 1, 2024
@jon-nfc
Copy link
Member Author

jon-nfc commented Dec 1, 2024

/cc @jasonpagetas

@jon-nfc jon-nfc added v1.3.0 Version Affected. v1.3.1 Version Affected. v1.2-beta Version Affected. v1.2.0 Version Affected. v1.2.1 Version Affected. v1.2.2 Version Affected. labels Dec 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug::regression Bug reason type::bug Issue Type v1.2-beta Version Affected. v1.2.0 Version Affected. v1.2.1 Version Affected. v1.2.2 Version Affected. v1.3.0 Version Affected. v1.3.1 Version Affected. v1.4.0 Version Affected. v1.4.1 Version Affected.
Projects
Status: Planning
Development

No branches or pull requests

1 participant