MCPcopy Create free account
hub / github.com/bytebase/bytebase / DeleteExpiredExportArchives

Method DeleteExpiredExportArchives

backend/store/export_archive.go:96–116  ·  view source on GitHub ↗

DeleteExpiredExportArchives deletes export archives older than the specified retention period. Returns the number of archives deleted.

(ctx context.Context, workspaceID string, retentionPeriod time.Duration)

Source from the content-addressed store, hash-verified

94// DeleteExpiredExportArchives deletes export archives older than the specified retention period.
95// Returns the number of archives deleted.
96func (s *Store) DeleteExpiredExportArchives(ctx context.Context, workspaceID string, retentionPeriod time.Duration) (int64, error) {
97 cutoffTime := time.Now().Add(-retentionPeriod)
98
99 q := qb.Q().Space("DELETE FROM export_archive WHERE workspace = ?", workspaceID).And("created_at < ?", cutoffTime)
100 query, args, err := q.ToSQL()
101 if err != nil {
102 return 0, errors.Wrapf(err, "failed to build sql")
103 }
104
105 result, err := s.GetDB().ExecContext(ctx, query, args...)
106 if err != nil {
107 return 0, err
108 }
109
110 rowsAffected, err := result.RowsAffected()
111 if err != nil {
112 return 0, err
113 }
114
115 return rowsAffected, nil
116}

Callers

nothing calls this directly

Calls 5

GetDBMethod · 0.95
QFunction · 0.92
AndMethod · 0.80
SpaceMethod · 0.80
ToSQLMethod · 0.80

Tested by

no test coverage detected