Skip to content

Commit

Permalink
added db cleanup script
Browse files Browse the repository at this point in the history
  • Loading branch information
DamourYouKnow committed Sep 11, 2017
1 parent 5cd3732 commit 0165e4d
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions scripts/database_cleanup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from pymongo import MongoClient

client = MongoClient('localhost', 27017)
db = client['haha-no-ur']
col = db['users']

user_ids = col.find().distinct('_id')
total = len(user_ids)
i = 1

for user_id in user_ids:
user = col.find_one({'_id': user_id})
album = user['album']
for card in album:
card.pop('rarity', None)
card.pop('attribute', None)
card.pop('release_date', None)
card.pop('round_card_image', None)
card.pop('round_card_idolized_image', None)
card.pop('name', None)
card.pop('year', None)
card.pop('main_unit', None)
card.pop('sub_unit', None)

col.update({'_id': user_id}, {'$set': {'album': album}})
print(str(i) + '/' + str(total))
i += 1

print('done')

0 comments on commit 0165e4d

Please sign in to comment.