Skip to content

Commit

Permalink
fix net counter
Browse files Browse the repository at this point in the history
  • Loading branch information
ppigazzini committed Feb 28, 2024
1 parent 1bc8b1a commit e241033
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 3 additions & 0 deletions server/fishtest/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,9 @@ def download_nn(self):
nn = self.request.rundb.get_nn(self.request.matchdict["id"])
if nn is None:
raise exception_response(404)
else:
self.request.rundb.increment_nn_downloads(self.request.matchdict["id"])

return HTTPFound(
"https://data.stockfishchess.org/nn/" + self.request.matchdict["id"]
)
Expand Down
9 changes: 4 additions & 5 deletions server/fishtest/rundb.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,11 +477,10 @@ def update_nn(self, net):
self.nndb.update_one({"name": net["name"]}, {"$set": net})

def get_nn(self, name):
nn = self.nndb.find_one({"name": name}, {"nn": 0})
if nn:
self.nndb.update_one({"name": name}, {"$inc": {"downloads": 1}})
return nn
return None
return self.nndb.find_one({"name": name}, {"nn": 0})

def increment_nn_downloads(self, name):
self.nndb.update_one({"name": name}, {"$inc": {"downloads": 1}})

def get_nns(
self, user_id, user="", network_name="", master_only=False, limit=0, skip=0
Expand Down

0 comments on commit e241033

Please sign in to comment.