chore(repo): reinitialize repository
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
package dashboard
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"inbox/internal/domain/humantask"
|
||||
"inbox/internal/domain/lane"
|
||||
"inbox/internal/domain/message"
|
||||
"inbox/internal/domain/role"
|
||||
"inbox/internal/domain/topic"
|
||||
"inbox/internal/domain/workflow"
|
||||
)
|
||||
|
||||
type workspaceTopicSnapshot struct {
|
||||
topics []topic.Record
|
||||
topicByID map[string]topic.Record
|
||||
messagesByTopic map[string][]message.Record
|
||||
runsByTopic map[string][]workflow.Run
|
||||
}
|
||||
|
||||
type workflowBoardSnapshot struct {
|
||||
workspaceTopicSnapshot
|
||||
roles []role.Definition
|
||||
lanesByTopic map[string][]lane.Record
|
||||
pendingByTopicRole map[string]map[string]int
|
||||
pendingByRole map[string]int
|
||||
pendingHumanByTopic map[string][]humantask.Record
|
||||
pendingHumanByTopicRole map[string]map[string]int
|
||||
pendingHumanByRole map[string]int
|
||||
}
|
||||
|
||||
func (s *Service) loadWorkspaceTopicSnapshot(ctx context.Context, workspaceID string, space topic.Space) (workspaceTopicSnapshot, error) {
|
||||
topics, err := s.repo.ListTopicsBySpace(ctx, workspaceID, space)
|
||||
if err != nil {
|
||||
return workspaceTopicSnapshot{}, err
|
||||
}
|
||||
messages, err := s.repo.ListMessagesByWorkspace(ctx, workspaceID)
|
||||
if err != nil {
|
||||
return workspaceTopicSnapshot{}, err
|
||||
}
|
||||
runs, err := s.repo.ListWorkflowRunsByWorkspace(ctx, workspaceID)
|
||||
if err != nil {
|
||||
return workspaceTopicSnapshot{}, err
|
||||
}
|
||||
|
||||
topicByID := make(map[string]topic.Record, len(topics))
|
||||
for _, item := range topics {
|
||||
topicByID[item.ID] = item
|
||||
}
|
||||
return workspaceTopicSnapshot{
|
||||
topics: topics,
|
||||
topicByID: topicByID,
|
||||
messagesByTopic: filterMessagesByKnownTopics(messages, topicByID),
|
||||
runsByTopic: filterRunsByKnownTopics(runs, topicByID),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *Service) loadWorkflowBoardSnapshot(ctx context.Context, workspaceID string) (workflowBoardSnapshot, error) {
|
||||
topicSnapshot, err := s.loadWorkspaceTopicSnapshot(ctx, workspaceID, topic.SpaceWorkflow)
|
||||
if err != nil {
|
||||
return workflowBoardSnapshot{}, err
|
||||
}
|
||||
roles, err := s.repo.ListRoles(ctx)
|
||||
if err != nil {
|
||||
return workflowBoardSnapshot{}, err
|
||||
}
|
||||
lanes, err := s.repo.ListLanesByWorkspace(ctx, workspaceID)
|
||||
if err != nil {
|
||||
return workflowBoardSnapshot{}, err
|
||||
}
|
||||
pending, err := s.repo.ListPendingDeliveriesByWorkspace(ctx, workspaceID)
|
||||
if err != nil {
|
||||
return workflowBoardSnapshot{}, err
|
||||
}
|
||||
pendingHumanTasks, err := s.repo.ListPendingHumanTasksByWorkspace(ctx, workspaceID)
|
||||
if err != nil {
|
||||
return workflowBoardSnapshot{}, err
|
||||
}
|
||||
|
||||
return workflowBoardSnapshot{
|
||||
workspaceTopicSnapshot: topicSnapshot,
|
||||
roles: roles,
|
||||
lanesByTopic: groupLanesByKnownTopics(lanes, topicSnapshot.topicByID),
|
||||
pendingByTopicRole: groupPendingDeliveriesByTopicRole(pending, topicSnapshot.topicByID),
|
||||
pendingByRole: groupPendingDeliveriesByRole(pending, topicSnapshot.topicByID),
|
||||
pendingHumanByTopic: groupHumanTasksByKnownTopics(pendingHumanTasks, topicSnapshot.topicByID),
|
||||
pendingHumanByTopicRole: groupPendingHumanTasksByTopicRole(
|
||||
pendingHumanTasks,
|
||||
topicSnapshot.topicByID,
|
||||
),
|
||||
pendingHumanByRole: groupPendingHumanTasksByRole(pendingHumanTasks, topicSnapshot.topicByID),
|
||||
}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user