Skip to content

Commit

Permalink
Fix to exclude downloads of public plans with no user id associated with
Browse files Browse the repository at this point in the history
download, as most of these downloads are associated with robots.

Change:
 - We exclude the cont  downloads in export_plans table for which
   user_id is nil.
  • Loading branch information
John Pinto committed Oct 17, 2024
1 parent 56759df commit 04c25a0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

### Fix
- Fix for removing from statistics the count of the download of plans that lack an user id in exported_plans table. Most of such downloads will have been associated with robots harvesting.

## v4.2.0

**Note this upgrade is mainly a migration from Bootstrap 3 to Bootstrap 5.**
Expand Down
2 changes: 2 additions & 0 deletions app/models/stat_exported_plan/create_or_update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ def org_plan_ids(org_id:, filtered:)
.uniq
end

# Exclude plans harvested by robots, by excluding plans that have a user_id nil.
def exported_plans(start_date:, end_date:, org_id:, filtered:)
ExportedPlan.where(plan_id: org_plan_ids(org_id: org_id, filtered: filtered))
.where(created_at: start_date..end_date)
.where.not(user_id: nil)
.count
end
end
Expand Down

0 comments on commit 04c25a0

Please sign in to comment.