snapshot of https://github.com/traggo/server.git (master, 2026-09-16; blobs > 131072B omitted)
Some checks failed
build / build (push) Failing after 3s
Some checks failed
build / build (push) Failing after 3s
This commit is contained in:
21
timespan/copy.go
Normal file
21
timespan/copy.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package timespan
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/traggo/server/auth"
|
||||
"github.com/traggo/server/generated/gqlmodel"
|
||||
"github.com/traggo/server/model"
|
||||
)
|
||||
|
||||
// CopyTimeSpan copies a time span.
|
||||
func (r *ResolverForTimeSpan) CopyTimeSpan(ctx context.Context, id int, start model.Time, end *model.Time) (*gqlmodel.TimeSpan, error) {
|
||||
old := &model.TimeSpan{ID: id}
|
||||
|
||||
if r.DB.Preload("Tags").Where("user_id = ?", auth.GetUser(ctx).ID).Find(old).RecordNotFound() {
|
||||
return nil, fmt.Errorf("time span with id %d does not exist", id)
|
||||
}
|
||||
|
||||
return r.CreateTimeSpan(ctx, start, end, tagsToInputTag(old.Tags), old.Note)
|
||||
}
|
||||
Reference in New Issue
Block a user