opensupplyhub / open-apparel-registry

An application for searching, matching, uploading factories.
MIT License
32 stars 13 forks source link

Sector field blank on some facilities #1958

Closed mariel-oar closed 2 years ago

mariel-oar commented 2 years ago

All facilities moved over from OAR should have been assigned a sector value of Apparel. All new facilities are blocked if sector is not included.

There are a number of facilities (look like they are all apparel facilities that are showing up with a blank sector value): CN20211821GPP86 MA20202680RFD9Z TN2020268Y889EV

Proposed Fix

jwalgran commented 2 years ago

All three of the example facilities have anonymized contributor details.

The items associated with these facilities are all inactive

~I suspect that~ we are filtering out inactive items when fetching the sectors for a facility

https://github.com/open-apparel-registry/open-apparel-registry/blob/629665ec4be33972024a6bcde43e4ec9da699b9a/src/django/api/serializers.py#L1039-L1040

opensupplyhub=> select i.id, sector, is_public, is_active from api_facilitylistitem i join api_source s on i.source_id = s.id  where facility
_id = 'MA20202680RFD9Z';
   id   |  sector   | is_public | is_active
--------+-----------+-----------+-----------
 141607 | {Apparel} | t         | f
 142170 | {Apparel} | t         | f
(2 rows)

opensupplyhub=> select i.id, sector, is_public, is_active from api_facilitylistitem i join api_source s on i.source_id = s.id  where facility_id = 'CN20211821GPP86';
   id   |  sector   | is_public | is_active
--------+-----------+-----------+-----------
 536590 | {Apparel} | f         | f
 540863 | {Apparel} | t         | f
(2 rows)

opensupplyhub=> select i.id, sector, is_public, is_active from api_facilitylistitem i join api_source s on i.source_id = s.id  where facility_id = 'TN2020268Y889EV';
   id   |  sector   | is_public | is_active
--------+-----------+-----------+-----------
 141610 | {Apparel} | t         | f
 142173 | {Apparel} | t         | f
(2 rows)