Changeset 0.21.1.1 (#87)
This commit is contained in:
@@ -30,10 +30,10 @@ func (s *ProjectStore) Create(ctx context.Context, p *models.Project) error {
|
||||
|
||||
func (s *ProjectStore) GetByID(ctx context.Context, id string) (*models.Project, error) {
|
||||
var p models.Project
|
||||
var teamID sql.NullString
|
||||
var teamID, workspaceID sql.NullString
|
||||
err := DB.QueryRowContext(ctx, `
|
||||
SELECT p.id, p.name, p.description, p.color, p.icon, p.scope,
|
||||
p.owner_id, p.team_id, p.is_archived, p.settings,
|
||||
p.owner_id, p.team_id, p.is_archived, p.workspace_id, p.settings,
|
||||
p.created_at, p.updated_at,
|
||||
(SELECT COUNT(*) FROM project_channels WHERE project_id = p.id),
|
||||
(SELECT COUNT(*) FROM project_knowledge_bases WHERE project_id = p.id),
|
||||
@@ -41,7 +41,7 @@ func (s *ProjectStore) GetByID(ctx context.Context, id string) (*models.Project,
|
||||
FROM projects p
|
||||
WHERE p.id = $1`, id).Scan(
|
||||
&p.ID, &p.Name, &p.Description, &p.Color, &p.Icon, &p.Scope,
|
||||
&p.OwnerID, &teamID, &p.IsArchived, &p.Settings,
|
||||
&p.OwnerID, &teamID, &p.IsArchived, &workspaceID, &p.Settings,
|
||||
&p.CreatedAt, &p.UpdatedAt,
|
||||
&p.ChannelCount, &p.KBCount, &p.NoteCount,
|
||||
)
|
||||
@@ -49,6 +49,7 @@ func (s *ProjectStore) GetByID(ctx context.Context, id string) (*models.Project,
|
||||
return nil, err
|
||||
}
|
||||
p.TeamID = NullableStringPtr(teamID)
|
||||
p.WorkspaceID = NullableStringPtr(workspaceID)
|
||||
return &p, nil
|
||||
}
|
||||
|
||||
@@ -69,6 +70,9 @@ func (s *ProjectStore) Update(ctx context.Context, id string, patch models.Proje
|
||||
if patch.IsArchived != nil {
|
||||
b.Set("is_archived", *patch.IsArchived)
|
||||
}
|
||||
if patch.WorkspaceID != nil {
|
||||
b.Set("workspace_id", models.NullString(patch.WorkspaceID))
|
||||
}
|
||||
if len(patch.Settings) > 0 {
|
||||
// Merge: read existing settings, overlay with patch values, write back.
|
||||
var existing models.JSONMap
|
||||
@@ -114,7 +118,7 @@ func (s *ProjectStore) ListForUser(ctx context.Context, userID string, teamIDs [
|
||||
// User sees: their personal projects + team projects for their teams + global projects
|
||||
q := `
|
||||
SELECT p.id, p.name, p.description, p.color, p.icon, p.scope,
|
||||
p.owner_id, p.team_id, p.is_archived, p.settings,
|
||||
p.owner_id, p.team_id, p.is_archived, p.workspace_id, p.settings,
|
||||
p.created_at, p.updated_at,
|
||||
(SELECT COUNT(*) FROM project_channels WHERE project_id = p.id),
|
||||
(SELECT COUNT(*) FROM project_knowledge_bases WHERE project_id = p.id),
|
||||
@@ -403,16 +407,17 @@ func queryProjects(ctx context.Context, q string, args ...interface{}) ([]models
|
||||
var result []models.Project
|
||||
for rows.Next() {
|
||||
var p models.Project
|
||||
var teamID sql.NullString
|
||||
var teamID, workspaceID sql.NullString
|
||||
if err := rows.Scan(
|
||||
&p.ID, &p.Name, &p.Description, &p.Color, &p.Icon, &p.Scope,
|
||||
&p.OwnerID, &teamID, &p.IsArchived, &p.Settings,
|
||||
&p.OwnerID, &teamID, &p.IsArchived, &workspaceID, &p.Settings,
|
||||
&p.CreatedAt, &p.UpdatedAt,
|
||||
&p.ChannelCount, &p.KBCount, &p.NoteCount,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
p.TeamID = NullableStringPtr(teamID)
|
||||
p.WorkspaceID = NullableStringPtr(workspaceID)
|
||||
result = append(result, p)
|
||||
}
|
||||
return result, rows.Err()
|
||||
|
||||
Reference in New Issue
Block a user