def add_deck_aliases(self, alias, new_aliases): canonical_name = utils.transform_deck_name(alias) new_canonical_aliases = list( {utils.transform_deck_name(name) for name in new_aliases}) return self.decks().update_one({"canonical_aliases": canonical_name}, { "$addToSet": { "aliases": { "$each": new_aliases }, "canonical_aliases": { "$each": new_canonical_aliases } } })
def add_deck(self, color, color_name, deck_name, aliases, commanders, link=""): decks = self.decks() document = { "name": deck_name, "color": utils.sort_color_str(color), "color_name": color_name, "link": link, "aliases": aliases, "canonical_aliases": [utils.transform_deck_name(alias) for alias in aliases], "commanders": commanders } if not decks.find_one({"name": deck_name}): decks.insert_one(document) return 1 else: decks.find_one_and_replace({"name": deck_name}, document) return 0
def add_deck_link(self, alias, link): canonical_name = utils.transform_deck_name(alias) return self.decks().update_one({"canonical_aliases": canonical_name}, {"$set": { "link": link }})
def find_deck(self, alias): if alias.lower() == "rogue": return {"name": "Rogue"} canonical_name = utils.transform_deck_name(alias) return self.decks().find_one({"canonical_aliases": canonical_name})