mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-11-21 20:17:27 +01:00
Update advanced_search.py
This commit is contained in:
@@ -54,7 +54,7 @@ class AdvancedSearch(DVMTaskInterface):
|
|||||||
|
|
||||||
# default values
|
# default values
|
||||||
user = ""
|
user = ""
|
||||||
since_days = 1 #days ago
|
since_days = 800 #days ago
|
||||||
until_days = 0 #days ago
|
until_days = 0 #days ago
|
||||||
search = ""
|
search = ""
|
||||||
max_results = 20
|
max_results = 20
|
||||||
@@ -105,20 +105,18 @@ class AdvancedSearch(DVMTaskInterface):
|
|||||||
search_until = Timestamp.from_secs(dif)
|
search_until = Timestamp.from_secs(dif)
|
||||||
|
|
||||||
if options["user"] == "":
|
if options["user"] == "":
|
||||||
notes_filter = Filter().kind(1).search(options["search"]).since(search_since).until(search_until)
|
notes_filter = Filter().kind(1).search(options["search"]).since(search_since).until(search_until).limit(options["max_results"])
|
||||||
elif options["search"] == "":
|
elif options["search"] == "":
|
||||||
notes_filter = Filter().kind(1).author(PublicKey.from_hex(options["user"])).since(search_since).until(search_until)
|
notes_filter = Filter().kind(1).author(PublicKey.from_hex(options["user"])).since(search_since).until(search_until).limit(options["max_results"])
|
||||||
else:
|
else:
|
||||||
notes_filter = Filter().kind(1).author(PublicKey.from_hex(options["user"])).search(options["search"]).since(search_since).until(search_until)
|
notes_filter = Filter().kind(1).author(PublicKey.from_hex(options["user"])).search(options["search"]).since(search_since).until(search_until).limit(options["max_results"])
|
||||||
|
|
||||||
events = cli.get_events_of([notes_filter], timedelta(seconds=5))
|
events = cli.get_events_of([notes_filter], timedelta(seconds=5))
|
||||||
|
|
||||||
result_list = []
|
result_list = []
|
||||||
if len(events) > 0:
|
if len(events) > 0:
|
||||||
i = 0
|
|
||||||
for event in events:
|
for event in events:
|
||||||
if i < int(options["max_results"]):
|
|
||||||
i = i+1
|
|
||||||
e_tag = Tag.parse(["e", event.id().to_hex()])
|
e_tag = Tag.parse(["e", event.id().to_hex()])
|
||||||
print(e_tag.as_vec())
|
print(e_tag.as_vec())
|
||||||
result_list.append(e_tag.as_vec())
|
result_list.append(e_tag.as_vec())
|
||||||
|
|||||||
Reference in New Issue
Block a user