Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased


## [1.73.0] - 2025-12-15
### Added
- USABILITY UI CleanUp: Group Filters - API improvements [#613](https://github.com/rokwire/groups-building-block/issues/613)

## [1.72.0] - 2025-09-15
### Added
- Change participant age field for participant filtering in research groups feature [#604](https://github.com/rokwire/groups-building-block/issues/604)
Expand Down
8 changes: 4 additions & 4 deletions core/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ type Services interface {
UpdateGroupDateUpdated(clientID string, groupID string) error
DeleteGroup(clientID string, current *model.User, id string) error
GetAllGroupsUnsecured() ([]model.Group, error)
GetAllGroups(clientID string) ([]model.Group, error)
GetGroups(clientID string, current *model.User, filter model.GroupsFilter) ([]model.Group, error)
GetAllGroups(clientID string) (int64, []model.Group, error)
GetGroups(clientID string, current *model.User, filter model.GroupsFilter) (int64, []model.Group, error)
GetGroupFilterStats(clientID string, current *model.User, filter model.StatsFilter) (*model.StatsResult, error)
GetUserGroups(clientID string, current *model.User, filter model.GroupsFilter) ([]model.Group, error)
DeleteUser(clientID string, current *model.User) error
Expand Down Expand Up @@ -122,7 +122,7 @@ type Services interface {

// Administration exposes administration APIs for the driver adapters
type Administration interface {
GetGroups(clientID string, current *model.User, filter model.GroupsFilter) ([]model.Group, error)
GetGroups(clientID string, current *model.User, filter model.GroupsFilter) (int64, []model.Group, error)
DeleteGroup(clientID string, current *model.User, id string, inactive bool) error
AdminDeleteMembershipsByID(clientID string, current *model.User, groupID string, accountIDs []string) error
}
Expand Down Expand Up @@ -159,7 +159,7 @@ type Storage interface {
DeleteGroup(ctx storage.TransactionContext, clientID string, id string) error
FindGroup(context storage.TransactionContext, clientID string, groupID string, userID *string) (*model.Group, error)
FindGroupByTitle(clientID string, title string) (*model.Group, error)
FindGroups(clientID string, userID *string, filter model.GroupsFilter, skipMembershipCheck bool) ([]model.Group, error)
FindGroups(clientID string, userID *string, filter model.GroupsFilter, skipMembershipCheck bool) (int64, []model.Group, error)
FindAllGroupsUnsecured() ([]model.Group, error)
FindGroupsByGroupIDs(groupIDs []string) ([]model.Group, error)
FindUserGroups(clientID string, userID string, filter model.GroupsFilter) ([]model.Group, error)
Expand Down
2 changes: 1 addition & 1 deletion core/interfaces_admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type administrationImpl struct {
app *Application
}

func (s *administrationImpl) GetGroups(clientID string, current *model.User, filter model.GroupsFilter) ([]model.Group, error) {
func (s *administrationImpl) GetGroups(clientID string, current *model.User, filter model.GroupsFilter) (int64, []model.Group, error) {
skipMembershipCheck := false
if current != nil {
skipMembershipCheck = current.IsGroupsBBAdministrator()
Expand Down
4 changes: 2 additions & 2 deletions core/interfaces_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ func (s *servicesImpl) DeleteGroup(clientID string, current *model.User, id stri
return s.app.deleteGroup(clientID, current, id, false)
}

func (s *servicesImpl) GetGroups(clientID string, current *model.User, filter model.GroupsFilter) ([]model.Group, error) {
func (s *servicesImpl) GetGroups(clientID string, current *model.User, filter model.GroupsFilter) (int64, []model.Group, error) {
return s.app.getGroups(clientID, current, filter, false)
}

func (s *servicesImpl) GetAllGroupsUnsecured() ([]model.Group, error) {
return s.app.getAllGroupsUnsecured()
}

func (s *servicesImpl) GetAllGroups(clientID string) ([]model.Group, error) {
func (s *servicesImpl) GetAllGroups(clientID string) (int64, []model.Group, error) {
return s.app.getAllGroups(clientID)
}

Expand Down
8 changes: 5 additions & 3 deletions core/model/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type GroupsFilter struct {
MemberID *string `json:"member_id"` // member id
MemberUserID *string `json:"member_user_id"` // member user id
MemberExternalID *string `json:"member_external_id"` // member user external id
MemberStatuses []string `json:"member_statuses"` // member user status
Title *string `json:"title"` // group title
Category *string `json:"category"` // group category
Privacy *string `json:"privacy"` // group privacy
Expand All @@ -33,9 +34,10 @@ type GroupsFilter struct {
ResearchGroup *bool `json:"research_group"`
ResearchAnswers map[string]map[string][]string `json:"research_answers"`
Attributes map[string]interface{} `json:"attributes"`
Order *string `json:"order"` // order by category & name (asc desc)
Offset *int64 `json:"offset"` // result offset
Limit *int64 `json:"limit"` // result limit
Order *string `json:"order"` // order by category & name (asc desc)
Offset *int64 `json:"offset"` // result offset
Limit *int64 `json:"limit"` // result limit
LimitID *string `json:"limit_id"` // limit id
DaysInactive *int64 `json:"days_inactive"`
Administrative *bool `json:"administrative"`
} // @name GroupsFilter
Expand Down
19 changes: 4 additions & 15 deletions core/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,28 +418,17 @@ func (app *Application) getAllGroupsUnsecured() ([]model.Group, error) {
return app.storage.FindAllGroupsUnsecured()
}

func (app *Application) getGroups(clientID string, current *model.User, filter model.GroupsFilter, skipMembershipCheck bool) ([]model.Group, error) {
func (app *Application) getGroups(clientID string, current *model.User, filter model.GroupsFilter, skipMembershipCheck bool) (int64, []model.Group, error) {
var userID *string
if current != nil {
userID = &current.ID
}
// find the groups objects
groups, err := app.storage.FindGroups(clientID, userID, filter, skipMembershipCheck)
if err != nil {
return nil, err
}

return groups, nil
return app.storage.FindGroups(clientID, userID, filter, skipMembershipCheck)
}

func (app *Application) getAllGroups(clientID string) ([]model.Group, error) {
// find the groups objects
groups, err := app.storage.FindGroups(clientID, nil, model.GroupsFilter{}, false)
if err != nil {
return nil, err
}

return groups, nil
func (app *Application) getAllGroups(clientID string) (int64, []model.Group, error) {
return app.storage.FindGroups(clientID, nil, model.GroupsFilter{}, false)
}

func (app *Application) getUserGroups(clientID string, current *model.User, filter model.GroupsFilter) ([]model.Group, error) {
Expand Down
169 changes: 151 additions & 18 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,57 @@ const docTemplate = `{
}
}
}
},
"post": {
"security": [
{
"AppUserAuth": []
}
],
"description": "Updates a membership. Only the status can be changed.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Admin"
],
"operationId": "AdminCreateMemberships",
"parameters": [
{
"type": "string",
"description": "APP",
"name": "APP",
"in": "header",
"required": true
},
{
"description": "body data",
"name": "data",
"in": "body",
"required": true,
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/MembershipStatus"
}
}
},
{
"type": "string",
"description": "Group ID",
"name": "group-id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/api/admin/group/{group-id}/members/v2": {
Expand Down Expand Up @@ -1806,6 +1857,42 @@ const docTemplate = `{
}
}
},
"/api/admin/v3/groups/load": {
"post": {
"security": [
{
"AppUserAuth": []
}
],
"description": "Gives the groups list. It can be filtered by category, title and privacy. V3",
"consumes": [
"application/json"
],
"tags": [
"Admin"
],
"operationId": "AdminGetGroupsV3",
"parameters": [
{
"description": "body data",
"name": "data",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/GroupsFilter"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/getGroupsResponseV3"
}
}
}
}
},
"/api/analytics/groups": {
"get": {
"security": [
Expand Down Expand Up @@ -4902,6 +4989,42 @@ const docTemplate = `{
}
}
},
"/api/v3/groups/load": {
"post": {
"security": [
{
"AppUserAuth": []
}
],
"description": "Gives the groups list. It can be filtered by category, title and privacy. V3",
"consumes": [
"application/json"
],
"tags": [
"Client"
],
"operationId": "GetGroupsV3",
"parameters": [
{
"description": "body data",
"name": "data",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/GroupsFilter"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/getGroupsResponseV3"
}
}
}
}
},
"/authman/synchronize": {
"post": {
"security": [
Expand Down Expand Up @@ -5239,12 +5362,7 @@ const docTemplate = `{
"type": "object",
"additionalProperties": {
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"type": "string"
}
}
"additionalProperties": {}
}
},
"settings": {
Expand Down Expand Up @@ -5470,6 +5588,10 @@ const docTemplate = `{
"description": "result limit",
"type": "integer"
},
"limit_id": {
"description": "limit id",
"type": "string"
},
"member_external_id": {
"description": "member user external id",
"type": "string"
Expand All @@ -5478,6 +5600,13 @@ const docTemplate = `{
"description": "member id",
"type": "string"
},
"member_statuses": {
"description": "member user status",
"type": "array",
"items": {
"type": "string"
}
},
"member_user_id": {
"description": "member user id",
"type": "string"
Expand Down Expand Up @@ -5965,12 +6094,7 @@ const docTemplate = `{
"type": "object",
"additionalProperties": {
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"type": "string"
}
}
"additionalProperties": {}
}
},
"settings": {
Expand Down Expand Up @@ -6165,6 +6289,20 @@ const docTemplate = `{
}
}
},
"getGroupsResponseV3": {
"type": "object",
"properties": {
"results": {
"type": "array",
"items": {
"$ref": "#/definitions/Group"
}
},
"total_count": {
"type": "integer"
}
}
},
"getPutAdminGroupIDsForEventIDRequestAndResponse": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -6807,12 +6945,7 @@ const docTemplate = `{
"type": "object",
"additionalProperties": {
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"type": "string"
}
}
"additionalProperties": {}
}
},
"settings": {
Expand Down
Loading