Files
htwkalender/services/data-manager/service/functions/event.go
2025-04-27 13:57:34 +02:00

23 lines
619 B
Go

package functions
import (
"github.com/google/uuid"
"htwkalender/data-manager/model"
)
// generateUUIDs generates a UUID for each event based on the event name, course and semester
// the UUID is used to identify the event in the database
func GenerateUUIDs(events []model.Event) []model.Event {
for i, event := range events {
// generate a hash value from the event name, course and semester
hash := GenerateUUID(event)
events[i].UUID = hash
}
return events
}
func GenerateUUID(event model.Event) string {
hash := uuid.NewSHA1(uuid.NameSpaceOID, []byte(event.Name+event.Course)).String()
return hash
}