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

Merged
merged 1 commit into from
May 29, 2024
Merged

Implement Add-on activity log #11080

merged 1 commit into from
May 29, 2024

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 91.25000% with 7 lines in your changes are missing coverage. Please review.

Project coverage is 90.56%. Comparing base (6aee586) to head (3f2b279).
Report is 1891 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #11080      +/-   ##
==========================================
- Coverage   90.82%   90.56%   -0.26%     
==========================================
  Files         554      573      +19     
  Lines       57306    58626    +1320     
  Branches     9122     9376     +254     
==========================================
+ Hits        52046    53095    +1049     
- Misses       3640     3841     +201     
- Partials     1620     1690      +70     
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.76% <100.00%> (+0.03%) ⬆️
weblate/urls.py 81.70% <ø> (ø)
weblate/addons/models.py 89.09% <96.00%> (-2.58%) ⬇️
weblate/addons/views.py 83.96% <75.00%> (-5.91%) ⬇️

... and 310 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
@ParthS007 ParthS007 force-pushed the 10053 branch 2 times, most recently from 7d1ed37 to 25b1d06 Compare May 24, 2024 13:23
@ParthS007 ParthS007 requested a review from nijel May 29, 2024 07:32
@nijel nijel merged commit e422770 into WeblateOrg:main May 29, 2024
30 of 31 checks passed
@nijel
Copy link
Member

nijel commented May 29, 2024

Merged, thanks for your contribution!

@ParthS007 ParthS007 deleted the 10053 branch May 29, 2024 10:31
Copy link

sentry-io bot commented May 29, 2024

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ RepositoryError: fatal: bad revision 'origin/l10n..' weblate.trans.tasks.perform_commit View Issue
  • ‼️ FileParseError: 'NoneType' object has no attribute 'mode' /api/translations/{component__project__slug}/{c... View Issue
  • ‼️ PermissionError: [Errno 13] Permission denied: '/home/cdn' weblate.trans.tasks.perform_commit View Issue
  • ‼️ WeblateLockTimeoutError: Lock on lock:repo:17561 could not be acquired in 120s weblate.addons.tasks.postconfigure_addon View Issue
  • ‼️ OperationalError: deadlock detected weblate.trans.tasks.perform_update View Issue

Did you find this useful? React with a 👍 or 👎

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