Keep track of rows that are outside of the district
This commit is contained in:
parent
8932f46900
commit
76f4613320
3 changed files with 19 additions and 10 deletions
|
|
@ -397,17 +397,17 @@ func NewFieldSeeker(ctx context.Context, oauth *models.OauthToken) (*fieldseeker
|
||||||
RefreshTokenExpires: oauth.RefreshTokenExpires,
|
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 err != nil {
|
||||||
if errors.Is(err, arcgis.ErrorInvalidAuthToken) {
|
if errors.Is(err, arcgis.ErrorInvalidAuthToken) {
|
||||||
return nil, InvalidatedTokenError{}
|
return nil, InvalidatedTokenError{}
|
||||||
} else if errors.Is(err, arcgis.ErrorInvalidRefreshToken) {
|
} else if errors.Is(err, arcgis.ErrorInvalidRefreshToken) {
|
||||||
return nil, InvalidatedTokenError{}
|
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 nil, fmt.Errorf("Failed to create Fieldseeker client: %w", err)
|
||||||
}
|
}
|
||||||
return fssync, nil
|
return fssync, nil
|
||||||
|
|
@ -522,6 +522,10 @@ func periodicallyExportFieldseeker(ctx context.Context, org *models.Organization
|
||||||
oauth,
|
oauth,
|
||||||
)
|
)
|
||||||
if err != nil {
|
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)
|
return fmt.Errorf("Failed to create fieldseeker client: %w", err)
|
||||||
}
|
}
|
||||||
logPermissions(ctx, fssync)
|
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)
|
return fmt.Errorf("Failed to update oauth token from database: %w", err)
|
||||||
}
|
}
|
||||||
var accessTokenDelay time.Duration
|
var accessTokenDelay time.Duration
|
||||||
if oauth.AccessTokenExpires.Before(time.Now()) {
|
if oauth.AccessTokenExpires.Before(time.Now()) || time.Until(oauth.AccessTokenExpires) < (3*time.Second) {
|
||||||
accessTokenDelay = 1
|
accessTokenDelay = time.Second
|
||||||
} else {
|
} else {
|
||||||
accessTokenDelay = time.Until(oauth.AccessTokenExpires) - (3 * time.Second)
|
accessTokenDelay = time.Until(oauth.AccessTokenExpires) - (3 * time.Second)
|
||||||
}
|
}
|
||||||
var refreshTokenDelay time.Duration
|
var refreshTokenDelay time.Duration
|
||||||
if oauth.RefreshTokenExpires.Before(time.Now()) {
|
if oauth.RefreshTokenExpires.Before(time.Now()) || time.Until(oauth.RefreshTokenExpires) < (3*time.Second) {
|
||||||
refreshTokenDelay = 1
|
refreshTokenDelay = time.Second
|
||||||
} else {
|
} else {
|
||||||
refreshTokenDelay = time.Until(oauth.RefreshTokenExpires) - (3 * time.Second)
|
refreshTokenDelay = time.Until(oauth.RefreshTokenExpires) - (3 * time.Second)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<div class="card summary-card h-100 border-warning">
|
<div class="card summary-card h-100 border-warning">
|
||||||
<div class="card-body text-center">
|
<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>
|
<h5>Outside District</h5>
|
||||||
<p class="text-muted">Potential geocoding errors</p>
|
<p class="text-muted">Potential geocoding errors</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import (
|
||||||
type UploadPoolDetail struct {
|
type UploadPoolDetail struct {
|
||||||
CountExisting int
|
CountExisting int
|
||||||
CountNew int
|
CountNew int
|
||||||
|
CountOutside int
|
||||||
Created time.Time
|
Created time.Time
|
||||||
ID int32
|
ID int32
|
||||||
Name string
|
Name string
|
||||||
|
|
@ -95,9 +96,12 @@ func GetUploadPoolDetail(ctx context.Context, organization_id int32, file_id int
|
||||||
pools := make([]UploadPoolRow, 0)
|
pools := make([]UploadPoolRow, 0)
|
||||||
count_existing := 0
|
count_existing := 0
|
||||||
count_new := 0
|
count_new := 0
|
||||||
|
count_outside := 0
|
||||||
for _, r := range rows {
|
for _, r := range rows {
|
||||||
if r.IsNew {
|
if r.IsNew {
|
||||||
count_new = count_new + 1
|
count_new = count_new + 1
|
||||||
|
} else if !r.IsInDistrict {
|
||||||
|
count_outside = count_outside + 1
|
||||||
} else {
|
} else {
|
||||||
count_existing = count_existing + 1
|
count_existing = count_existing + 1
|
||||||
}
|
}
|
||||||
|
|
@ -108,6 +112,7 @@ func GetUploadPoolDetail(ctx context.Context, organization_id int32, file_id int
|
||||||
}
|
}
|
||||||
return UploadPoolDetail{
|
return UploadPoolDetail{
|
||||||
CountExisting: count_existing,
|
CountExisting: count_existing,
|
||||||
|
CountOutside: count_outside,
|
||||||
CountNew: count_new,
|
CountNew: count_new,
|
||||||
Name: file.Name,
|
Name: file.Name,
|
||||||
Pools: pools,
|
Pools: pools,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue