diff --git a/nostr_dvm/tasks/content_discovery_currently_popular.py b/nostr_dvm/tasks/content_discovery_currently_popular.py index af9b925..dca3afb 100644 --- a/nostr_dvm/tasks/content_discovery_currently_popular.py +++ b/nostr_dvm/tasks/content_discovery_currently_popular.py @@ -27,6 +27,8 @@ class DicoverContentCurrentlyPopular(DVMTaskInterface): FIX_COST: float = 0 dvm_config: DVMConfig last_schedule: int + db_since = 3600 + db_name = "db/nostr_recent_notes.db" def __init__(self, name, dvm_config: DVMConfig, nip89config: NIP89Config, nip88config: NIP88Config = None, admin_config: AdminConfig = None, options=None): @@ -87,7 +89,7 @@ class DicoverContentCurrentlyPopular(DVMTaskInterface): keys = Keys.parse(sk.to_hex()) signer = NostrSigner.keys(keys) - database = NostrDatabase.sqlite("db/nostr_recent_notes.db") + database = NostrDatabase.sqlite(self.db_name) cli = ClientBuilder().database(database).signer(signer).opts(opts).build() cli.add_relay("wss://relay.damus.io") @@ -95,7 +97,7 @@ class DicoverContentCurrentlyPopular(DVMTaskInterface): # Negentropy reconciliation # Query events from database - timestamp_hour_ago = Timestamp.now().as_secs() - 3600 + timestamp_hour_ago = Timestamp.now().as_secs() - self.db_since lasthour = Timestamp.from_secs(timestamp_hour_ago) filter1 = Filter().kind(definitions.EventDefinitions.KIND_NOTE).since(lasthour) @@ -142,13 +144,13 @@ class DicoverContentCurrentlyPopular(DVMTaskInterface): sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY) keys = Keys.parse(sk.to_hex()) signer = NostrSigner.keys(keys) - database = NostrDatabase.sqlite("db/nostr_recent_notes.db") + database = NostrDatabase.sqlite(self.db_name) cli = ClientBuilder().signer(signer).database(database).opts(opts).build() cli.add_relay("wss://relay.damus.io") cli.connect() - timestamp_hour_ago = Timestamp.now().as_secs() - 3600 + timestamp_hour_ago = Timestamp.now().as_secs() - self.db_since lasthour = Timestamp.from_secs(timestamp_hour_ago) filter1 = Filter().kinds([definitions.EventDefinitions.KIND_NOTE, definitions.EventDefinitions.KIND_REACTION, definitions.EventDefinitions.KIND_ZAP]).since(lasthour) # Notes, reactions, zaps @@ -158,7 +160,7 @@ class DicoverContentCurrentlyPopular(DVMTaskInterface): dbopts = NegentropyOptions().direction(NegentropyDirection.DOWN) cli.reconcile(filter1, dbopts) database.delete(Filter().until(Timestamp.from_secs( - Timestamp.now().as_secs() - 3600))) # Clear old events so db doesnt get too full. + Timestamp.now().as_secs() - self.db_since))) # Clear old events so db doesnt get too full. print("Done Syncing Notes of Last hour.") diff --git a/nostr_dvm/tasks/content_discovery_currently_popular_followers.py b/nostr_dvm/tasks/content_discovery_currently_popular_followers.py index 9ee236e..79abac3 100644 --- a/nostr_dvm/tasks/content_discovery_currently_popular_followers.py +++ b/nostr_dvm/tasks/content_discovery_currently_popular_followers.py @@ -28,6 +28,8 @@ class DicoverContentCurrentlyPopularFollowers(DVMTaskInterface): FIX_COST: float = 0 dvm_config: DVMConfig last_schedule: int + db_since = 2 * 3600 + db_name = "db/nostr_recent_notes2.db" def __init__(self, name, dvm_config: DVMConfig, nip89config: NIP89Config, nip88config: NIP88Config = None, admin_config: AdminConfig = None, options=None): @@ -94,7 +96,7 @@ class DicoverContentCurrentlyPopularFollowers(DVMTaskInterface): keys = Keys.parse(sk.to_hex()) signer = NostrSigner.keys(keys) - database = NostrDatabase.sqlite("db/nostr_recent_notes2.db") + database = NostrDatabase.sqlite(self.db_name) cli = ClientBuilder().database(database).signer(signer).opts(opts).build() cli.add_relay("wss://relay.damus.io") cli.add_relay("wss://nos.lol") @@ -112,7 +114,7 @@ class DicoverContentCurrentlyPopularFollowers(DVMTaskInterface): # Negentropy reconciliation # Query events from database - timestamp_hour_ago = Timestamp.now().as_secs() - 7200 + timestamp_hour_ago = Timestamp.now().as_secs() - self.db_since lasthour = Timestamp.from_secs(timestamp_hour_ago) @@ -182,13 +184,13 @@ class DicoverContentCurrentlyPopularFollowers(DVMTaskInterface): sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY) keys = Keys.parse(sk.to_hex()) signer = NostrSigner.keys(keys) - database = NostrDatabase.sqlite("db/nostr_recent_notes2.db") + database = NostrDatabase.sqlite(self.db_name) cli = ClientBuilder().signer(signer).database(database).opts(opts).build() cli.add_relay("wss://relay.damus.io") cli.connect() - timestamp_hour_ago = Timestamp.now().as_secs() - 7200 + timestamp_hour_ago = Timestamp.now().as_secs() - self.db_since lasthour = Timestamp.from_secs(timestamp_hour_ago) filter1 = Filter().kinds([definitions.EventDefinitions.KIND_NOTE, definitions.EventDefinitions.KIND_REACTION, @@ -199,7 +201,7 @@ class DicoverContentCurrentlyPopularFollowers(DVMTaskInterface): dbopts = NegentropyOptions().direction(NegentropyDirection.DOWN) cli.reconcile(filter1, dbopts) database.delete(Filter().until(Timestamp.from_secs( - Timestamp.now().as_secs() - 7200))) # Clear old events so db doesnt get too full. + Timestamp.now().as_secs() - self.db_since))) # Clear old events so db doesnt get too full. print("Done Syncing Notes of Last hour.") diff --git a/nostr_dvm/tasks/search_users.py b/nostr_dvm/tasks/search_users.py index 80b490e..5d3ee76 100644 --- a/nostr_dvm/tasks/search_users.py +++ b/nostr_dvm/tasks/search_users.py @@ -26,6 +26,7 @@ class SearchUser(DVMTaskInterface): FIX_COST: float = 0 dvm_config: DVMConfig last_schedule: int = 0 + db_name = "db/nostr_profiles.db" def __init__(self, name, dvm_config: DVMConfig, nip89config: NIP89Config, nip88config: NIP88Config = None, admin_config: AdminConfig = None, options=None): @@ -84,7 +85,7 @@ class SearchUser(DVMTaskInterface): keys = Keys.parse(sk.to_hex()) signer = NostrSigner.keys(keys) - database = NostrDatabase.sqlite("db/nostr_profiles.db") + database = NostrDatabase.sqlite(self.db_name) cli = ClientBuilder().database(database).signer(signer).opts(opts).build() cli.add_relay("wss://relay.damus.io") @@ -147,7 +148,7 @@ class SearchUser(DVMTaskInterface): sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY) keys = Keys.parse(sk.to_hex()) signer = NostrSigner.keys(keys) - database = NostrDatabase.sqlite("db/nostr_profiles.db") + database = NostrDatabase.sqlite(self.db_name) cli = ClientBuilder().signer(signer).database(database).opts(opts).build() cli.add_relay("wss://relay.damus.io")