def test_mongostore_from_collection(mongostore, db_json): ms = MongoStore.from_db_file(db_json) ms.connect() other_ms = MongoStore.from_collection(ms._collection) assert ms._collection.full_name == other_ms._collection.full_name assert ms.database == other_ms.database
def __init__(self, pj_store, lpad, incremental=True, query=None, base_priority=2500, site_penalty=10, vote_weight=10, **kwargs): """ Takes a propjockey collection and sets the priority of a fireworks in a fireworks collection from a LaunchPad Args: pj_store (Store): store corresponding to propjockey collection lpad (LaunchPad): fireworks launchpad query (dict): query to filter the propjockey store base_priority (int): base priority to assign to fireworks site_penalty (int): per-site penalty to priority vote_weight (int): priority boost per vote **kwargs (kwargs): kwargs for builder """ self.pj_store = pj_store if isinstance(lpad, dict): self.lpad = LaunchPad.from_dict(lpad) else: self.lpad = lpad self.fws_store = MongoStore.from_collection(self.lpad.fireworks) self.fws_store.lu_field = "_pj_lu" self.incremental = incremental self.start_date = datetime.utcnow() self.query = query or {} self.base_priority = base_priority self.site_penalty = site_penalty self.vote_weight = vote_weight super().__init__(sources=[self.pj_store], targets=[self.fws_store], **kwargs)
def _get_store_by_name(self, name): return MongoStore.from_collection(self.collection.database[name])
def last_updated(self): lus = [] for cname in self.collection_names: lu = MongoStore.from_collection(self.collection.database[cname], lu_field=self.lu_field).last_updated lus.append(lu) return max(lus)