Initial commit: Open sourcing all of the Maple Open Technologies code.
This commit is contained in:
commit
755d54a99d
2010 changed files with 448675 additions and 0 deletions
|
|
@ -0,0 +1,50 @@
|
|||
// monorepo/cloud/backend/internal/usecase/filemetadata/anonymize_old_ips.go
|
||||
package filemetadata
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"codeberg.org/mapleopentech/monorepo/cloud/maplefile-backend/config"
|
||||
dom_file "codeberg.org/mapleopentech/monorepo/cloud/maplefile-backend/internal/domain/file"
|
||||
)
|
||||
|
||||
type AnonymizeOldIPsUseCase interface {
|
||||
Execute(ctx context.Context, cutoffDate time.Time) (int, error)
|
||||
}
|
||||
|
||||
type anonymizeOldIPsUseCaseImpl struct {
|
||||
config *config.Configuration
|
||||
logger *zap.Logger
|
||||
repo dom_file.FileMetadataRepository
|
||||
}
|
||||
|
||||
func NewAnonymizeOldIPsUseCase(
|
||||
config *config.Configuration,
|
||||
logger *zap.Logger,
|
||||
repo dom_file.FileMetadataRepository,
|
||||
) AnonymizeOldIPsUseCase {
|
||||
logger = logger.Named("FileMetadataAnonymizeOldIPsUseCase")
|
||||
return &anonymizeOldIPsUseCaseImpl{config, logger, repo}
|
||||
}
|
||||
|
||||
func (uc *anonymizeOldIPsUseCaseImpl) Execute(ctx context.Context, cutoffDate time.Time) (int, error) {
|
||||
uc.logger.Debug("Anonymizing old IPs in file metadata tables",
|
||||
zap.Time("cutoff_date", cutoffDate))
|
||||
|
||||
count, err := uc.repo.AnonymizeOldIPs(ctx, cutoffDate)
|
||||
if err != nil {
|
||||
uc.logger.Error("Failed to anonymize old IPs in file metadata tables",
|
||||
zap.Error(err),
|
||||
zap.Time("cutoff_date", cutoffDate))
|
||||
return 0, err
|
||||
}
|
||||
|
||||
uc.logger.Info("Successfully anonymized old IPs in file metadata tables",
|
||||
zap.Int("count", count),
|
||||
zap.Time("cutoff_date", cutoffDate))
|
||||
|
||||
return count, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue