Exemplo n.º 1
0
    def tr_create(groupid, eventmaster, eventrankmaster, uidlist, tomorrow):
        """書き込み.
        """
        group = None
        if groupid:
            group = BattleEventGroup.getByKeyForUpdate(groupid)

        model_mgr = ModelRequestMgr()
        rankrecordlist = BattleEventRank.fetchByKeyForUpdate(
            [BattleEventRank.makeID(uid, eventmaster.id) for uid in uidlist])
        playerexp_dict = BackendApi.get_model_dict(model_mgr, PlayerExp,
                                                   uidlist)
        for rankrecord in rankrecordlist:
            if rankrecord.groups and BattleEventGroup.getByKey(
                    rankrecord.groups):
                # すでに参加している.
                continue
            if group and group.fixed:
                group = None

            playerexp = playerexp_dict.get(rankrecord.uid)
            level = playerexp.level if playerexp else 1
            group = BackendApi.tr_battleevent_regist_group(
                model_mgr, eventrankmaster, rankrecord, False, group, level,
                tomorrow)
            print 'set group:%s => %s' % (rankrecord.uid, group.id)

        model_mgr.write_all()
        return model_mgr, group
Exemplo n.º 2
0
 def __getGroupRecord(self, groupidlist):
     grouplist = BattleEventGroup.getByKey(groupidlist,
                                           using=settings.DB_READONLY)
     grouploglist = BattleEventGroupLog.getByKey(groupidlist,
                                                 using=settings.DB_READONLY)
     modellist = list(grouplist) + list(grouploglist)
     modellist.sort(key=lambda x: x.cdate, reverse=True)
     return modellist