add max_results option to nostr.band trending

This commit is contained in:
Believethehype 2024-05-17 10:52:41 +02:00
parent f5548c6fac
commit fd51555583
2 changed files with 8 additions and 3 deletions

View File

@ -44,13 +44,18 @@ class TrendingNotesNostrBand(DVMTaskInterface):
print(self.dvm_config.PRIVATE_KEY)
request_form = {"jobID": event.id().to_hex()}
max_results = 200
for tag in event.tags():
if tag.as_vec()[0] == 'i':
input_type = tag.as_vec()[2]
elif tag.as_vec()[0] == 'param':
param = tag.as_vec()[1]
if param == "max_results": # check for param type
max_results = int(tag.as_vec()[2])
options = {
"max_results": max_results,
}
request_form['options'] = json.dumps(options)
return request_form
@ -69,7 +74,7 @@ class TrendingNotesNostrBand(DVMTaskInterface):
if len(response_json["notes"]) > 0:
for note in response_json["notes"]:
i += 1
if i < 20:
if i < int(options["max_results"]):
e_tag = Tag.parse(["e", note["id"]])
#print(e_tag.as_vec())
result_list.append(e_tag.as_vec())

View File

@ -50,7 +50,7 @@ def playground():
"nostr-hotter-site", " ai ", "palestine", "https://boards.4chan", "https://techcrunch.com",
"https://screenrant.com"],
"db_name": "db/nostr_recent_notes.db",
"db_since": 10 * 60 * 60, # 10h since gmt
"db_since": 12 * 60 * 60, # 10h since gmt
"personalized": False}
image = "https://image.nostr.build/a816f3f5e98e91e8a47d50f4cd7a2c17545f556d9bb0a6086a659b9abdf7ab68.jpg"