Change 'today' stats for 'last 24h'

This commit is contained in:
Reckless_Satoshi 2022-03-13 05:00:21 -07:00
parent 806a56c7f9
commit feacb485fb
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
3 changed files with 16 additions and 14 deletions

View File

@ -653,13 +653,15 @@ class InfoView(ListAPIView):
User.objects.filter(last_login__day=today.day)) User.objects.filter(last_login__day=today.day))
# Compute average premium and volume of today # Compute average premium and volume of today
queryset = MarketTick.objects.filter(timestamp__day=today.day) last_day = timezone.now() - timedelta(days=1)
queryset = MarketTick.objects.filter(timestamp__gt=last_day)
if not len(queryset) == 0: if not len(queryset) == 0:
avg_premium, total_volume = compute_avg_premium(queryset) avg_premium, total_volume = compute_avg_premium(queryset)
# If no contracts, fallback to lifetime avg premium # If no contracts, fallback to lifetime avg premium
else: else:
queryset = MarketTick.objects.all() queryset = MarketTick.objects.all()
avg_premium, total_volume = compute_avg_premium(queryset) avg_premium, _ = compute_avg_premium(queryset)
total_volume = 0
queryset = MarketTick.objects.all() queryset = MarketTick.objects.all()
if not len(queryset) == 0: if not len(queryset) == 0:
@ -670,8 +672,8 @@ class InfoView(ListAPIView):
else: else:
lifetime_volume = 0 lifetime_volume = 0
context["today_avg_nonkyc_btc_premium"] = round(avg_premium, 2) context["last_day_nonkyc_btc_premium"] = round(avg_premium, 2)
context["today_volume"] = total_volume *100000000 context["last_day_volume"] = total_volume *100000000
context["lifetime_volume"] = lifetime_volume context["lifetime_volume"] = lifetime_volume
context["lnd_version"] = get_lnd_version() context["lnd_version"] = get_lnd_version()
context["robosats_running_commit_hash"] = get_commit_robosats() context["robosats_running_commit_hash"] = get_commit_robosats()

View File

@ -66,8 +66,8 @@ export default class BottomBar extends Component {
active_robots_today: 0, active_robots_today: 0,
maker_fee: 0, maker_fee: 0,
taker_fee: 0, taker_fee: 0,
today_avg_nonkyc_btc_premium: 0, last_day_nonkyc_btc_premium: 0,
today_volume: 0, last_day_volume: 0,
lifetime_volume: 0, lifetime_volume: 0,
robosats_running_commit_hash: '000000000000000', robosats_running_commit_hash: '000000000000000',
openProfile: false, openProfile: false,
@ -158,7 +158,7 @@ export default class BottomBar extends Component {
<Divider/> <Divider/>
<ListItem> <ListItem>
<ListItemIcon><EqualizerIcon/></ListItemIcon> <ListItemIcon><EqualizerIcon/></ListItemIcon>
<ListItemText primary={pn(this.state.today_volume)+" Sats"} secondary="Today contracted volume"/> <ListItemText primary={pn(this.state.last_day_volume)+" Sats"} secondary="24h contracted volume"/>
</ListItem> </ListItem>
<Divider/> <Divider/>
@ -498,8 +498,8 @@ bottomBarDesktop =()=>{
<ListItemText <ListItemText
primaryTypographyProps={{fontSize: '14px'}} primaryTypographyProps={{fontSize: '14px'}}
secondaryTypographyProps={{fontSize: '12px'}} secondaryTypographyProps={{fontSize: '12px'}}
primary={this.state.today_avg_nonkyc_btc_premium+"%"} primary={this.state.last_day_nonkyc_btc_premium+"%"}
secondary="Today Avg Premium" /> secondary="24h Avg Premium" />
</ListItem> </ListItem>
</Grid> </Grid>
@ -627,8 +627,8 @@ bottomBarDesktop =()=>{
<ListItemText <ListItemText
primaryTypographyProps={{fontSize: '14px'}} primaryTypographyProps={{fontSize: '14px'}}
secondaryTypographyProps={{fontSize: '12px'}} secondaryTypographyProps={{fontSize: '12px'}}
primary={this.state.today_avg_nonkyc_btc_premium+"%"} primary={this.state.last_day_nonkyc_btc_premium+"%"}
secondary="Today non-KYC average premium" /> secondary="24h non-KYC average premium" />
</ListItem> </ListItem>
<Divider/> <Divider/>
@ -724,9 +724,9 @@ bottomBarPhone =()=>{
</Grid> </Grid>
<Grid item xs={1.8} align="center"> <Grid item xs={1.8} align="center">
<Tooltip enterTouchDelay="300" title="Today non-KYC bitcoin premium"> <Tooltip enterTouchDelay="300" title="24h non-KYC bitcoin premium">
<IconButton onClick={this.handleClickOpenExchangeSummary} > <IconButton onClick={this.handleClickOpenExchangeSummary} >
<Badge badgeContent={this.state.today_avg_nonkyc_btc_premium+"%"} color="action"> <Badge badgeContent={this.state.last_day_nonkyc_btc_premium+"%"} color="action">
<PriceChangeIcon /> <PriceChangeIcon />
</Badge> </Badge>
</IconButton> </IconButton>

File diff suppressed because one or more lines are too long