Ensure post pruning has a random selection element
This commit is contained in:
parent
dc397903b2
commit
cc9e397f60
|
@ -27,16 +27,18 @@ class Command(BaseCommand):
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
# Find a set of posts that match the initial criteria
|
# Find a set of posts that match the initial criteria
|
||||||
print(f"Running query to find up to {number} old posts...")
|
print(f"Running query to find up to {number} old posts...")
|
||||||
posts = Post.objects.filter(
|
posts = (
|
||||||
local=False,
|
Post.objects.filter(
|
||||||
created__lt=timezone.now()
|
local=False,
|
||||||
- datetime.timedelta(days=settings.SETUP.REMOTE_PRUNE_HORIZON),
|
created__lt=timezone.now()
|
||||||
).exclude(
|
- datetime.timedelta(days=settings.SETUP.REMOTE_PRUNE_HORIZON),
|
||||||
Q(interactions__identity__local=True)
|
)
|
||||||
| Q(visibility=Post.Visibilities.mentioned)
|
.exclude(
|
||||||
)[
|
Q(interactions__identity__local=True)
|
||||||
:number
|
| Q(visibility=Post.Visibilities.mentioned)
|
||||||
]
|
)
|
||||||
|
.order_by("?")[:number]
|
||||||
|
)
|
||||||
post_ids_and_uris = dict(posts.values_list("object_uri", "id"))
|
post_ids_and_uris = dict(posts.values_list("object_uri", "id"))
|
||||||
print(f" found {len(post_ids_and_uris)}")
|
print(f" found {len(post_ids_and_uris)}")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue