1
This commit is contained in:
parent
2213cf56a3
commit
f119d401fc
@ -1,6 +1,7 @@
|
|||||||
import csv
|
import csv
|
||||||
import json
|
import json
|
||||||
import datetime
|
import datetime
|
||||||
|
import functools
|
||||||
|
|
||||||
# 1.NFT总量 (宝箱+赠送)
|
# 1.NFT总量 (宝箱+赠送)
|
||||||
# 2.NFT mint数量 (卖出的宝箱+赠送)
|
# 2.NFT mint数量 (卖出的宝箱+赠送)
|
||||||
@ -94,13 +95,45 @@ def statData():
|
|||||||
assert(len(boxUser) == stat['bindBox']['total'] - stat['bindBox']['open'])
|
assert(len(boxUser) == stat['bindBox']['total'] - stat['bindBox']['open'])
|
||||||
stat['bindBox']['merchant_hold'] = len(merchant_box)
|
stat['bindBox']['merchant_hold'] = len(merchant_box)
|
||||||
stat['bindBox']['user_hold'] = stat['bindBox']['total'] - stat['bindBox']['open'] - stat['bindBox']['merchant_hold']
|
stat['bindBox']['user_hold'] = stat['bindBox']['total'] - stat['bindBox']['open'] - stat['bindBox']['merchant_hold']
|
||||||
|
for key, value in boxUser.copy().items():
|
||||||
|
if value == MERCHANT_ADDRESS:
|
||||||
|
del boxUser[key]
|
||||||
|
assert(len(boxUser) == stat['bindBox']['user_hold'])
|
||||||
|
userHoldNums = {}
|
||||||
|
for key, value in boxUser.items():
|
||||||
|
userHoldNums[value] = 1
|
||||||
for row in nftTable:
|
for row in nftTable:
|
||||||
if row['owner_address'] != EMPTY_ADDRESS:
|
ownerAddress = row['owner_address'].lower()
|
||||||
|
if ownerAddress != EMPTY_ADDRESS and ownerAddress != '' and row['token_type'] != 4:
|
||||||
stat['nft_total'] += 1
|
stat['nft_total'] += 1
|
||||||
stat['nft_mint'] += 1
|
stat['nft_mint'] += 1
|
||||||
|
if ownerAddress not in userHoldNums:
|
||||||
|
userHoldNums[ownerAddress] = 1
|
||||||
|
else:
|
||||||
|
userHoldNums[ownerAddress] += 1
|
||||||
#end for
|
#end for
|
||||||
|
userHoldList = []
|
||||||
|
for key, value in userHoldNums.items():
|
||||||
|
if value > 1:
|
||||||
|
userHoldList.append(
|
||||||
|
{
|
||||||
|
'address': key,
|
||||||
|
'nftNum': value
|
||||||
|
}
|
||||||
|
)
|
||||||
|
#end for
|
||||||
|
def cmpFunc(a, b):
|
||||||
|
if a['nftNum'] > b['nftNum']:
|
||||||
|
return -1
|
||||||
|
elif a['nftNum'] < b['nftNum']:
|
||||||
|
return 1
|
||||||
|
else:
|
||||||
|
return 0
|
||||||
|
stat['nft_rank'] = sorted(userHoldList, key=functools.cmp_to_key(cmpFunc))
|
||||||
|
for i in range(len(stat['nft_rank'])):
|
||||||
|
stat['nft_rank'][i]['rank'] = i + 1
|
||||||
stat['nft_mint'] += stat['bindBox']['merchant_hold']
|
stat['nft_mint'] += stat['bindBox']['merchant_hold']
|
||||||
print(json.dumps(stat))
|
print(json.dumps(stat, indent=4))
|
||||||
|
|
||||||
def loadData():
|
def loadData():
|
||||||
def rowToObj(row, fields):
|
def rowToObj(row, fields):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user