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

kobotoolbox / kpi / 13811832038
81%
master: 76%

Build:
Build:
LAST BUILD BRANCH: dev-1257-remove-v1-forms-endpoint
DEFAULT BRANCH: master
Ran 12 Mar 2025 01:31PM UTC
Jobs 1
Files 635
Run time 1min
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

12 Mar 2025 12:53PM UTC coverage: 80.875% (+0.01%) from 80.861%
13811832038

push

github

web-flow
feat(massEmails): query for users approaching submission limits TASK-1579 (#5572)

### 📣 Summary
Query for users who are approaching their maximum submission limit.


### 📖 Description
Create queries for users who are over 90% and 100%, respectively, of
their submission limit. These queries will be accessible by mass email
jobs.


### 💭 Notes
Similar to https://github.com/kobotoolbox/kpi/pull/5562, this PR is
mostly about taking existing rules for determining submission
limits/submission counts and applying them to all organizations at once.
It's not as simple as the storage limits because submissions are
measured per billing period, so we have to calculate the current billing
period for every org.

Similar to the storage usage PR, we refactored the code for getting
billing dates for an individual organization to just call the method for
getting all billing dates with a filter. There's a unit test to make
sure this doesn't increase the number of queries since the logic is a
little more complicated. The basic logic is the same: look for an active
subscription first, then a canceled subscription, then default to the
first of the current month.

Unlike with the storage PR, we didn't also refactor the method to get
all submissions within the billing period for an individual organization
because it's very hard to do without increasing the number of queries
(because of the variable billing period, which is calculated in python
and not easily convertible to a SQL method). Instead we just add a new
method that gets all submissions from the most recent billing period for
all orgs.

This PR also moves some of the billing date calculation logic to
stripe/utils.py because it's stripe-specific and not applicable to if
Stripe is disabled.

Finally, this PR refactors `get_users_within_range_of_usage_limit` to
work with either storage or submission usage types because the basic
procedure is the same: get all limits, get all usage, and compare usage
to limits.


### 👀... (continued)

6018 of 9555 branches covered (62.98%)

112 of 120 new or added lines in 4 files covered. (93.33%)

10 existing lines in 4 files now uncovered.

22967 of 28398 relevant lines covered (80.88%)

0.81 hits per line

New Missed Lines in Diff

Lines Coverage ∆ File
2
94.87
4.4% kobo/apps/stripe/utils.py
6
82.22
-6.97% kobo/apps/mass_emails/user_queries.py

Uncovered Existing Lines

Lines Coverage ∆ File
1
96.55
0.47% kobo/apps/organizations/utils.py
2
82.22
-6.97% kobo/apps/mass_emails/user_queries.py
2
94.41
-1.24% kobo/apps/stripe/views.py
5
86.06
-3.03% kobo/apps/organizations/models.py
Jobs
ID Job ID Ran Files Coverage
1 13811832038.1 12 Mar 2025 01:31PM UTC 635
80.88
Source Files on build 13811832038
  • Tree
  • List 635
  • Changed 7
  • Source Changed 0
  • Coverage Changed 7
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • cbf1e6c8 on github
  • Prev Build on main (#13793498909)
  • Next Build on main (#13811861621)
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

© 2026 Coveralls, Inc