Keep track of rows that are outside of the district

This commit is contained in:
Eli Ribble 2026-02-14 04:08:22 +00:00
parent 8932f46900
commit 76f4613320
No known key found for this signature in database
3 changed files with 19 additions and 10 deletions

View file

@ -397,17 +397,17 @@ func NewFieldSeeker(ctx context.Context, oauth *models.OauthToken) (*fieldseeker
RefreshTokenExpires: oauth.RefreshTokenExpires,
},
)
if err != nil {
return nil, fmt.Errorf("Failed to create ArcGIS client: %w", err)
}
log.Info().Str("context", context).Str("host", host).Msg("Using base fieldseeker URL")
fssync, err := fieldseeker.NewFieldSeekerFromURL(ctx, *ar, row.FieldseekerURL.MustGet())
if err != nil {
if errors.Is(err, arcgis.ErrorInvalidAuthToken) {
return nil, InvalidatedTokenError{}
} else if errors.Is(err, arcgis.ErrorInvalidRefreshToken) {
return nil, InvalidatedTokenError{}
}
return nil, fmt.Errorf("Failed to create ArcGIS client: %w", err)
}
log.Info().Str("context", context).Str("host", host).Msg("Using base fieldseeker URL")
fssync, err := fieldseeker.NewFieldSeekerFromURL(ctx, *ar, row.FieldseekerURL.MustGet())
if err != nil {
return nil, fmt.Errorf("Failed to create Fieldseeker client: %w", err)
}
return fssync, nil
@ -522,6 +522,10 @@ func periodicallyExportFieldseeker(ctx context.Context, org *models.Organization
oauth,
)
if err != nil {
if errors.Is(err, &InvalidatedTokenError{}) {
log.Info().Int32("org", org.ID).Msg("oauth token for org is invalid, waiting for refresh")
continue
}
return fmt.Errorf("Failed to create fieldseeker client: %w", err)
}
logPermissions(ctx, fssync)
@ -620,14 +624,14 @@ func maintainOAuth(ctx context.Context, oauth *models.OauthToken) error {
return fmt.Errorf("Failed to update oauth token from database: %w", err)
}
var accessTokenDelay time.Duration
if oauth.AccessTokenExpires.Before(time.Now()) {
accessTokenDelay = 1
if oauth.AccessTokenExpires.Before(time.Now()) || time.Until(oauth.AccessTokenExpires) < (3*time.Second) {
accessTokenDelay = time.Second
} else {
accessTokenDelay = time.Until(oauth.AccessTokenExpires) - (3 * time.Second)
}
var refreshTokenDelay time.Duration
if oauth.RefreshTokenExpires.Before(time.Now()) {
refreshTokenDelay = 1
if oauth.RefreshTokenExpires.Before(time.Now()) || time.Until(oauth.RefreshTokenExpires) < (3*time.Second) {
refreshTokenDelay = time.Second
} else {
refreshTokenDelay = time.Until(oauth.RefreshTokenExpires) - (3 * time.Second)
}

View file

@ -48,7 +48,7 @@
<div class="col-md-4">
<div class="card summary-card h-100 border-warning">
<div class="card-body text-center">
<h1 class="display-4 text-warning">4</h1>
<h1 class="display-4 text-warning">{{ .Upload.CountOutside }}</h1>
<h5>Outside District</h5>
<p class="text-muted">Potential geocoding errors</p>
</div>

View file

@ -22,6 +22,7 @@ import (
type UploadPoolDetail struct {
CountExisting int
CountNew int
CountOutside int
Created time.Time
ID int32
Name string
@ -95,9 +96,12 @@ func GetUploadPoolDetail(ctx context.Context, organization_id int32, file_id int
pools := make([]UploadPoolRow, 0)
count_existing := 0
count_new := 0
count_outside := 0
for _, r := range rows {
if r.IsNew {
count_new = count_new + 1
} else if !r.IsInDistrict {
count_outside = count_outside + 1
} else {
count_existing = count_existing + 1
}
@ -108,6 +112,7 @@ func GetUploadPoolDetail(ctx context.Context, organization_id int32, file_id int
}
return UploadPoolDetail{
CountExisting: count_existing,
CountOutside: count_outside,
CountNew: count_new,
Name: file.Name,
Pools: pools,