Begin work on debugging user behavior in early setup
This commit is contained in:
parent
655f26e218
commit
97ea4ad3bb
5 changed files with 14 additions and 10 deletions
|
|
@ -26,6 +26,7 @@ import (
|
||||||
"github.com/Gleipnir-Technology/nidus-sync/db/enums"
|
"github.com/Gleipnir-Technology/nidus-sync/db/enums"
|
||||||
"github.com/Gleipnir-Technology/nidus-sync/db/models"
|
"github.com/Gleipnir-Technology/nidus-sync/db/models"
|
||||||
"github.com/Gleipnir-Technology/nidus-sync/db/sql"
|
"github.com/Gleipnir-Technology/nidus-sync/db/sql"
|
||||||
|
"github.com/Gleipnir-Technology/nidus-sync/debug"
|
||||||
"github.com/aarondl/opt/omit"
|
"github.com/aarondl/opt/omit"
|
||||||
"github.com/aarondl/opt/omitnull"
|
"github.com/aarondl/opt/omitnull"
|
||||||
"github.com/alitto/pond/v2"
|
"github.com/alitto/pond/v2"
|
||||||
|
|
@ -174,7 +175,7 @@ func updateArcgisUserData(ctx context.Context, user *models.User, access_token s
|
||||||
|
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
LogErrorTypeInfo(err)
|
debug.LogErrorTypeInfo(err)
|
||||||
if errors.Is(err, pgx.ErrNoRows) {
|
if errors.Is(err, pgx.ErrNoRows) {
|
||||||
} else {
|
} else {
|
||||||
log.Error().Err(err).Msg("Failed to query for existing org")
|
log.Error().Err(err).Msg("Failed to query for existing org")
|
||||||
|
|
@ -310,7 +311,7 @@ func refreshFieldseekerData(ctx context.Context, newOauthCh <-chan struct{}) {
|
||||||
if errors.Is(err, arcgis.InvalidatedRefreshTokenError) {
|
if errors.Is(err, arcgis.InvalidatedRefreshTokenError) {
|
||||||
log.Info().Int("oauth_token.id", int(oauth.ID)).Msg("Marked invalid by the server")
|
log.Info().Int("oauth_token.id", int(oauth.ID)).Msg("Marked invalid by the server")
|
||||||
} else {
|
} else {
|
||||||
LogErrorTypeInfo(err)
|
debug.LogErrorTypeInfo(err)
|
||||||
log.Error().Err(err).Msg("Crashed oauth maintenance goroutine")
|
log.Error().Err(err).Msg("Crashed oauth maintenance goroutine")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"github.com/Gleipnir-Technology/nidus-sync/db/enums"
|
"github.com/Gleipnir-Technology/nidus-sync/db/enums"
|
||||||
"github.com/Gleipnir-Technology/nidus-sync/db/models"
|
"github.com/Gleipnir-Technology/nidus-sync/db/models"
|
||||||
"github.com/Gleipnir-Technology/nidus-sync/db/sql"
|
"github.com/Gleipnir-Technology/nidus-sync/db/sql"
|
||||||
|
"github.com/Gleipnir-Technology/nidus-sync/debug"
|
||||||
"github.com/aarondl/opt/omit"
|
"github.com/aarondl/opt/omit"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"golang.org/x/crypto/bcrypt"
|
"golang.org/x/crypto/bcrypt"
|
||||||
|
|
@ -141,16 +142,15 @@ func SignupUser(username string, name string, password string) (*models.User, er
|
||||||
return u, nil
|
return u, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Helper function to translate strings into solid error types for operating on
|
// Helper function to translate strings into solid error types for operating on
|
||||||
func findUser(ctx context.Context, user_id int) (*models.User, error) {
|
func findUser(ctx context.Context, user_id int) (*models.User, error) {
|
||||||
user, err := models.FindUser(ctx, db.PGInstance.BobDB, int32(user_id))
|
user, err := models.FindUser(ctx, db.PGInstance.BobDB, int32(user_id))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err.Error() == "No such user" {
|
if err.Error() == "No such user" || err.Error() == "sql: no rows in result set" {
|
||||||
return nil, &NoUserError{}
|
return nil, &NoUserError{}
|
||||||
} else {
|
} else {
|
||||||
//LogErrorTypeInfo(err)
|
debug.LogErrorTypeInfo(err)
|
||||||
//log.Error().Err(err).Msg("Unrecognized error. This should be updated in the findUser code")
|
log.Error().Err(err).Msg("Unrecognized error. This should be updated in the findUser code")
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package main
|
package debug
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
@ -247,9 +247,11 @@ func getVectorTiles(w http.ResponseWriter, r *http.Request, u *models.User) {
|
||||||
log.Info().Str("org_id", org_id).Str("tileset_id", tileset_id).Str("zoom", zoom).Str("x", x).Str("y", y).Str("format", format).Msg("Get vector tiles")
|
log.Info().Str("org_id", org_id).Str("tileset_id", tileset_id).Str("zoom", zoom).Str("x", x).Str("y", y).Str("format", format).Msg("Get vector tiles")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Respond with an error that is visible to the user
|
||||||
func respondError(w http.ResponseWriter, m string, e error, s int) {
|
func respondError(w http.ResponseWriter, m string, e error, s int) {
|
||||||
log.Warn().Int("status", s).Err(e).Msg("Responding with an error")
|
log.Warn().Int("status", s).Err(e).Str("user message", m).Msg("Responding with an error")
|
||||||
http.Error(w, m, http.StatusBadRequest)
|
http.Error(w, m, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func postSignin(w http.ResponseWriter, r *http.Request) {
|
func postSignin(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"github.com/Gleipnir-Technology/nidus-sync/db"
|
"github.com/Gleipnir-Technology/nidus-sync/db"
|
||||||
enums "github.com/Gleipnir-Technology/nidus-sync/db/enums"
|
enums "github.com/Gleipnir-Technology/nidus-sync/db/enums"
|
||||||
"github.com/Gleipnir-Technology/nidus-sync/db/models"
|
"github.com/Gleipnir-Technology/nidus-sync/db/models"
|
||||||
|
"github.com/Gleipnir-Technology/nidus-sync/debug"
|
||||||
"github.com/aarondl/opt/omit"
|
"github.com/aarondl/opt/omit"
|
||||||
"github.com/aarondl/opt/omitnull"
|
"github.com/aarondl/opt/omitnull"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
|
@ -56,7 +57,7 @@ func notifyOauthInvalid(ctx context.Context, user *models.User) {
|
||||||
log.Info().Str("msg", msg).Int("user_id", int(user.ID)).Msg("Refusing to add another notification with the same type")
|
log.Info().Str("msg", msg).Int("user_id", int(user.ID)).Msg("Refusing to add another notification with the same type")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
LogErrorTypeInfo(err)
|
debug.LogErrorTypeInfo(err)
|
||||||
log.Error().Err(err).Msg("Failed to insert new notification. This is a programmer bug.")
|
log.Error().Err(err).Msg("Failed to insert new notification. This is a programmer bug.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue