From d4f6286980e43eb2479d6c6d919b7fd69c7a6104 Mon Sep 17 00:00:00 2001 From: tecnovert Date: Wed, 19 Jul 2023 20:52:03 +0200 Subject: [PATCH] ui: Add new count of active received bids. --- basicswap/basicswap.py | 11 +++++++---- basicswap/templates/header.html | 4 ++-- basicswap/templates/offer.html | 2 +- basicswap/ui/page_offers.py | 3 ++- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py index 3bee460..32ce8e9 100644 --- a/basicswap/basicswap.py +++ b/basicswap/basicswap.py @@ -3585,7 +3585,7 @@ class BasicSwap(BaseApp): if was_received: delay = random.randrange(self.min_delay_event, self.max_delay_event) - self.log.info('Releasing xmr script coin lock tx for bid %s in %d seconds', bid_id.hex(), delay) + self.log.info('Releasing ads script coin lock tx for bid %s in %d seconds', bid_id.hex(), delay) self.createActionInSession(delay, ActionTypes.SEND_XMR_LOCK_RELEASE, bid_id, session) if bid_changed: @@ -6240,18 +6240,20 @@ class BasicSwap(BaseApp): now: int = self.getTime() q_str = '''SELECT COUNT(CASE WHEN b.was_sent THEN 1 ELSE NULL END) AS count_sent, - COUNT(CASE WHEN b.was_sent AND s.swap_ended = 0 AND b.expire_at > {} AND o.expire_at > {} THEN 1 ELSE NULL END) AS count_sent_active, + COUNT(CASE WHEN b.was_sent AND (s.in_progress OR (s.swap_ended = 0 AND b.expire_at > {} AND o.expire_at > {})) THEN 1 ELSE NULL END) AS count_sent_active, COUNT(CASE WHEN b.was_received THEN 1 ELSE NULL END) AS count_received, - COUNT(CASE WHEN b.was_received AND b.state = {} AND b.expire_at > {} AND o.expire_at > {} THEN 1 ELSE NULL END) AS count_available + COUNT(CASE WHEN b.was_received AND b.state = {} AND b.expire_at > {} AND o.expire_at > {} THEN 1 ELSE NULL END) AS count_available, + COUNT(CASE WHEN b.was_received AND (s.in_progress OR (s.swap_ended = 0 AND b.expire_at > {} AND o.expire_at > {})) THEN 1 ELSE NULL END) AS count_recv_active FROM bids b JOIN offers o ON b.offer_id = o.offer_id JOIN bidstates s ON b.state = s.state_id - WHERE b.active_ind = 1'''.format(now, now, BidStates.BID_RECEIVED, now, now) + WHERE b.active_ind = 1'''.format(now, now, BidStates.BID_RECEIVED, now, now, now, now) q = self.engine.execute(q_str).first() bids_sent = q[0] bids_sent_active = q[1] bids_received = q[2] bids_available = q[3] + bids_recv_active = q[4] q_str = '''SELECT COUNT(CASE WHEN expire_at > {} THEN 1 ELSE NULL END) AS count_active, @@ -6272,6 +6274,7 @@ class BasicSwap(BaseApp): 'num_recv_bids': bids_received, 'num_sent_bids': bids_sent, 'num_sent_active_bids': bids_sent_active, + 'num_recv_active_bids': bids_recv_active, 'num_available_bids': bids_available, 'num_watched_outputs': num_watched_outputs, } diff --git a/basicswap/templates/header.html b/basicswap/templates/header.html index 8122882..3cea536 100644 --- a/basicswap/templates/header.html +++ b/basicswap/templates/header.html @@ -482,7 +482,7 @@ - Bids Received {{ summary.num_available_bids }} + Bids Received {{ summary.num_recv_active_bids }}