diff --git a/html/template/sync/pool-by-id.html b/html/template/sync/pool-by-id.html
index 9d937b27..d2deb7e0 100644
--- a/html/template/sync/pool-by-id.html
+++ b/html/template/sync/pool-by-id.html
@@ -69,137 +69,65 @@
-
-
- Warning: 4 entries appear to be outside district
- boundaries. These are highlighted in yellow below.
-
-
-
-
-
-
- | Plat ID |
- Latitude |
- Longitude |
- Street Address |
- Status |
- In District |
-
-
-
-
- | P12345 |
- 37.7749 |
- -122.4194 |
- 123 Main St, Anytown, CA |
-
- Existing
- |
-
- Yes
- |
-
-
- | P23456 |
- 37.3352 |
- -121.8811 |
- 456 Oak Ave, Someville, CA |
-
- Existing
- |
-
- Yes
- |
-
-
- | P34567 |
- 38.5816 |
- -121.4944 |
- 789 Pine Rd, Outtown, CA |
- New |
-
-
- No - Outside northern boundary
- |
-
-
- | P45678 |
- 37.4419 |
- -122.1430 |
- 101 Elm St, Cityville, CA |
- New |
-
- Yes
- |
-
-
- | P56789 |
- 37.3541 |
- -121.9552 |
- 202 Maple Dr, Townburg, CA |
-
- Existing
- |
-
- Yes
- |
-
-
- | P67890 |
- 35.3733 |
- -119.0187 |
- 303 Cedar Ln, Farville, CA |
- New |
-
-
- No - Outside southern boundary
- |
-
-
- | P78901 |
- 37.8044 |
- -122.2712 |
- 404 Birch Ave, Metroburg, CA |
-
- Existing
- |
-
- Yes
- |
-
-
- | P89012 |
- 37.4032 |
- -123.9612 |
- 505 Walnut St, Edgetown, CA |
- New |
-
-
- No - Outside western boundary
- |
-
-
-
-
-
-
+ {{ range .Upload.Errors }}
+
+
+ Error:{{ .Message }}
+
+ {{ end }}
+ {{ if eq (len .Upload.Pools) 0 }}
+
+
+ Warning: No pools could be understood from your
+ file.
+
+ {{ else }}
+
+
+
+
+ | Street |
+ City |
+ Post |
+ Status |
+ Condition |
+
+
+
+ {{ range .Upload.Pools }}
+
+ | {{ .Street }} |
+ {{ .City }} |
+ {{ .PostalCode }} |
+ {{ if eq .Status "new" }}
+
+ New
+ |
+ {{ else if eq .Status "existing" }}
+
+ Existing
+ |
+ {{ else if eq .Status "outside" }}
+
+ Outside
+ |
+ {{ else }}
+
+ {{ .Status }}
+ |
+ {{ end }}
+
+ {{ end }}
+
+
+
+ {{ end }}
diff --git a/platform/pool.go b/platform/pool.go
index 3ca1045d..886f2f05 100644
--- a/platform/pool.go
+++ b/platform/pool.go
@@ -24,14 +24,23 @@ type UploadPoolDetail struct {
CountNew int
CountOutside int
Created time.Time
+ Errors []UploadPoolError
ID int32
Name string
Pools []UploadPoolRow
Status string
}
+type UploadPoolError struct {
+ Column uint
+ Line uint
+ Message string
+}
type UploadPoolRow struct {
- Street string
- City string
+ City string
+ Condition string
+ Street string
+ PostalCode string
+ Status string
}
type PoolUpload struct {
Created time.Time `db:"created"`
@@ -84,36 +93,60 @@ func GetUploadPoolDetail(ctx context.Context, organization_id int32, file_id int
/*
csv, err := models.FindFileuploadCSV(ctx, db.PGInstance.BobDB, file_id)
if err != nil {
- return PoolDetail{}, fmt.Errorf("Failed to lookup csv %d: %w", file_id, err)
+ return UploadPoolDetail{}, fmt.Errorf("Failed to lookup csv %d: %w", file_id, err)
}
*/
- rows, err := models.FileuploadPools.Query(
+ error_rows, err := models.FileuploadErrorCSVS.Query(
+ models.SelectWhere.FileuploadErrorCSVS.CSVFileID.EQ(file_id),
+ ).All(ctx, db.PGInstance.BobDB)
+ if err != nil {
+ return UploadPoolDetail{}, fmt.Errorf("Failed to lookup errors in csv %d: %w", file_id, err)
+ }
+ errors := make([]UploadPoolError, 0)
+ for _, row := range error_rows {
+ errors = append(errors, UploadPoolError{
+ Column: uint(row.Col),
+ Line: uint(row.Line),
+ Message: row.Message,
+ })
+ }
+
+ pool_rows, err := models.FileuploadPools.Query(
models.SelectWhere.FileuploadPools.CSVFile.EQ(file_id),
).All(ctx, db.PGInstance.BobDB)
if err != nil {
return UploadPoolDetail{}, fmt.Errorf("Failed to query pools for %d: %w", file_id, err)
}
+
pools := make([]UploadPoolRow, 0)
count_existing := 0
count_new := 0
count_outside := 0
- for _, r := range rows {
+ status := "unknown"
+ for _, r := range pool_rows {
if r.IsNew {
count_new = count_new + 1
+ status = "new"
} else if !r.IsInDistrict {
count_outside = count_outside + 1
+ status = "outside"
} else {
count_existing = count_existing + 1
+ status = "existing"
}
pools = append(pools, UploadPoolRow{
- Street: r.AddressStreet,
- City: r.AddressCity,
+ City: r.AddressCity,
+ Condition: r.Condition.String(),
+ PostalCode: r.AddressPostalCode,
+ Status: status,
+ Street: r.AddressStreet,
})
}
return UploadPoolDetail{
CountExisting: count_existing,
CountOutside: count_outside,
CountNew: count_new,
+ Errors: errors,
Name: file.Name,
Pools: pools,
Status: file.Status.String(),