Merge pull request #1 from blockworks-foundation/ckamm/fix-ranked-pnl-market-index

ranked-pnl: Fix off-by-one in index
This commit is contained in:
Nicholas Clarke 2022-01-06 23:51:58 -08:00 committed by GitHub
commit c5c701d853
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -866,6 +866,8 @@ def ranked_pnl():
market_index = int(market_index)
except TypeError:
raise Exception('market-index must be an int')
# Postgres indices are 1-based
postgres_market_index = market_index + 1
order = request.args.get('order')
if order not in ['ASC', 'DESC']:
@ -882,7 +884,7 @@ def ranked_pnl():
sql = "select * from accountsdb.pnl(%(market_index)s, %(order)s, %(limit)s)"
cur.execute(sql, {'market_index': market_index, 'order': order, 'limit': limit})
cur.execute(sql, {'market_index': postgres_market_index, 'order': order, 'limit': limit})
data = cur.fetchone()[0]
if data is None: