Skip to content

Commit

Permalink
feat: Add send route for ticket plan with enhanced Stakwork integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Shoaibdev7 committed Feb 15, 2025
1 parent 310fdbf commit dcddca8
Show file tree
Hide file tree
Showing 9 changed files with 517 additions and 2 deletions.
14 changes: 14 additions & 0 deletions db/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,20 @@ func (db database) GetFeatureArchitecture(featureUuid string) (string, error) {
return featureArchitecture, nil
}

func (db database) GetPhaseDesign(phaseUUID string) (string, error) {
phase := FeaturePhase{}
result := db.db.Model(&FeaturePhase{}).Where("uuid = ?", phaseUUID).First(&phase)
if result.Error != nil {
return "", fmt.Errorf("error getting phase: %v", result.Error)
}

phaseDesign := fmt.Sprintf("Phase: %s. Design: %s",
phase.Name,
phase.PhaseDesign)

return phaseDesign, nil
}

func (db database) UpdateFeatureStatus(uuid string, status FeatureStatus) (WorkspaceFeatures, error) {
var feature WorkspaceFeatures

Expand Down
2 changes: 2 additions & 0 deletions db/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ type Database interface {
GetProductBrief(workspaceUuid string) (string, error)
GetFeatureBrief(featureUuid string) (string, error)
GetFeatureArchitecture(featureUuid string) (string, error)
GetPhaseDesign(phaseUUID string) (string, error)
GetTicketsByPhaseUUID(featureUUID string, phaseUUID string) ([]Tickets, error)
AddChat(chat *Chat) (Chat, error)
UpdateChat(chat *Chat) (Chat, error)
Expand Down Expand Up @@ -305,5 +306,6 @@ type Database interface {
GetLatestActivityByThread(threadID string) (*Activity, error)
CreateActivityThread(sourceID string, activity *Activity) (*Activity, error)
DeleteActivity(id string) error
BuildTicketArray(groupIDs []string) []TicketArrayItem
GetBountiesByWorkspaceAndTimeRange(workspaceId string, startDate time.Time, endDate time.Time) ([]NewBounty, error)
}
5 changes: 5 additions & 0 deletions db/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,11 @@ type Tickets struct {
UpdatedAt time.Time `gorm:"type:timestamp;default:current_timestamp" json:"updated_at"`
}

type TicketArrayItem struct {
TicketName string `json:"ticket_name"`
TicketDescription string `json:"ticket_description"`
}

type BroadcastType string

const (
Expand Down
34 changes: 33 additions & 1 deletion db/ticket_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,36 @@ func (db database) GetTicketPlansByWorkspace(workspaceUUID string) ([]TicketPlan
return nil, fmt.Errorf("failed to fetch ticket plans by workspace: %w", err)
}
return plans, nil
}
}

func (db database) BuildTicketArray(groupIDs []string) []TicketArrayItem {
var ticketArray []TicketArrayItem

for _, groupID := range groupIDs {
var tickets []Tickets
result := db.db.Where("ticket_group = ?", groupID).Find(&tickets)
if result.Error != nil {
continue
}

var latestVersion int
var latestName, latestDescription string

for _, ticket := range tickets {
if ticket.Version > latestVersion {
latestVersion = ticket.Version
latestName = ticket.Name
latestDescription = ticket.Description
}
}

if latestVersion > 0 {
ticketArray = append(ticketArray, TicketArrayItem{
TicketName: latestName,
TicketDescription: latestDescription,
})
}
}

return ticketArray
}
Loading

0 comments on commit dcddca8

Please sign in to comment.