Add lifetime settled volume. Sort admin panel cronologically

This commit is contained in:
Reckless_Satoshi 2022-01-26 10:45:24 -08:00
parent 2263ec7153
commit 493684b8c9
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
4 changed files with 31 additions and 5 deletions

View File

@ -19,6 +19,7 @@ class EUserAdmin(UserAdmin):
inlines = [ProfileInline]
list_display = ('avatar_tag','id','username','last_login','date_joined','is_staff')
list_display_links = ('id','username')
ordering = ('-id',)
def avatar_tag(self, obj):
return obj.profile.avatar_tag()
@ -36,6 +37,7 @@ class LNPaymentAdmin(AdminChangeLinksMixin, admin.ModelAdmin):
list_display_links = ('hash','concept')
change_links = ('sender','receiver','order_made','order_taken','order_escrow','order_paid')
list_filter = ('type','concept','status')
ordering = ('-expires_at',)
@admin.register(Profile)
class UserProfileAdmin(AdminChangeLinksMixin, admin.ModelAdmin):
@ -49,9 +51,11 @@ class CurrencieAdmin(admin.ModelAdmin):
list_display = ('id','currency','exchange_rate','timestamp')
list_display_links = ('id','currency')
readonly_fields = ('currency','exchange_rate','timestamp')
ordering = ('id',)
@admin.register(MarketTick)
class MarketTickAdmin(admin.ModelAdmin):
list_display = ('timestamp','price','volume','premium','currency','fee')
readonly_fields = ('timestamp','price','volume','premium','currency','fee')
list_filter = ['currency']
ordering = ('-timestamp',)

View File

@ -492,8 +492,18 @@ class InfoView(ListAPIView):
avg_premium = 0
total_volume = 0
queryset = MarketTick.objects.all()
if not len(queryset) == 0:
volume_settled = []
for tick in queryset:
volume_settled.append(tick.volume)
lifetime_volume_settled = int(sum(volume_settled)*100000000)
else:
lifetime_volume_settled = 0
context['today_avg_nonkyc_btc_premium'] = round(avg_premium,2)
context['today_total_volume'] = total_volume
context['lifetime_satoshis_settled'] = lifetime_volume_settled
context['lnd_version'] = get_lnd_version()
context['robosats_running_commit_hash'] = get_commit_robosats()
context['fee'] = FEE

View File

@ -15,6 +15,11 @@ import EqualizerIcon from '@mui/icons-material/Equalizer';
import SendIcon from '@mui/icons-material/Send';
import PublicIcon from '@mui/icons-material/Public';
// pretty numbers
function pn(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
export default class BottomBar extends Component {
constructor(props) {
super(props);
@ -27,6 +32,7 @@ export default class BottomBar extends Component {
fee: 0,
today_avg_nonkyc_btc_premium: 0,
today_total_volume: 0,
lifetime_satoshis_settled: 0,
};
this.getInfo();
}
@ -61,7 +67,7 @@ export default class BottomBar extends Component {
>
<DialogContent>
<Typography component="h5" variant="h5">Stats For Nerds</Typography>
<List>
<List dense>
<Divider/>
<ListItem>
<ListItemIcon><BoltIcon/></ListItemIcon>
@ -84,6 +90,12 @@ export default class BottomBar extends Component {
<ListItemText primary={this.state.today_total_volume+" BTC"} secondary="Today traded volume"/>
</ListItem>
<Divider/>
<ListItem>
<ListItemIcon><EqualizerIcon/></ListItemIcon>
<ListItemText primary={pn(this.state.lifetime_satoshis_settled)+" Sats"} secondary="Lifetime settled volume"/>
</ListItem>
<Divider/>
<ListItem>
<ListItemIcon><PublicIcon/></ListItemIcon>

View File

@ -147,11 +147,11 @@ export default class OrderPage extends Component {
countdownPenaltyRenderer = ({ minutes, seconds, completed }) => {
if (completed) {
// Render a completed state
return (<span> nothing. Good to go!</span>);
return (<span> Penalty lifted, good to go!</span>);
} else {
return (
<span>{zeroPad(minutes)}m {zeroPad(seconds)}s </span>
<span> Wait {zeroPad(minutes)}m {zeroPad(seconds)}s </span>
);
}
};
@ -445,7 +445,7 @@ export default class OrderPage extends Component {
<Divider />
<Grid item xs={12} align="center">
<Alert severity="warning" sx={{maxWidth:360}}>
You cannot take an order yet! Wait <Countdown date={new Date(this.state.penalty)} renderer={this.countdownPenaltyRenderer} />
You cannot take an order yet! <Countdown date={new Date(this.state.penalty)} renderer={this.countdownPenaltyRenderer} />
</Alert>
</Grid>
</>