Skip to content

Commit fa80b68

Browse files
committed
Finish giantbomb -> dekudeals migration
1 parent 93b070d commit fa80b68

File tree

3 files changed

+1
-78
lines changed

3 files changed

+1
-78
lines changed

giantbomb_names.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

modules/games.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
mclient = pymongo.MongoClient(config.mongoURI)
1717

18-
AUTO_SYNC = False
18+
AUTO_SYNC = True
1919
SEARCH_RATIO_THRESHOLD = 50
2020
DEKU_UTM = "utm_campaign=rnintendoswitch&utm_medium=social&utm_source=discord"
2121

modules/social.py

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,82 +1544,6 @@ async def _profile_revoke(
15441544
content=f'{config.greenTick} {item.title()} `{name}` revoked from {len(users) - failCount}/{len(users)} member(s).'
15451545
)
15461546

1547-
@commands.group(name='migratefavgames', invoke_without_command=True)
1548-
async def _migratefavgames(self, ctx):
1549-
if ctx.author.id not in [
1550-
125233822760566784, # MattBSG
1551-
123879073972748290, # Lyrus
1552-
]:
1553-
return await ctx.reply('no permission')
1554-
new_id_cache = dict()
1555-
1556-
with open('giantbomb_names.json') as f:
1557-
game_lookup = json.load(f)
1558-
1559-
db = mclient.bowser.users
1560-
1561-
query = {"favgames": {'$exists': True, '$not': {'$size': 0}}}
1562-
count = db.count_documents(query)
1563-
users = db.find(query)
1564-
1565-
message = await ctx.reply(f'Migrating... 0/{count} (0%)')
1566-
1567-
for j, user in enumerate(users):
1568-
new_games = user['favgames']
1569-
1570-
for i, game in enumerate(user['favgames']):
1571-
# Not a GiantBomb id
1572-
if not game.startswith("3030-"):
1573-
new_games[i] = game
1574-
continue
1575-
1576-
# Already cached
1577-
if game in new_id_cache:
1578-
new_games[i] = new_id_cache[game]
1579-
continue
1580-
1581-
# Get name from GiantBomb archive and search
1582-
1583-
# giantbomb id unknown
1584-
if game not in game_lookup:
1585-
new_games[i] = game # keep the giantbomb id
1586-
new_id_cache[game] = game
1587-
continue
1588-
1589-
names = game_lookup[game]
1590-
1591-
score = 0
1592-
deku_id = None
1593-
new_name = None
1594-
for name in names:
1595-
search = self.Games.search(name)
1596-
1597-
if search and (search['score'] > score):
1598-
score = search['score']
1599-
deku_id = search['deku_id']
1600-
new_name = search['name']
1601-
1602-
if not deku_id:
1603-
new_games[i] = game # keep the giantbomb id
1604-
new_id_cache[game] = game
1605-
continue
1606-
1607-
logging.info(f"favgames migration: {names[0]} -> {new_name}")
1608-
new_games[i] = deku_id
1609-
new_id_cache[game] = deku_id
1610-
1611-
# update user record
1612-
db.update_one({'_id': user['_id']}, {'$set': {'favgames': new_games}}, upsert=True)
1613-
1614-
# update the progress message
1615-
interval = (count // 100) + 1
1616-
if ((j + 1) % interval) == 0:
1617-
percent_complete = ((j + 1) / count) * 100
1618-
await message.edit(content=f'Migrating... {j+1}/{count} ({percent_complete:.0f}%)')
1619-
1620-
await message.edit(content=f'Migrating... {count}/{count} (100%)')
1621-
await message.reply('Done!')
1622-
16231547
@commands.Cog.listener()
16241548
async def on_message(self, message):
16251549
if (not message.guild) or message.author.bot:

0 commit comments

Comments
 (0)