Better tracing
Not done yet, still need to add them to just about every other function
This commit is contained in:
parent
83f47d17be
commit
529d106351
13 changed files with 148 additions and 22 deletions
|
@ -1,6 +1,8 @@
|
|||
package storage
|
||||
|
||||
import (
|
||||
"github.com/rs/zerolog/log"
|
||||
"gitlab.com/mstarongitlab/linstrom/util"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
|
@ -161,6 +163,8 @@ Misskey "permissions" (no order):
|
|||
*/
|
||||
|
||||
func (s *Storage) NewEmptyRole(name string) (*Role, error) {
|
||||
defer util.Untrace(util.Trace(&log.Logger))
|
||||
// Check if a role with the given name already exists
|
||||
_, err := s.FindRoleByName(name)
|
||||
switch err {
|
||||
case nil:
|
||||
|
@ -180,6 +184,7 @@ func (s *Storage) NewEmptyRole(name string) (*Role, error) {
|
|||
}
|
||||
|
||||
func (s *Storage) FindRoleByName(name string) (*Role, error) {
|
||||
defer util.Untrace(util.Trace(&log.Logger))
|
||||
role := Role{}
|
||||
err := s.db.Where("name = ?", name).First(&role).Error
|
||||
switch err {
|
||||
|
@ -193,6 +198,7 @@ func (s *Storage) FindRoleByName(name string) (*Role, error) {
|
|||
}
|
||||
|
||||
func (s *Storage) FindRolesByNames(names []string) ([]Role, error) {
|
||||
defer util.Untrace(util.Trace(&log.Logger))
|
||||
roles := []Role{}
|
||||
err := s.db.Where("name IN ?", names).Find(&roles).Error
|
||||
switch err {
|
||||
|
@ -204,3 +210,8 @@ func (s *Storage) FindRolesByNames(names []string) ([]Role, error) {
|
|||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Storage) UpdateRole(role *Role) error {
|
||||
defer util.Untrace(util.Trace(&log.Logger))
|
||||
return s.db.Save(role).Error
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue