fix: Auction sorting on older HSD versions
All checks were successful
Build Docker / Build Image (push) Successful in 38s

This commit is contained in:
Nathan Woodburn 2025-01-31 17:38:02 +11:00
parent a1d1a6337e
commit 3844acdaf8
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
4 changed files with 16 additions and 14 deletions

Binary file not shown.

21
main.py
View File

@ -297,6 +297,8 @@ def auctions():
if direction == "":
reverse = True
sortbyDomain = False
if sort == "price":
# Sort by price
bids = sorted(bids, key=lambda k: k['value'],reverse=reverse)
@ -306,26 +308,25 @@ def auctions():
sort_state = direction
sort_state_next = reverseDirection(direction)
domains = sorted(domains, key=lambda k: k['state'],reverse=reverse)
sortbyDomain = True
elif sort == "time":
sort_time = direction
sort_time_next = reverseDirection(direction)
bids = sorted(bids, key=lambda k: k['height'],reverse=reverse)
# If older HSD version sort by domain height
if bids[0]['height'] == 0:
domains = sorted(domains, key=lambda k: k['height'],reverse=reverse)
sortbyDomain = True
else:
bids = sorted(bids, key=lambda k: k['height'],reverse=reverse)
else:
# Sort by domain
bids = sorted(bids, key=lambda k: k['name'],reverse=reverse)
sort_domain = direction
sort_domain_next = reverseDirection(direction)
if sort == "state":
bidsHtml = render.bidDomains(bids,domains,True)
else:
bidsHtml = render.bidDomains(bids,domains)
bidsHtml = render.bidDomains(bids,domains,sortbyDomain)
plugins = ""
message = ''
if 'message' in request.args:
message = request.args.get("message")

View File

@ -183,9 +183,10 @@ def bids(bids,reveals):
return html
def bidDomains(bids,domains, sortState=False):
def bidDomains(bids,domains, sortbyDomains=False):
html = ''
if not sortState:
if not sortbyDomains:
for bid in bids:
for domain in domains:
if bid['name'] == domain['name']:
@ -201,7 +202,7 @@ def bidDomains(bids,domains, sortState=False):
html += f"<td><a class='text-decoration-none' style='color: var(--bs-table-color-state, var(--bs-table-color-type, var(--bs-table-color)));' href='/auction/{domain['name']}'>{domain['name']}</a></td>"
html += f"<td>{domain['state']}</td>"
html += f"<td>{bidDisplay}</td>"
html += f"<td>{bid['height']:,}</td>"
html += f"<td>{domain['height']:,}</td>"
html += "</tr>"
else:
for domain in domains:

View File

@ -155,7 +155,7 @@
<table class="table">
<thead>
<tr>
<th><a href="/auctions?direction={{sort_domain_next}}">Domain{{sort_domain}}</a></th>
<th><a href="/auctions?sort=domain&direction={{sort_domain_next}}">Domain{{sort_domain}}</a></th>
<th><a href="/auctions?sort=state&direction={{sort_state_next}}">State{{sort_state}}</a></th>
<th><a href="/auctions?sort=price&direction={{sort_price_next}}">Bid{{sort_price}}</a></th>
<th><a href="/auctions?sort=time&direction={{sort_time_next}}">Block{{sort_time}}</a></th>