Skip to content

Conversation

@rowanseymour
Copy link
Member

No description provided.

@codecov
Copy link

codecov bot commented Dec 15, 2025

Codecov Report

❌ Patch coverage is 66.66667% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.57%. Comparing base (420962e) to head (33b267f).

Files with missing lines Patch % Lines
archives/archives.go 70.58% 5 Missing and 5 partials ⚠️
archives/s3.go 61.53% 7 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #143      +/-   ##
==========================================
+ Coverage   58.03%   58.57%   +0.53%     
==========================================
  Files           7        7              
  Lines         908      968      +60     
==========================================
+ Hits          527      567      +40     
- Misses        276      288      +12     
- Partials      105      113       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rowanseymour rowanseymour force-pushed the delete-dailies-after-rolling-up branch from 84e0ccf to 8550aea Compare December 15, 2025 19:51
@rowanseymour rowanseymour force-pushed the delete-dailies-after-rolling-up branch from 8550aea to c2fe571 Compare December 15, 2025 19:58
@rowanseymour rowanseymour marked this pull request as ready for review December 15, 2025 20:13
Copilot AI review requested due to automatic review settings December 15, 2025 20:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements automatic deletion of daily archives after they have been rolled up into monthly archives and their records deleted. This helps reduce storage costs by removing redundant daily archives once their data has been consolidated into monthly archives.

Key changes:

  • Added DeleteRolledUpDailyArchives function to identify and delete daily archives that have been rolled up and deleted
  • Added DeleteS3Files utility function for efficient batch deletion of S3 objects (up to 1000 per request)
  • Integrated the deletion logic into the main archive workflow
  • Added comprehensive test coverage for the new deletion functionality
  • Updated test data to reflect proper archive states

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
archives/archives.go Adds DeleteRolledUpDailyArchives function and integrates it into the ArchiveOrg workflow to clean up daily archives after rollup
archives/s3.go Adds DeleteS3Files function for batch deletion of S3 objects with automatic batching and error handling
archives/archives_test.go Adds comprehensive test for the daily archive deletion flow including rollup, record deletion, and archive cleanup
testdb.sql Updates test data to set one archive's needs_deletion to FALSE to ensure proper test conditions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

slog.Error("error deleting S3 object in batch", "bucket", bucket, "key", *e.Key, "error", *e.Message)
}
totalDeleted += len(batch) - len(output.Errors)
lastErr = fmt.Errorf("%d errors deleting S3 objects", len(output.Errors))
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message only reflects the count of errors from the last batch with failures, not the cumulative count across all batches. If multiple batches have errors, only the last batch's error count is reported in the returned error. Consider tracking and reporting the total number of errors across all batches, or clarifying in the message that this is the last batch's error count.

Copilot uses AI. Check for mistakes.
// check for individual errors
if len(output.Errors) > 0 {
for _, e := range output.Errors {
slog.Error("error deleting S3 object in batch", "bucket", bucket, "key", *e.Key, "error", *e.Message)
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential nil pointer dereference. The code assumes that e.Key and e.Message are non-nil, but the AWS SDK types may return nil pointers for these fields in error cases. Consider adding nil checks before dereferencing these pointers to avoid panics.

Suggested change
slog.Error("error deleting S3 object in batch", "bucket", bucket, "key", *e.Key, "error", *e.Message)
key := "<nil>"

Copilot uses AI. Check for mistakes.
of deleted_on since empty ones don't get deleted_on set
@rowanseymour rowanseymour force-pushed the delete-dailies-after-rolling-up branch from a53be61 to 33b267f Compare December 15, 2025 22:19
@rowanseymour rowanseymour merged commit 5f588d3 into main Dec 16, 2025
7 checks passed
@rowanseymour rowanseymour deleted the delete-dailies-after-rolling-up branch December 16, 2025 14:06
@github-actions github-actions bot locked and limited conversation to collaborators Dec 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants