mirror of
https://github.com/more-tech4-magnum-opus/backend.git
synced 2024-11-24 20:33:42 +03:00
fixed end season, moved secrets
This commit is contained in:
parent
ae7cfe5166
commit
8beee17e31
|
@ -1,3 +1,4 @@
|
|||
DJANGO_DEBUG=yes
|
||||
DATABASE_URL=postgres://postgres:debug@127.0.0.1:5432/moretech
|
||||
CELERY_BROKER_URL=redis://localhost:6379/0
|
||||
MAIN_WALLET=46d3684932f300a7fcdc8cc73cfa3057b5f61695c6e0299a5cb551f645e4cb9c
|
|
@ -216,3 +216,7 @@ REST_FRAMEWORK = {
|
|||
|
||||
# django-cors-headers
|
||||
CORS_ALLOW_ALL_ORIGINS = True
|
||||
|
||||
|
||||
MAIN_WALLET = env("MAIN_WALLET")
|
||||
TELEGRAM_API = "https://tender-badgers-eat-178-71-165-37.loca.lt"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from rest_framework import serializers
|
||||
from ..service import create_season
|
||||
from ..services import create_season
|
||||
from users.models import User
|
||||
from users.models import User, Department, Stream, Command
|
||||
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
from random import shuffle
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
from .models import Clan, User
|
||||
from utils.blockchain import transfer_rubbles
|
||||
import requests as r
|
||||
|
@ -10,28 +13,24 @@ def end_season():
|
|||
mx_clan = None
|
||||
for clan in Clan.objects.all():
|
||||
if sum(map(lambda user: user.respect, clan.user_set.all())) > mx_value:
|
||||
mx_value = sum(map(lambda user: user.respect, clan.user_set))
|
||||
mx_value = sum(map(lambda user: user.respect, clan.user_set.all()))
|
||||
mx_clan = clan
|
||||
for user in mx_clan.user_set.all():
|
||||
transfer_rubbles("46d3684932f300a7fcdc8cc73cfa3057b5f61695c6e0299a5cb551f645e4cb9c", user.wallet_public_key, 100)
|
||||
transfer_rubbles(
|
||||
settings.MAIN_WALLET,
|
||||
user.wallet_public_key,
|
||||
100,
|
||||
)
|
||||
Clan.objects.all().delete()
|
||||
|
||||
|
||||
def create_chat(clan: Clan):
|
||||
user_list = list(
|
||||
map(lambda user: user.telegram, clan.user_set.all())
|
||||
)
|
||||
user_list = list(map(lambda user: user.telegram, clan.user_set.all()))
|
||||
if len(user_list):
|
||||
r.post('https://tender-badgers-eat-178-71-165-37.loca.lt/create-chat', data=json.dumps(
|
||||
{
|
||||
'chat_name': clan.name,
|
||||
'users': user_list
|
||||
}
|
||||
),
|
||||
headers={
|
||||
'accept': 'application/json',
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
r.post(
|
||||
f"{settings.TELEGRAM_API}/create-chat",
|
||||
data=json.dumps({"chat_name": clan.name, "users": user_list}),
|
||||
headers={"accept": "application/json", "Content-Type": "application/json"},
|
||||
)
|
||||
|
||||
|
||||
|
@ -43,8 +42,7 @@ def create_season():
|
|||
shuffle(users)
|
||||
clan = None
|
||||
for index, user in enumerate(users):
|
||||
print(index, len(users))
|
||||
if (index % 10 == 0) or (index == len(users)-1):
|
||||
if (index % 10 == 0) or (index == len(users) - 1):
|
||||
if clan is not None:
|
||||
create_chat(clan)
|
||||
clan = Clan.objects.create()
|
||||
|
@ -52,5 +50,3 @@ def create_season():
|
|||
user.save()
|
||||
if len(users) % 10 != 0:
|
||||
create_chat(clan)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user