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

View file

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

View file

@ -891,29 +891,6 @@ async def index(request):
if request.user.username != "Administrador" and request.user.username != "Morpheus": if request.user.username != "Administrador" and request.user.username != "Morpheus":
update_visitors(True) 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] coin = list(Coin.objects.order_by('-date'))[0]
if not(coin): if not(coin):
message = 'Website under maintenance. Check back in a few minutes' 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": if request.user.username != "Administrador" and request.user.username != "Morpheus":
update_visitors(False) update_visitors(False)
dates = [] dates = []
dates3 = [] dates3 = []
dates4 = [] dates4 = []

View file

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