Count existing and new pool rows

This commit is contained in:
Eli Ribble 2026-02-09 19:17:33 +00:00
parent 515dbb54fa
commit f00436b136
No known key found for this signature in database
2 changed files with 21 additions and 10 deletions

View file

@ -30,7 +30,7 @@
<div class="col-md-4">
<div class="card summary-card h-100 border-primary">
<div class="card-body text-center">
<h1 class="display-4 text-primary">45</h1>
<h1 class="display-4 text-primary">{{ .Upload.CountExisting }}</h1>
<h5>Existing Pools</h5>
<p class="text-muted">Matches found in previous records</p>
</div>
@ -39,7 +39,7 @@
<div class="col-md-4">
<div class="card summary-card h-100 border-success">
<div class="card-body text-center">
<h1 class="display-4 text-success">23</h1>
<h1 class="display-4 text-success">{{ .Upload.CountNew }}</h1>
<h5>New Pools</h5>
<p class="text-muted">Not found in existing records</p>
</div>

View file

@ -20,11 +20,13 @@ import (
)
type UploadPoolDetail struct {
Created time.Time
ID int32
Name string
Pools []UploadPoolRow
Status string
CountExisting int
CountNew int
Created time.Time
ID int32
Name string
Pools []UploadPoolRow
Status string
}
type UploadPoolRow struct {
Street string
@ -91,16 +93,25 @@ func GetUploadPoolDetail(ctx context.Context, organization_id int32, file_id int
return UploadPoolDetail{}, fmt.Errorf("Failed to query pools for %d: %w", file_id, err)
}
pools := make([]UploadPoolRow, 0)
count_existing := 0
count_new := 0
for _, r := range rows {
if r.IsNew {
count_new = count_new + 1
} else {
count_existing = count_existing + 1
}
pools = append(pools, UploadPoolRow{
Street: r.AddressStreet,
City: r.AddressCity,
})
}
return UploadPoolDetail{
Name: file.Name,
Pools: pools,
Status: file.Status.String(),
CountExisting: count_existing,
CountNew: count_new,
Name: file.Name,
Pools: pools,
Status: file.Status.String(),
}, nil
}
func PoolUploadList(ctx context.Context, organization_id int32) ([]PoolUpload, error) {