• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kobotoolbox / kpi / 12691298492
81%
master: 76%

Build:
Build:
LAST BUILD BRANCH: refactor-subsequences-2025
DEFAULT BRANCH: master
Ran 09 Jan 2025 02:30PM UTC
Jobs 1
Files 623
Run time 205min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

09 Jan 2025 01:53PM UTC coverage: 80.499% (+0.04%) from 80.455%
12691298492

push

github

web-flow
feat(projectHistoryLog): record submission modifications (#5404)


### 📣 Summary
Log updates to submissions, both content and validation status.

### 💭 Notes

#### SubmissionUpdate

The `SubmissionUpdate` class is just a dataclass meant to make it clear
what information we need to create a PH log for submission
modification/creation/deletion. It's meant mostly to help future
developers since we're not using the usual `initial_data`/`updated_data`
pattern where we just take configured fields off of a model.

#### ProjectHistoryLog.__init__
 
This PR includes a small refactor on ProjectHistoryLog to set the
`app_name`, `model_name`, and `log_type` in the `__init__` method like
we do with `create`. This saves us some repeated code when we are
creating logs in bulk.

#### Attaching the asset to the request

We always need the `asset_uid` when logging any views that include the
`AssetNestedObjectViewsetMixin` mixin, so I updated `AuditLoggedViewSet`
to always attach the asset (available via the mixin) to the request. We
may be able to use this to simplify other code later if we wish.

#### Where we add data to the request

We can't use the usual method of having the views inherit from
`AuditLoggedViewSet` and configuring `logged_fields` on the relevant
model because the viewsets that update Instances rarely act directly on
the Instance objects via get_object or the serializers. Instead they
usually have custom code that works through the deployment object on the
asset.

We could pass the request from the viewset through the layers of other
methods until we get to the part where we are actually updating
instances, but this would require a lot of changes in existing view code
and we're trying to keep the audit log code relatively self-contained.
Changes to logging code should ideally not require changes in view code.
Instead, I decided to use a receiver on the Instance model `post_save`
signal.

This also should allow the code to be more backend-agnostic sin... (continued)

5811 of 9300 branches covered (62.48%)

59 of 60 new or added lines in 7 files covered. (98.33%)

22216 of 27598 relevant lines covered (80.5%)

0.8 hits per line

New Missed Lines in Diff

Lines Coverage ∆ File
1
98.26
-0.22% kobo/apps/audit_log/models.py
Jobs
ID Job ID Ran Files Coverage
1 12691298492.1 09 Jan 2025 02:30PM UTC 623
80.5
Source Files on build 12691298492
  • Tree
  • List 623
  • Changed 10
  • Source Changed 0
  • Coverage Changed 10
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • 36b4484a on github
  • Prev Build on main (#12681000469)
  • Next Build on main (#12693142361)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc