Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: remove unused code (#1245)

Yilong Lib592b30bf83f
diff --git a/api/backup.go b/api/backup.go
index 98303ce447..2243b99532 100644
--- a/api/backup.go
+++ b/api/backup.go
@@ -169,7 +169,6 @@ type BackupSetting struct {
DatabaseID int `jsonapi:"attr,databaseId"`
// Do not return this to the client since the client always has the database context and fetching the
// database object and all its own related objects is a bit expensive.
- // TODO(dragonly): do we need this field?
Database *Database
// Domain specific fields
diff --git a/server/activity_manager.go b/server/activity_manager.go
index 1fb3f03e8b..c1d524be03 100644
--- a/server/activity_manager.go
+++ b/server/activity_manager.go
@@ -66,20 +66,6 @@ func (m *ActivityManager) CreateActivity(ctx context.Context, create *api.Activi
return activity, nil
}
- // If we need to post webhook event, then we need to make sure the project info exists since we will include
- // the project name in the webhook event.
- if meta.issue.Project == nil {
- project, err := m.s.store.GetProjectByID(ctx, meta.issue.ProjectID)
- if err != nil {
- return nil, fmt.Errorf("failed to find project for posting webhook event after changing the issue status: %v, error: %w", meta.issue.Name, err)
- }
- if project == nil {
- return nil, fmt.Errorf("failed to find project ID %v for posting webhook event after changing the issue status %q", meta.issue.ProjectID, meta.issue.Name)
- }
- // TODO(dragonly): revisit the necessity of this function to depend on ActivityMeta.
- meta.issue.Project = project
- }
-
updater, err := m.s.store.GetPrincipalByID(ctx, create.CreatorID)
if err != nil {
return nil, fmt.Errorf("failed to find updater for posting webhook event after changing the issue status: %v, error: %w", meta.issue.Name, err)
diff --git a/server/backup_runner.go b/server/backup_runner.go
index 82eedcb225..da0d7b9e9e 100644
--- a/server/backup_runner.go
+++ b/server/backup_runner.go
@@ -73,24 +73,7 @@ func (s *BackupRunner) Run(ctx context.Context, wg *sync.WaitGroup) {
runningTasks[backupSetting.ID] = true
mu.Unlock()
- db, err := s.server.store.GetDatabase(ctx, &api.DatabaseFind{ID: &backupSetting.DatabaseID})
- if err != nil {
- s.l.Error("Failed to get database for backup setting",
- zap.Int("id", backupSetting.ID),
- zap.Int("databaseID", backupSetting.DatabaseID),
- zap.Error(err))
- continue
- }
- if db == nil {
- err := fmt.Errorf("failed to get database for backup setting, database ID not found %v", backupSetting.DatabaseID)
- s.l.Error(err.Error(),
- zap.Int("id", backupSetting.ID),
- zap.Int("databaseID", backupSetting.DatabaseID),
- zap.Error(err))
- continue
- }
- backupSetting.Database = db
-
+ db := backupSetting.Database
backupName := fmt.Sprintf("%s-%s-%s-autobackup", api.ProjectShortSlug(db.Project), api.EnvSlug(db.Instance.Environment), t.Format("20060102T030405"))
go func(database *api.Database, backupSettingID int, backupName string, hookURL string) {
s.l.Debug("Schedule auto backup",
diff --git a/store/database.go b/store/database.go
index c662413fe4..5b5ef8dad5 100644
--- a/store/database.go
+++ b/store/database.go
@@ -192,8 +192,6 @@ func (s *Store) composeDatabase(ctx context.Context, raw *databaseRaw) (*api.Dat
// Each database instance is created under a particular environment.
// The value of bb.environment is identical to the name of the environment.
- // TODO(dragonly): seems like we do not need to composed this.
- // need redesign, e.g., extract the kv part which is only in memory, and the relations which are in the database.
labelList = append(labelList, &api.DatabaseLabel{
Key: api.EnvironmentKeyName,
Value: db.Instance.Environment.Name,