socials fix

This commit is contained in:
anon 2022-09-23 22:24:06 -03:00
parent a9e8459641
commit d0864f815a
4 changed files with 19 additions and 51 deletions

View file

@ -165,7 +165,6 @@ async def get_social_data(session, symbol):
data = data_prep_comments(symbol, timestamp2, timestamp1, filters, limit)
social.commentsPerHour = len(data)/2
social.save()
print(str(social.name) + ' - ' + str(social.date) + ' - ' + str(social.subscriberCount) + ' - ' + str(social.commentsPerHour) + ' - ' + str(social.postsPerHour) )
return True
####################################################################################
@ -254,21 +253,21 @@ async def update_xmr_data(yesterday, coin):
stocktoflow = (100/inflation)**1.65
supply = coin.supply + revenue
print('Name: ' + name)
print('Date: ' + str(yesterday))
print('Success: ' + str(success))
print('Errors: ' + str(errors))
print('Blocksize: ' + str(blocksize))
print('Transactions: ' + str(txs))
print('Revenue: ' + str(revenue))
print('Fees: ' + str(fees))
print('Inflation: ' + str(inflation))
print('Hashrate: ' + str(hashrate))
print('Difficulty: ' + str(difficulty))
print('Stocktoflow: ' + str(stocktoflow))
print('Priceusd: ' + str(priceusd))
print('Pricebtc: ' + str(pricebtc))
print('Supply: ' + str(supply))
#print('Name: ' + name)
#print('Date: ' + str(yesterday))
#print('Success: ' + str(success))
#print('Errors: ' + str(errors))
#print('Blocksize: ' + str(blocksize))
#print('Transactions: ' + str(txs))
#print('Revenue: ' + str(revenue))
#print('Fees: ' + str(fees))
#print('Inflation: ' + str(inflation))
#print('Hashrate: ' + str(hashrate))
#print('Difficulty: ' + str(difficulty))
#print('Stocktoflow: ' + str(stocktoflow))
#print('Priceusd: ' + str(priceusd))
#print('Pricebtc: ' + str(pricebtc))
#print('Supply: ' + str(supply))
try:
coin = Coin()

View file

@ -125,10 +125,8 @@ def get_latest_price(symbol):
try:
response = session.get(url, params=parameters)
print(response)
data = json.loads(response.text)
print('getting latest data')
print(data)
try:
if data['data'][symbol.upper()]['cmc_rank']:
print('new data received')
@ -215,11 +213,10 @@ def update_rank(data=None):
# Load Reddit api to check if there are new followers
def check_new_social(symbol):
yesterday = datetime.datetime.strftime(date.today()-timedelta(1), '%Y-%m-%d')
yesterday = datetime.datetime.strftime(date.today()-timedelta(2), '%Y-%m-%d')
socials = Social.objects.filter(name=symbol).filter(date=yesterday)
if not(socials):
print('getting new data - ' + str(symbol))
request = 'https://www.reddit.com/r/'+ symbol +'/about.json'
response = requests.get(request, headers = {'User-agent': 'Checking new social data'})
data = json.loads(response.content)
@ -239,15 +236,14 @@ def check_new_social(symbol):
limit = 1000
filters = []
data = data_prep_posts(symbol, timestamp2, timestamp1, filters, limit)
print(len(data))
social.postsPerHour = len(data)/12
timestamp2 = int(timestamp1 - 3600)
limit = 1000
data = data_prep_comments(symbol, timestamp2, timestamp1, filters, limit)
print(len(data))
social.commentsPerHour = len(data)/1
social.save()
print('getting new data - ' + str(social.name) + ' - ' + str(social.date))
return True
# Update database DailyData with most recent coin data
@ -292,7 +288,6 @@ def update_database(date_from=None, date_to=None):
count_aux = 0
found = False
print(date_aux)
while count_aux < 100 and not(found):
try:
date_aux3 = date_aux - timedelta(count_aux)
@ -303,8 +298,6 @@ def update_database(date_from=None, date_to=None):
except:
found = False
count_aux += 1
print(date_aux3)
except:
return count

View file

@ -891,29 +891,6 @@ async def index(request):
if request.user.username != "Administrador" and request.user.username != "Morpheus":
update_visitors(True)
# coins = Coin.objects.filter(name='xmr').order_by('-date')
# for coin in coins:
# if '2022-09-17' == datetime.datetime.strftime(coin.date, '%Y-%m-%d'):
# coin.supply = 18175769
# coin.save()
# print('saved')
# if '2022-09-16' == datetime.datetime.strftime(coin.date, '%Y-%m-%d'):
# coin.supply = 18175284
# coin.save()
# print('saved')
# if '2022-09-15' == datetime.datetime.strftime(coin.date, '%Y-%m-%d'):
# coin.supply = 18174852
# coin.save()
# print('saved')
# coins_aux = Coin.objects.filter(name='xmr').filter(date=coin.date)
# count = 1
# for coin_aux in coins_aux:
# if count > 1:
# print('deleted one')
# print(coin_aux.date)
# coin_aux.delete()
# count += 1
coin = list(Coin.objects.order_by('-date'))[0]
if not(coin):
message = 'Website under maintenance. Check back in a few minutes'
@ -2209,7 +2186,6 @@ def bitcoin(request):
if request.user.username != "Administrador" and request.user.username != "Morpheus":
update_visitors(False)
dates = []
dates3 = []
dates4 = []

View file

@ -28,8 +28,8 @@ STATICFILES_DIRS = [
SECRET_KEY = 'dafsdasdfasfa7sdfs9d7das7f9as7df8ad43525fsffdssdg455$$###77saf9df79as79s'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
#DEBUG = False
#DEBUG = True
DEBUG = False
ALLOWED_HOSTS = ['80.78.22.34', 'www.moneroj.net', 'localhost', '127.0.0.1', 'moneroj.net', 'moneroj5xq4ttg4ec7e5secqdyw5mcovzvfvlq6i7omv353i6mnexlqd.onion']