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

Implement Add-on activity log #11080

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

ParthS007
Copy link
Member

@ParthS007 ParthS007 commented Feb 23, 2024

Proposed changes

closes #10053

Add AddonActivityLog model

  • Foreign key to Addon
  • Foreign key to Component to see what component triggered that event.
  • Event to see what action triggered that (some add-ons can be triggered by more of them)
  • Timestamp
  • Details as JSONField
  • Create new instance on each add-on trigger
  • Make add-ons log what they did
  • Add a renderer for details to the BaseAddon class (subclasses might customize this)
  • List paginated events delivery on add-on management page
  • Add pruning of events after some time

Checklist

  • Lint and unit tests pass locally with my changes.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added documentation to describe my feature.
  • I have squashed my commits into logic units.
  • I have described the changes in the commit messages.
Screenshot 2024-04-29 at 10 37 10 Screenshot 2024-04-29 at 10 38 04 Screenshot 2024-05-17 at 11 15 28

weblate/addons/models.py Outdated Show resolved Hide resolved
weblate/addons/models.py Outdated Show resolved Hide resolved
weblate/addons/models.py Outdated Show resolved Hide resolved
weblate/addons/models.py Outdated Show resolved Hide resolved
weblate/addons/models.py Outdated Show resolved Hide resolved
@ParthS007 ParthS007 force-pushed the 10053 branch 3 times, most recently from b7f3f4d to f656020 Compare April 5, 2024 09:20
@ParthS007
Copy link
Member Author

@nijel

Add pruning of events after some time

What is the criterion for pruning and how we plan to do this?

  1. Have a management command to delete events
  2. Have a task scheduled after a certain interval to prune automatically.

@nijel
Copy link
Member

nijel commented Apr 5, 2024

Have a periodic task for that, something similar like we do for an audit log:

@app.task(trail=False)
def cleanup_auditlog() -> None:
"""Cleanup old auditlog entries."""
from weblate.accounts.models import AuditLog
AuditLog.objects.filter(
timestamp__lt=now() - timedelta(days=settings.AUDITLOG_EXPIRY)
).delete()

weblate/addons/models.py Outdated Show resolved Hide resolved
weblate/addons/tasks.py Outdated Show resolved Hide resolved
weblate/addons/base.py Outdated Show resolved Hide resolved
weblate/addons/models.py Show resolved Hide resolved
weblate/templates/addons/addon_list.html Outdated Show resolved Hide resolved
Copy link
Member

@nijel nijel left a comment

Choose a reason for hiding this comment

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

I'd display the activity log on the add-on detail page, not on the list page. On the list page, all add-ons logs would be mixed up, what could make reading the log challenging with many add-ons installed.

docs/admin/config.rst Outdated Show resolved Hide resolved
weblate/addons/tasks.py Outdated Show resolved Hide resolved
weblate/addons/tasks.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented May 6, 2024

Codecov Report

Attention: Patch coverage is 95.31250% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 90.62%. Comparing base (6aee586) to head (271cc0b).
Report is 1822 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #11080      +/-   ##
==========================================
- Coverage   90.82%   90.62%   -0.20%     
==========================================
  Files         554      572      +18     
  Lines       57306    58708    +1402     
  Branches     9122     9375     +253     
==========================================
+ Hits        52046    53203    +1157     
- Misses       3640     3817     +177     
- Partials     1620     1688      +68     
Files Coverage Δ
weblate/addons/migrations/0003_addonactivitylog.py 100.00% <100.00%> (ø)
weblate/addons/tasks.py 94.31% <100.00%> (+2.42%) ⬆️
weblate/addons/tests.py 99.75% <100.00%> (+0.02%) ⬆️
weblate/urls.py 81.70% <ø> (ø)
weblate/addons/models.py 89.09% <96.00%> (-2.58%) ⬇️
weblate/addons/views.py 82.44% <85.71%> (-7.44%) ⬇️

... and 245 files with indirect coverage changes

@ParthS007 ParthS007 requested a review from nijel May 8, 2024 14:33
@nijel nijel added this to the 5.6 milestone May 13, 2024
Copy link
Member

@nijel nijel left a comment

Choose a reason for hiding this comment

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

Looks good now, the only missing bit is ability to display log for add-ons which have no configuration.

weblate/addons/models.py Outdated Show resolved Hide resolved
weblate/addons/base.py Outdated Show resolved Hide resolved
Copy link
Member

@nijel nijel left a comment

Choose a reason for hiding this comment

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

Can you please add test for the new view?

weblate/addons/base.py Outdated Show resolved Hide resolved
@ParthS007 ParthS007 force-pushed the 10053 branch 2 times, most recently from 2343347 to 271cc0b Compare May 20, 2024 09:28
weblate/addons/views.py Outdated Show resolved Hide resolved

self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "addons/addon_logs.html")
self.assertEqual(response.context["instance"], addon)
Copy link
Member

Choose a reason for hiding this comment

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

Can we have tests that the request for logs fails without authentication?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add-on activity log
2 participants