Example #1
0
    def make_refresh(self,
                     tp,
                     set_timestamp=False,
                     save=True,
                     send_notify=True):
        club_level = get_club_property(self.server_id, self.char_id, 'level')
        goods = ConfigStore.refresh(tp, club_level)

        try:
            tp_doc = self.doc['tp'][str(tp)]
        except KeyError:
            tp_doc = MongoStore.document_tp()

        if set_timestamp:
            tp_doc['refresh_at'] = arrow.utcnow().timestamp

        tp_doc['goods'] = {
            str(_id): {
                'index': _index,
                'times': 0
            }
            for _id, _index in goods
        }
        self.doc['tp'][str(tp)] = tp_doc

        if save:
            MongoStore.db(self.server_id).update_one(
                {'_id': self.char_id}, {'$set': {
                    'tp.{0}'.format(tp): tp_doc
                }})

        if send_notify:
            self.send_notify(tp=tp)
Example #2
0
    def make_refresh(self, tp, set_timestamp=False, save=True, send_notify=True):
        club_level = get_club_property(self.server_id, self.char_id, 'level')
        goods = ConfigStore.refresh(tp, club_level)

        try:
            tp_doc = self.doc['tp'][str(tp)]
        except KeyError:
            tp_doc = MongoStore.document_tp()

        if set_timestamp:
            tp_doc['refresh_at'] = arrow.utcnow().timestamp

        tp_doc['goods'] = {str(_id): {'index': _index, 'times': 0} for _id, _index in goods}
        self.doc['tp'][str(tp)] = tp_doc

        if save:
            MongoStore.db(self.server_id).update_one(
                {'_id': self.char_id},
                {'$set': {
                    'tp.{0}'.format(tp): tp_doc
                }}
            )

        if send_notify:
            self.send_notify(tp=tp)