mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2025-08-07 04:09:15 +02:00
fix:#75 refactoring duplicate function
This commit is contained in:
17
services/data-manager/service/functions/event.go
Normal file
17
services/data-manager/service/functions/event.go
Normal file
@@ -0,0 +1,17 @@
|
||||
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 := uuid.NewSHA1(uuid.NameSpaceOID, []byte(event.Name+event.Course))
|
||||
events[i].UUID = hash.String()
|
||||
}
|
||||
return events
|
||||
}
|
Reference in New Issue
Block a user