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
|
@ -3,6 +3,8 @@ package storage
|
|||
import (
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"gitlab.com/mstarongitlab/linstrom/util"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
|
@ -31,6 +33,7 @@ type MediaMetadata struct {
|
|||
}
|
||||
|
||||
func (s *Storage) NewMediaMetadata(location, mediaType, name string) (*MediaMetadata, error) {
|
||||
defer util.Untrace(util.Trace(&log.Logger))
|
||||
newMedia := MediaMetadata{
|
||||
Location: location,
|
||||
Name: name,
|
||||
|
@ -41,6 +44,7 @@ func (s *Storage) NewMediaMetadata(location, mediaType, name string) (*MediaMeta
|
|||
}
|
||||
|
||||
func (s *Storage) FuzzyFindMediaMetadataByName(name string) ([]MediaMetadata, error) {
|
||||
defer util.Untrace(util.Trace(&log.Logger))
|
||||
notes := []MediaMetadata{}
|
||||
err := s.db.Where("name LIKE %?%", name).Find(notes).Error
|
||||
if err != nil {
|
||||
|
@ -50,6 +54,7 @@ func (s *Storage) FuzzyFindMediaMetadataByName(name string) ([]MediaMetadata, er
|
|||
}
|
||||
|
||||
func (s *Storage) GetMediaMetadataById(id string) (*MediaMetadata, error) {
|
||||
defer util.Untrace(util.Trace(&log.Logger))
|
||||
media := MediaMetadata{ID: id}
|
||||
err := s.db.First(&media).Error
|
||||
if err != nil {
|
||||
|
@ -59,6 +64,7 @@ func (s *Storage) GetMediaMetadataById(id string) (*MediaMetadata, error) {
|
|||
}
|
||||
|
||||
func (s *Storage) FuzzyFindMediaMetadataByLocation(location string) ([]MediaMetadata, error) {
|
||||
defer util.Untrace(util.Trace(&log.Logger))
|
||||
data := []MediaMetadata{}
|
||||
if err := s.db.Where("location LIKE %?%", location).Find(data).Error; err != nil {
|
||||
return nil, err
|
||||
|
@ -67,15 +73,18 @@ func (s *Storage) FuzzyFindMediaMetadataByLocation(location string) ([]MediaMeta
|
|||
}
|
||||
|
||||
func (s *Storage) DeleteMediaMetadataById(id string) error {
|
||||
defer util.Untrace(util.Trace(&log.Logger))
|
||||
return s.db.Delete(MediaMetadata{ID: id}).Error
|
||||
}
|
||||
|
||||
func (s *Storage) DeleteMediaMetadataByFuzzyLocation(location string) error {
|
||||
defer util.Untrace(util.Trace(&log.Logger))
|
||||
var tmp MediaMetadata
|
||||
return s.db.Where("location LIKE %?%", location).Delete(&tmp).Error
|
||||
}
|
||||
|
||||
func (s *Storage) DeleteMediaMetadataByFuzzyName(name string) error {
|
||||
defer util.Untrace(util.Trace(&log.Logger))
|
||||
var tmp MediaMetadata
|
||||
return s.db.Where("name LIKE %?%", name).Delete(&tmp).Error
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue