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

feat(audit): add change details to AuditLog #3218

Merged
merged 9 commits into from
Jan 8, 2024

Conversation

matthewelwell
Copy link
Contributor

@matthewelwell matthewelwell commented Dec 22, 2023

Changes

This PR adds the change details to the API when retrieving a record from the AuditLog. To achieve this, I have added a new endpoint to retrieve an individual AuditLog record which includes a new change_details attribute in the JSON response.

The change_details attribute contains a list, representing fields that have changed, e.g:

    ...
    "change_details": [
        {
            "field": "enabled",
            "new": true,
            "old": false
        }
    ]
    ...

How did you test this code?

Added 'integration' style tests for common use cases.

Copy link

vercel bot commented Dec 22, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 8, 2024 9:30am
flagsmith-frontend-preview ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 8, 2024 9:30am
flagsmith-frontend-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 8, 2024 9:30am

@github-actions github-actions bot added the api Issue related to the REST API label Dec 22, 2023
@matthewelwell matthewelwell force-pushed the feature/1347/add-change-details-to-audit-log branch from 230f86e to 77731c5 Compare December 22, 2023 10:27
Copy link
Contributor

github-actions bot commented Dec 22, 2023

Uffizzi Preview deployment-43428 was deleted.

@codecov-commenter
Copy link

codecov-commenter commented Dec 22, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (445c698) 95.90% compared to head (9f35076) 77.21%.
Report is 1 commits behind head on main.

Files Patch % Lines
api/audit/serializers.py 95.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #3218       +/-   ##
===========================================
- Coverage   95.90%   77.21%   -18.70%     
===========================================
  Files        1062     1036       -26     
  Lines       32357    31602      -755     
===========================================
- Hits        31033    24401     -6632     
- Misses       1324     7201     +5877     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@swagger_serializer_method(
serializer_or_field=AuditLogChangeDetailsSerializer(many=True)
)
def get_change_details(self, instance: AuditLog) -> typing.List[typing.Dict]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def get_change_details(self, instance: AuditLog) -> typing.List[typing.Dict]:
def get_change_details(self, instance: AuditLog) -> typing.List[typing.Dict[str, typing.Any]:

api/audit/models.py Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issue related to the REST API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants