* move error-related code for groups to its own file

* update group avatar logic

remove unused/duplicate logic

* update `FindGroupsOptions.ToConds()`

allow passing `-1` as the `ParentGroupID`, meaning "find matching groups regardless of the parent group id"

* add `DedupeBy` function to container module

this removes duplicate items from a slice using a custom function

* add `SliceMap` util

works like javascripts's `Array.prototoype.map`, taking in a slice and transforming each element with the provided function

* add group service

functions included so far:
- avatar uploading/deletion
- group deletion
- group creation
- group moving (including moving item inside a group)
- group update
- team management
  - add team
  - remove team
  - update team permissions
  - recalculating team access (in event of group move)
- group searching (only used in frontend/web components for now)
This commit is contained in:
☙◦ The Tablet ❀ GamerGirlandCo ◦❧
2026-04-02 20:00:45 -04:00
parent 1246721523
commit 96feb682fe
11 changed files with 739 additions and 90 deletions
+13
View File
@@ -19,3 +19,16 @@ func FilterSlice[E any, T comparable](s []E, include func(E) (T, bool)) []T {
}
return slices.Clip(filtered)
}
func DedupeBy[E any, I comparable](s []E, id func(E) I) []E {
filtered := make([]E, 0, len(s)) // slice will be clipped before returning
seen := make(map[I]bool, len(s))
for i := range s {
itemId := id(s[i])
if _, ok := seen[itemId]; !ok {
filtered = append(filtered, s[i])
seen[itemId] = true
}
}
return slices.Clip(filtered)
}
+8
View File
@@ -77,3 +77,11 @@ func SliceNilAsEmpty[T any](a []T) []T {
}
return a
}
func SliceMap[T any, R any](slice []T, mapper func(it T) R) []R {
ret := make([]R, 0)
for _, it := range slice {
ret = append(ret, mapper(it))
}
return ret
}