snapshot of https://github.com/traggo/server.git (master, 2026-09-16; blobs > 131072B omitted)
Some checks failed
build / build (push) Failing after 3s

This commit is contained in:
upstream-mirror
2026-09-16 05:24:45 +05:00
commit cda7c1a474
272 changed files with 31973 additions and 0 deletions

25
timespan/tagcheck.go Normal file
View File

@@ -0,0 +1,25 @@
package timespan
import (
"fmt"
"github.com/jinzhu/gorm"
"github.com/traggo/server/model"
)
func tagsExist(db *gorm.DB, userID int, tags []model.TimeSpanTag) error {
existingTags := make(map[string]struct{})
for _, tag := range tags {
if _, ok := existingTags[tag.Key]; ok {
return fmt.Errorf("tag '%s' is present multiple times", tag.Key)
}
if db.Where("key = ?", tag.Key).Where("user_id = ?", userID).Find(new(model.TagDefinition)).RecordNotFound() {
return fmt.Errorf("tag '%s' does not exist", tag.Key)
}
existingTags[tag.Key] = struct{}{}
}
return nil
}