Changeset 0.9.3 (#53)
This commit is contained in:
@@ -134,6 +134,21 @@ func (s *CatalogStore) ListAll(ctx context.Context) ([]models.CatalogEntry, erro
|
||||
return scanCatalogEntries(rows)
|
||||
}
|
||||
|
||||
// ListAllGlobal returns all catalog entries whose provider_config has scope='global'.
|
||||
// Used by admin panel — admin should not see user BYOK or team-level models.
|
||||
func (s *CatalogStore) ListAllGlobal(ctx context.Context) ([]models.CatalogEntry, error) {
|
||||
rows, err := DB.QueryContext(ctx,
|
||||
fmt.Sprintf(`SELECT %s FROM model_catalog mc
|
||||
JOIN provider_configs pc ON pc.id = mc.provider_config_id
|
||||
WHERE pc.scope = 'global'
|
||||
ORDER BY mc.model_id`, catalogColsMC))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
return scanCatalogEntries(rows)
|
||||
}
|
||||
|
||||
func (s *CatalogStore) SetVisibility(ctx context.Context, id string, visibility string) error {
|
||||
_, err := DB.ExecContext(ctx,
|
||||
"UPDATE model_catalog SET visibility = $1 WHERE id = $2", visibility, id)
|
||||
@@ -149,7 +164,10 @@ func (s *CatalogStore) BulkSetVisibility(ctx context.Context, providerConfigID s
|
||||
|
||||
func (s *CatalogStore) BulkSetVisibilityAll(ctx context.Context, visibility string) error {
|
||||
_, err := DB.ExecContext(ctx,
|
||||
"UPDATE model_catalog SET visibility = $1", visibility)
|
||||
`UPDATE model_catalog SET visibility = $1
|
||||
WHERE provider_config_id IN (
|
||||
SELECT id FROM provider_configs WHERE scope = 'global'
|
||||
)`, visibility)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user