feat:#104 changed event selection to uuid

This commit is contained in:
masterElmar
2023-12-29 00:05:39 +01:00
parent e29ed1f12f
commit 5128fcbddd
2 changed files with 6 additions and 12 deletions

View File

@@ -125,20 +125,14 @@ func buildIcalQueryForModules(modules []model.FeedCollection) dbx.Expression {
//second check if modules has only one element //second check if modules has only one element
if len(modules) == 1 { if len(modules) == 1 {
return dbx.And( return dbx.HashExp{"uuid": modules[0].UUID}
dbx.HashExp{"Name": modules[0].Name},
dbx.HashExp{"course": modules[0].Course},
)
} }
//third check if modules has more than one element //third check if modules has more than one element
var wheres []dbx.Expression var wheres []dbx.Expression
for _, module := range modules { for _, module := range modules {
where := dbx.And( where := dbx.HashExp{"uuid": module.UUID}
dbx.HashExp{"Name": module.Name},
dbx.HashExp{"course": module.Course},
)
wheres = append(wheres, where) wheres = append(wheres, where)
} }

View File

@@ -23,13 +23,13 @@ func Test_buildIcalQueryForModules(t *testing.T) {
}, },
{ {
name: "one module", name: "one module",
args: args{modules: []model.FeedCollection{{Name: "test", Course: "test"}}}, args: args{modules: []model.FeedCollection{{Name: "test", Course: "test", UUID: "test"}}},
want: dbx.And(dbx.HashExp{"Name": "test"}, dbx.HashExp{"course": "test"}), want: dbx.HashExp{"uuid": "test"},
}, },
{ {
name: "two modules", name: "two modules",
args: args{modules: []model.FeedCollection{{Name: "test", Course: "test"}, {Name: "test2", Course: "test2"}}}, args: args{modules: []model.FeedCollection{{Name: "test", Course: "test", UUID: "test"}, {Name: "test2", Course: "test2", UUID: "test2"}}},
want: dbx.Or(dbx.And(dbx.HashExp{"Name": "test"}, dbx.HashExp{"course": "test"}), dbx.And(dbx.HashExp{"Name": "test2"}, dbx.HashExp{"course": "test2"})), want: dbx.Or(dbx.HashExp{"uuid": "test"}, dbx.HashExp{"uuid": "test2"}),
}, },
} }
for _, tt := range tests { for _, tt := range tests {