mirror of
https://github.com/yzernik/squeaknode.git
synced 2026-08-15 12:50:47 +02:00
Only delete squeaks that are not liked (#880)
This commit is contained in:
parent
c4477a9168
commit
bfbb4ba335
2 changed files with 11 additions and 6 deletions
|
|
@ -90,7 +90,11 @@ class SqueakDb:
|
|||
|
||||
@property
|
||||
def squeak_is_liked(self):
|
||||
return self.squeaks.c.liked # noqa: E711
|
||||
return self.squeaks.c.liked
|
||||
|
||||
@property
|
||||
def squeak_is_not_liked(self):
|
||||
return self.squeaks.c.liked == False # noqa: E711
|
||||
|
||||
@property
|
||||
def squeak_has_no_secret_key(self):
|
||||
|
|
@ -442,10 +446,10 @@ class SqueakDb:
|
|||
hashes = [bytes.fromhex(row["hash"]) for row in rows]
|
||||
return hashes
|
||||
|
||||
def yield_old_squeaks_to_delete(
|
||||
def get_old_squeaks_to_delete(
|
||||
self,
|
||||
interval_s: int,
|
||||
) -> Iterator[SqueakEntryWithProfile]:
|
||||
) -> List[SqueakEntryWithProfile]:
|
||||
""" Get squeaks older than retention that meet the
|
||||
criteria for deletion.
|
||||
"""
|
||||
|
|
@ -459,11 +463,12 @@ class SqueakDb:
|
|||
)
|
||||
.where(self.squeak_is_older_than_retention(interval_s))
|
||||
.where(self.profile_has_no_private_key)
|
||||
.where(self.squeak_is_not_liked)
|
||||
)
|
||||
with self.get_connection() as connection:
|
||||
result = connection.execute(s)
|
||||
for row in result:
|
||||
yield self._parse_squeak_entry_with_profile(row)
|
||||
rows = result.fetchall()
|
||||
return [self._parse_squeak_entry_with_profile(row) for row in rows]
|
||||
|
||||
def insert_profile(self, squeak_profile: SqueakProfile) -> int:
|
||||
""" Insert a new squeak profile. """
|
||||
|
|
|
|||
|
|
@ -526,7 +526,7 @@ class SqueakController:
|
|||
self.payment_processor.start_processing()
|
||||
|
||||
def delete_old_squeaks(self):
|
||||
squeaks_to_delete = self.squeak_db.yield_old_squeaks_to_delete(
|
||||
squeaks_to_delete = self.squeak_db.get_old_squeaks_to_delete(
|
||||
self.config.core.squeak_retention_s,
|
||||
)
|
||||
for squeak_entry_with_profile in squeaks_to_delete:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue