Skip to content

Commit

Permalink
[pocketbase#47] fixed some doc and code inconsistencies and removed s…
Browse files Browse the repository at this point in the history
…ome redundant parentheses
  • Loading branch information
ValleyZw authored Jul 10, 2022
1 parent d64fbf9 commit 460c684
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions apis/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ func InitApi(app core.App) (*echo.Echo, error) {
var apiErr *rest.ApiError

switch v := err.(type) {
case (*echo.HTTPError):
case *echo.HTTPError:
if v.Internal != nil && app.IsDebug() {
log.Println(v.Internal)
}
msg := fmt.Sprintf("%v", v.Message)
apiErr = rest.NewApiError(v.Code, msg, v)
case (*rest.ApiError):
case *rest.ApiError:
if app.IsDebug() && v.RawData() != nil {
log.Println(v.RawData())
}
Expand Down
6 changes: 3 additions & 3 deletions apis/middlewares.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,11 @@ func ActivityLogger(app core.App) echo.MiddlewareFunc {

if err != nil {
switch v := err.(type) {
case (*echo.HTTPError):
case *echo.HTTPError:
status = v.Code
meta["errorMessage"] = v.Message
meta["errorDetails"] = fmt.Sprint(v.Internal)
case (*rest.ApiError):
case *rest.ApiError:
status = v.Code
meta["errorMessage"] = v.Message
meta["errorDetails"] = fmt.Sprint(v.RawData())
Expand Down Expand Up @@ -259,7 +259,7 @@ func ActivityLogger(app core.App) echo.MiddlewareFunc {
// ---
now := time.Now()
lastLogsDeletedAt := cast.ToTime(app.Cache().Get("lastLogsDeletedAt"))
daysDiff := (now.Sub(lastLogsDeletedAt).Hours() * 24)
daysDiff := now.Sub(lastLogsDeletedAt).Hours() * 24

if daysDiff > float64(app.Settings().Logs.MaxDays) {
deleteErr := app.LogsDao().DeleteOldRequests(now.AddDate(0, 0, -1*app.Settings().Logs.MaxDays))
Expand Down
8 changes: 4 additions & 4 deletions core/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,12 @@ func (s *Settings) Merge(other *Settings) error {
}

// Clone creates a new deep copy of the current settings.
func (c *Settings) Clone() (*Settings, error) {
new := &Settings{}
if err := new.Merge(c); err != nil {
func (s *Settings) Clone() (*Settings, error) {
settings := &Settings{}
if err := settings.Merge(s); err != nil {
return nil, err
}
return new, nil
return settings, nil
}

// RedactClone creates a new deep copy of the current settings,
Expand Down
2 changes: 1 addition & 1 deletion daos/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (dao *Dao) FindAdminByEmail(email string) (*models.Admin, error) {
return model, nil
}

// FindAdminByEmail finds the admin associated with the provided JWT token.
// FindAdminByToken finds the admin associated with the provided JWT token.
//
// Returns an error if the JWT token is invalid or expired.
func (dao *Dao) FindAdminByToken(token string, baseTokenKey string) (*models.Admin, error) {
Expand Down
2 changes: 1 addition & 1 deletion forms/user_email_change_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/pocketbase/pocketbase/models"
)

// UserEmailChangeConfirm defines a user email change request form.
// UserEmailChangeRequest defines a user email change request form.
type UserEmailChangeRequest struct {
app core.App
user *models.User
Expand Down
4 changes: 2 additions & 2 deletions models/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (m *BaseModel) GetCreated() types.DateTime {
return m.Created
}

// GetCreated returns the model's Updated datetime.
// GetUpdated returns the model's Updated datetime.
func (m *BaseModel) GetUpdated() types.DateTime {
return m.Updated
}
Expand All @@ -71,7 +71,7 @@ func (m *BaseModel) RefreshCreated() {
m.Created = types.NowDateTime()
}

// RefreshCreated updates the model's Created field with the current datetime.
// RefreshUpdated updates the model's Created field with the current datetime.
func (m *BaseModel) RefreshUpdated() {
m.Updated = types.NowDateTime()
}
Expand Down
4 changes: 2 additions & 2 deletions models/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ func NewRecordsFromNullStringMaps(collection *Collection, rows []dbx.NullStringM
return result
}

// Returns the table name associated to the current Record model.
// TableName returns the table name associated to the current Record model.
func (m *Record) TableName() string {
return m.collection.Name
}

// Returns the Collection model associated to the current Record model.
// Collection returns the Collection model associated to the current Record model.
func (m *Record) Collection() *Collection {
return m.collection
}
Expand Down
2 changes: 1 addition & 1 deletion tools/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type Provider interface {
// SetClientId sets the provider client's ID.
SetClientId(clientId string)

// ClientId returns the provider client's app secret.
// ClientSecret returns the provider client's app secret.
ClientSecret() string

// SetClientSecret sets the provider client's app secret.
Expand Down
2 changes: 1 addition & 1 deletion tools/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

var cachedPatterns = map[string]*regexp.Regexp{}

// ExustInSlice checks whether a comparable element exists in a slice of the same type.
// ExistInSlice checks whether a comparable element exists in a slice of the same type.
func ExistInSlice[T comparable](item T, list []T) bool {
if len(list) == 0 {
return false
Expand Down

0 comments on commit 460c684

Please sign in to comment.