activity: allow multiple types in route filter

This commit is contained in:
Harvey Tindall
2023-10-19 22:44:27 +01:00
parent df1581d48e
commit 5a0677bac8
4 changed files with 99 additions and 7 deletions

View File

@@ -96,9 +96,12 @@ func (app *appContext) GetActivities(gc *gin.Context) {
req := GetActivitiesDTO{}
gc.BindJSON(&req)
query := &badgerhold.Query{}
activityType := stringToActivityType(req.Type)
if activityType != ActivityUnknown {
query = badgerhold.Where("Type").Eq(activityType)
activityTypes := make([]interface{}, len(req.Type))
for i, v := range req.Type {
activityTypes[i] = stringToActivityType(v)
}
if len(activityTypes) != 0 {
query = badgerhold.Where("Type").In(activityTypes...)
}
if req.Ascending {