Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
Add a contributors with active lists report
Browse files Browse the repository at this point in the history
The exiting /admin/reports/countributors/ report shows all registered
accounts. We need a version that only lists those contributor accounts
that have submitted facilities.

This adds a contributors-with-active-facilities report.
It has the same output schema as the contributors report and
uses the same filter criteria as the /api/contributors endpoint.
  • Loading branch information
TaiWilkin committed Mar 13, 2020
1 parent aa7050d commit 8a76f60
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/django/api/reports/contributors_with_active_facilities.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
SELECT
u.email,
c.name,
date(u.created_at) AS registration_date,
regexp_replace(c.description, E'[\\n\\r]+', ' ', 'g' ) AS description,
c.contrib_type,
c.website,
u.should_receive_newsletter
FROM api_contributor c
JOIN api_user u ON u.id = c.admin_id
INNER JOIN api_source s ON (c.id = s.contributor_id)
WHERE s.id IN (
SELECT V0.id
FROM api_source V0
WHERE (V0.is_active = true AND V0.is_public = true AND NOT (V0.id IN (SELECT U1.source_id FROM api_facilitylistitem U1 WHERE U1.status IN ('ERROR', 'ERROR_PARSING', 'ERROR_GEOCODING', 'ERROR_MATCHING'))))
)
AND u.email NOT LIKE '%openapparel.org%'
ORDER BY u.created_at, email

0 comments on commit 8a76f60

Please sign in to comment.