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

Add a contributors with active lists report #990

Merged
merged 1 commit into from
Mar 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Add a report that groups facility counts by country [#979](https://github.com/open-apparel-registry/open-apparel-registry/pull/979)
- Add confirmed matches to canonical facility list when matching [#964](https://github.com/open-apparel-registry/open-apparel-registry/pull/964)
- Add polygonal search [#969](https://github.com/open-apparel-registry/open-apparel-registry/pull/969)
- Add report that lists contributors with active lists [#990](https://github.com/open-apparel-registry/open-apparel-registry/pull/990)

### Changed
- Zoom to search [#966](https://github.com/open-apparel-registry/open-apparel-registry/pull/966)
Expand Down
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