35 lines
903 B
Python
35 lines
903 B
Python
|
from django.core.management.base import BaseCommand
|
||
|
|
||
|
from ...models import Coin
|
||
|
from ...synchronous import (
|
||
|
update_database,
|
||
|
update_dominance,
|
||
|
update_p2pool,
|
||
|
update_rank,
|
||
|
get_history_function,
|
||
|
)
|
||
|
from ...asynchronous import (
|
||
|
get_block_data,
|
||
|
get_coin_data,
|
||
|
get_coinmarketcap_data,
|
||
|
get_network_data,
|
||
|
get_p2pool_data,
|
||
|
get_social_data,
|
||
|
update_others_data,
|
||
|
update_xmr_data,
|
||
|
)
|
||
|
|
||
|
|
||
|
class Command(BaseCommand):
|
||
|
help = "Initializes the database with the latest data"
|
||
|
|
||
|
def handle(self, *args, **options):
|
||
|
Coin.objects.all().delete()
|
||
|
|
||
|
for coin in ["xmr", "btc", "dash", "zec", "grin"]:
|
||
|
try:
|
||
|
self.stdout.write(self.style.SUCCESS(f"Updating {coin} data"))
|
||
|
get_history_function(coin)
|
||
|
except Exception as e:
|
||
|
self.stdout.write(self.style.ERROR(f"Error with {coin}: {e}"))
|