Skip to content

Commit 71507de

Browse files
authored
Mark 0 out of 0 reads as partial success (#598)
1 parent e84887d commit 71507de

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

api/models/download.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ type PackagerRequest struct {
6868
Contents []PackagerContentItem `json:"contents"`
6969
Format string `json:"format"`
7070
Extent Extent `json:"extent"`
71+
ProductIDs []uuid.UUID `json:"product_ids"`
7172
}
7273

7374
// Extent is a name and a bounding box
@@ -210,7 +211,8 @@ func GetDownloadPackagerRequest(db *pgxpool.Pool, downloadID *uuid.UUID) (*Packa
210211
'/download_', d.id, '.', f.extension
211212
) AS output_key,
212213
f.abbreviation AS format,
213-
COALESCE(c.contents, '[]'::jsonb) AS contents
214+
COALESCE(c.contents, '[]'::jsonb) AS contents,
215+
ARRAY(SELECT product_id FROM download_product WHERE download_id = $1) AS product_ids
214216
FROM download d
215217
INNER JOIN download_format f ON f.id = d.download_format_id
216218
LEFT JOIN watershed w ON w.id = d.watershed_id

async_packager/packager.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,17 @@ def handle_message(message):
7676
package_file = writer_result["file"]
7777
product_stats = writer_result["product_stats"]
7878

79+
# Fill in products that had 0 files in contents
80+
for pid in PayloadResp.product_ids:
81+
if str(pid) not in product_stats:
82+
product_stats[str(pid)] = {"expected": 0, "successful": 0}
83+
7984
# Determine status from per-product stats
8085
total_expected = sum(ps["expected"] for ps in product_stats.values())
8186
total_successful = sum(ps["successful"] for ps in product_stats.values())
87+
all_products_have_data = all(ps["expected"] > 0 for ps in product_stats.values())
8288

83-
if total_successful == total_expected:
89+
if total_successful == total_expected and all_products_have_data:
8490
status_key = "SUCCESS"
8591
else:
8692
status_key = "PARTIAL_SUCCESS"

0 commit comments

Comments
 (0)