Skip to content

Commit

Permalink
bugfix related to generic dvms
Browse files Browse the repository at this point in the history
  • Loading branch information
believethehype committed Sep 3, 2024
1 parent 323b900 commit f92fbd0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion nostr_dvm/dvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ async def handle_nip90_job_event(nip90_event):
self.dvm_config)

for dvm in self.dvm_config.SUPPORTED_DVMS:
if dvm.TASK == task or dvm.TASK == "generic" and dvm.FIX_COST == 0 and dvm.PER_UNIT_COST == 0 and dvm_config.NIP88 is None:
if (dvm.TASK == task or dvm.TASK == "generic") and dvm.FIX_COST == 0 and dvm.PER_UNIT_COST == 0 and dvm_config.NIP88 is None:
task_is_free = True

cashu_redeemed = False
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages

VERSION = '0.8.14'
VERSION = '0.8.15'
DESCRIPTION = 'A framework to build and run Nostr NIP90 Data Vending Machines'
LONG_DESCRIPTION = ('A framework to build and run Nostr NIP90 Data Vending Machines. See the github repository for more information')

Expand Down
24 changes: 12 additions & 12 deletions tests/generic_dvm_autotopic_feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def playground(announce=False):
dvm_config = build_default_config(identifier)
dvm_config.KIND = Kind(kind) # Manually set the Kind Number (see data-vending-machines.org)
dvm_config.CUSTOM_PROCESSING_MESSAGE = "Creating a personalized feed based on the topics you write about. This might take a moment."

dvm_config.FIX_COST = 10

# Add NIP89
nip89info = {
Expand All @@ -64,7 +64,7 @@ def playground(announce=False):
nip89config.CONTENT = json.dumps(nip89info)

options = {
"input": "How do you call a noisy ostrich?",
"input": "",
}

dvm = GenericDVM(name=name, dvm_config=dvm_config, nip89config=nip89config,
Expand Down Expand Up @@ -138,16 +138,16 @@ async def process(request_form):
ns.finallist = {}

for event in events:
if all(ele in event.content().lower() for ele in []):
if any(ele in event.content().lower() for ele in result):
if not any(ele in event.content().lower() for ele in []):
filt = Filter().kinds(
[definitions.EventDefinitions.KIND_ZAP, definitions.EventDefinitions.KIND_REACTION,
definitions.EventDefinitions.KIND_REPOST,
definitions.EventDefinitions.KIND_NOTE]).event(event.id()).since(since)
reactions = await database.query([filt])
if len(reactions) >= 1:
ns.finallist[event.id().to_hex()] = len(reactions)
#if all(ele in event.content().lower() for ele in []):
if any(ele in event.content().lower() for ele in result):
#if not any(ele in event.content().lower() for ele in []):
filt = Filter().kinds(
[definitions.EventDefinitions.KIND_ZAP, definitions.EventDefinitions.KIND_REACTION,
definitions.EventDefinitions.KIND_REPOST,
definitions.EventDefinitions.KIND_NOTE]).event(event.id()).since(since)
reactions = await database.query([filt])
if len(reactions) >= 1:
ns.finallist[event.id().to_hex()] = len(reactions)

result_list = []
finallist_sorted = sorted(ns.finallist.items(), key=lambda x: x[1], reverse=True)[:int(200)]
Expand Down

0 comments on commit f92fbd0

Please sign in to comment.