2020-07-18 02:40:05 +02:00
|
|
|
package graph
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"database/sql"
|
|
|
|
|
2020-08-07 03:50:35 +02:00
|
|
|
"github.com/jordanknott/taskcafe/internal/db"
|
2020-07-18 02:40:05 +02:00
|
|
|
)
|
|
|
|
|
2020-08-21 01:11:24 +02:00
|
|
|
// GetOwnedList todo: remove this
|
2020-07-18 02:40:05 +02:00
|
|
|
func GetOwnedList(ctx context.Context, r db.Repository, user db.UserAccount) (*OwnedList, error) {
|
2020-08-01 03:01:14 +02:00
|
|
|
return &OwnedList{}, nil
|
2020-07-18 02:40:05 +02:00
|
|
|
}
|
2020-08-21 01:11:24 +02:00
|
|
|
|
|
|
|
// GetMemberList returns a list of projects the user is a member of
|
2020-07-18 02:40:05 +02:00
|
|
|
func GetMemberList(ctx context.Context, r db.Repository, user db.UserAccount) (*MemberList, error) {
|
|
|
|
projectMemberIDs, err := r.GetMemberProjectIDsForUserID(ctx, user.UserID)
|
|
|
|
if err != sql.ErrNoRows && err != nil {
|
|
|
|
return &MemberList{}, err
|
|
|
|
}
|
|
|
|
var projects []db.Project
|
|
|
|
for _, projectID := range projectMemberIDs {
|
|
|
|
project, err := r.GetProjectByID(ctx, projectID)
|
|
|
|
if err != nil {
|
|
|
|
return &MemberList{}, err
|
|
|
|
}
|
|
|
|
projects = append(projects, project)
|
|
|
|
}
|
|
|
|
teamMemberIDs, err := r.GetMemberTeamIDsForUserID(ctx, user.UserID)
|
|
|
|
if err != sql.ErrNoRows && err != nil {
|
|
|
|
return &MemberList{}, err
|
|
|
|
}
|
|
|
|
var teams []db.Team
|
|
|
|
for _, teamID := range teamMemberIDs {
|
|
|
|
team, err := r.GetTeamByID(ctx, teamID)
|
|
|
|
if err != nil {
|
|
|
|
return &MemberList{}, err
|
|
|
|
}
|
|
|
|
teams = append(teams, team)
|
|
|
|
}
|
|
|
|
|
|
|
|
return &MemberList{Teams: teams, Projects: projects}, nil
|
|
|
|
}
|
2020-12-19 03:34:35 +01:00
|
|
|
|
|
|
|
type ActivityData struct {
|
|
|
|
Data map[string]string
|
|
|
|
}
|