def loadDB(self): print("Initializing GamesLoader") print("Checking Game Document...") if Game.objects.first(): print("Found existing Game objects, deleting...") Game.objects().delete() file_data = self.preProcessGamesData() print("Current games folder data size:") print(len(file_data)) #To do: remove truncation for gameMap in file_data[0:3]: game = Game(event=gameMap['Event'], site=gameMap['Site'], date=gameMap['Date'], stage=gameMap['Round'], white=gameMap['White'], black=gameMap['Black'], result=gameMap['Result'], black_elo=gameMap['BlackElo'], blackfide_id=gameMap['BlackFideId'], black_title=gameMap['BlackTitle'], eco=gameMap['ECO'], event_date=gameMap['EventDate'], opening=gameMap['Opening'], variation=gameMap['Variation'], white_elo=gameMap['WhiteElo'], whitefide_id=gameMap['WhiteFideId'], white_title=gameMap['WhiteTitle'], moves=gameMap['Moves']) game.save() print("Database loaded successfully!")
def get(self): games = Game.objects().to_json() return Response(games, mimetype="application/json", status=200)
def get(self, name): games = Game.objects(opening=name).to_json() print(games) return Response(games, mimetype="application/json", status=200)