Changeset 0.21.4 (#90)

This commit is contained in:
2026-03-01 19:42:22 +00:00
parent bbbbe65bfa
commit d67cfd37c2
21 changed files with 1572 additions and 11 deletions

View File

@@ -16,7 +16,7 @@ func NewWorkspaceStore() *WorkspaceStore { return &WorkspaceStore{} }
// ── columns ────────────────────────────────
const workspaceCols = `id, owner_type, owner_id, name, root_path, max_bytes, status, indexing_enabled, created_at, updated_at`
const workspaceCols = `id, owner_type, owner_id, name, root_path, max_bytes, status, indexing_enabled, git_remote_url, git_branch, git_credential_id, git_last_sync, created_at, updated_at`
const workspaceFileCols = `id, workspace_id, path, is_directory, content_type, size_bytes, sha256, index_status, chunk_count, created_at, updated_at`
// ── scanners ───────────────────────────────
@@ -24,9 +24,12 @@ const workspaceFileCols = `id, workspace_id, path, is_directory, content_type, s
func scanWorkspace(row interface{ Scan(dest ...interface{}) error }) (*models.Workspace, error) {
var w models.Workspace
var maxBytes sql.NullInt64
var gitRemote, gitBranch, gitCredID sql.NullString
var gitSync sql.NullTime
err := row.Scan(
&w.ID, &w.OwnerType, &w.OwnerID, &w.Name,
&w.RootPath, &maxBytes, &w.Status, &w.IndexingEnabled,
&gitRemote, &gitBranch, &gitCredID, &gitSync,
&w.CreatedAt, &w.UpdatedAt,
)
if err != nil {
@@ -35,6 +38,18 @@ func scanWorkspace(row interface{ Scan(dest ...interface{}) error }) (*models.Wo
if maxBytes.Valid {
w.MaxBytes = &maxBytes.Int64
}
if gitRemote.Valid {
w.GitRemoteURL = &gitRemote.String
}
if gitBranch.Valid {
w.GitBranch = &gitBranch.String
}
if gitCredID.Valid {
w.GitCredentialID = &gitCredID.String
}
if gitSync.Valid {
w.GitLastSync = &gitSync.Time
}
return &w, nil
}
@@ -106,6 +121,15 @@ func (s *WorkspaceStore) Update(ctx context.Context, id string, patch models.Wor
if patch.IndexingEnabled != nil {
b.Set("indexing_enabled", *patch.IndexingEnabled)
}
if patch.GitRemoteURL != nil {
b.Set("git_remote_url", *patch.GitRemoteURL)
}
if patch.GitBranch != nil {
b.Set("git_branch", *patch.GitBranch)
}
if patch.GitCredentialID != nil {
b.Set("git_credential_id", *patch.GitCredentialID)
}
if !b.HasSets() {
return nil
}
@@ -365,3 +389,10 @@ func (s *WorkspaceStore) UpdateFileIndexStatus(ctx context.Context, fileID, stat
status, chunkCount, fileID)
return err
}
func (s *WorkspaceStore) SetGitLastSync(ctx context.Context, workspaceID string, t time.Time) error {
_, err := DB.ExecContext(ctx,
`UPDATE workspaces SET git_last_sync = $1, updated_at = NOW() WHERE id = $2`,
t, workspaceID)
return err
}