diff options
author | 2023-02-11 12:48:38 +0100 | |
---|---|---|
committer | 2023-02-11 12:48:38 +0100 | |
commit | 40bc03e71789523ec0f3cc4ae9f8532430832cd4 (patch) | |
tree | 9a2baceffea0b80d1701b636eb19107b96e70fd3 /internal/db/media.go | |
parent | [performance] remove throttling timers (#1466) (diff) | |
download | gotosocial-40bc03e71789523ec0f3cc4ae9f8532430832cd4.tar.xz |
[chore/performance] Update media prune logic, add extra CLI command (#1474)v0.7.0-rc2
* start updating media prune stuff a wee bit
* continue prune / uncache work
* more tidying + consistency stuff
* add prune CLI command
* docs
* arg
Diffstat (limited to 'internal/db/media.go')
-rw-r--r-- | internal/db/media.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/internal/db/media.go b/internal/db/media.go index f9bc5bd03..3756bd58f 100644 --- a/internal/db/media.go +++ b/internal/db/media.go @@ -37,6 +37,11 @@ type Media interface { // In other words, media attachments that originated remotely, and that we currently have cached locally. GetRemoteOlderThan(ctx context.Context, olderThan time.Time, limit int) ([]*gtsmodel.MediaAttachment, Error) + // CountRemoteOlderThan is like GetRemoteOlderThan, except instead of getting limit n attachments, + // it just counts how many remote attachments in the database (including avatars and headers) meet + // the olderThan criteria. + CountRemoteOlderThan(ctx context.Context, olderThan time.Time) (int, Error) + // GetAvatarsAndHeaders fetches limit n avatars and headers with an id < maxID. These headers // and avis may be in use or not; the caller should check this if it's important. GetAvatarsAndHeaders(ctx context.Context, maxID string, limit int) ([]*gtsmodel.MediaAttachment, Error) @@ -44,5 +49,11 @@ type Media interface { // GetLocalUnattachedOlderThan fetches limit n local media attachments (including avatars and headers), older than // the given time, which aren't header or avatars, and aren't attached to a status. In other words, attachments which were // uploaded but never used for whatever reason, or attachments that were attached to a status which was subsequently deleted. - GetLocalUnattachedOlderThan(ctx context.Context, olderThan time.Time, maxID string, limit int) ([]*gtsmodel.MediaAttachment, Error) + // + // These will be returned in order of attachment.created_at descending (newest to oldest in other words). + GetLocalUnattachedOlderThan(ctx context.Context, olderThan time.Time, limit int) ([]*gtsmodel.MediaAttachment, Error) + + // CountLocalUnattachedOlderThan is like GetLocalUnattachedOlderThan, except instead of getting limit n attachments, + // it just counts how many local attachments in the database meet the olderThan criteria. + CountLocalUnattachedOlderThan(ctx context.Context, olderThan time.Time) (int, Error) } |