-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e635e94
commit 952fd20
Showing
7 changed files
with
107 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
COC_EMAIL = email | ||
COC_PASSWORD = password | ||
|
||
#mongo logins | ||
STATIC_MONGODB = mongo_db_connection_string_#1 | ||
STATS_MONGODB = mongo_db_connection_string_#2 | ||
|
||
#link api | ||
LINK_API_USER = discord_links_user | ||
LINK_API_PW = dicord_links_pw | ||
|
||
BOT_TOKEN = bot_token | ||
|
||
SENTRY_DSN = sentry_stats_token | ||
|
||
REDIS_IP = 0.0.0.0 | ||
REDIS_PW = redis_db_pw | ||
|
||
BUNNY_ACCESS_KEY = bunny.net_access_token | ||
|
||
PORTAINER_API_TOKEN = portainer_api_token | ||
|
||
REDDIT_SECRET = reddit_user_secret | ||
REDDIT_PW = reddit_user_password | ||
|
||
OPENAI_API_KEY = open.ai_api_token | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from classes.bot import CustomClient | ||
from pymongo import InsertOne | ||
|
||
|
||
async def migrate_clan_db_simple_schema(bot: CustomClient): | ||
our_clan_tags = await bot.clan_db.distinct("tag") | ||
our_clan_stats = await bot.clan_stats.find({"tag" : {"$in" : our_clan_tags}}, projection={"_id": 0}).to_list(length=None) | ||
print(len(our_clan_stats), "clans") | ||
|
||
player_tags = [] | ||
for clan_stats in our_clan_stats: #type: dict | ||
_ = clan_stats.pop("tag") | ||
for season, player_info in clan_stats.items(): | ||
player_tags += list(player_info.keys()) | ||
|
||
player_tags = list(set(player_tags)) | ||
print(len(player_tags), "tags") | ||
players = await bot.get_players(tags=player_tags, custom=False) | ||
players_map = {p.tag : p for p in players} | ||
|
||
bulk_insert = [] | ||
for clan_stats in our_clan_stats: #type: dict | ||
clan_tag = clan_stats.pop("tag") | ||
for season, player_info in clan_stats.items(): | ||
season_data = {"tag": clan_tag, "season" : season, "members" : []} | ||
member_data = [] | ||
for tag, data in player_info.items(): | ||
api_player = players_map.get(tag) | ||
if api_player is None: | ||
continue | ||
member_data.append( | ||
{ | ||
"name" : api_player.name, | ||
"tag" : api_player.tag, | ||
"townhall" : api_player.town_hall, | ||
"donated" : data.get("donated", 0), | ||
"received": data.get("received", 0), | ||
"activity" : data.get("activity", 0), | ||
"gold_looted" : data.get("gold_looted", 0), | ||
"elixir_looted" : data.get("elixir_looted", 0), | ||
"dark_elixir_looted" : data.get("dark_elixir_looted", 0), | ||
"attack_wins" : data.get("attack_wins", 0), | ||
"clan_games" : data.get("clan_games", 0), | ||
"trophies" : data.get("trophies", 0) | ||
} | ||
) | ||
season_data["members"] = member_data | ||
bulk_insert.append(InsertOne(season_data)) | ||
|
||
print(len(bulk_insert), "documents") | ||
await bot.new_looper.get_collection("new_clan_stats").bulk_write(bulk_insert) | ||
print("done") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
STATS_MONGODB = connection_string | ||
|
||
STATIC_MONGODB = connection_string | ||
|
||
COC_PASSWORD = pw | ||
|
||
REDIS_PW = pw | ||
|
||
REDIS_IP = 0.0.0.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
SECONDARY_LOOP_CHANGE = 15 | ||
TERTIARY_LOOP_CHANGE = 150 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.