示例#1
0
    def execute(self):
        friend_list = []
        data = []

        with cache.get_pipeline('sharding', 'Slave') as pipeline:
            try:
                pipeline.hgetall(str(self.useridx) + ':FriendList')
                friends = pipeline.execute()

            except Exception as error:
                print(error)

            for friend in friends:
                for key, value in friend.items():
                    if int(value) == E_Friend_Request_State.accepted:
                        friend_list.append(int(key))

        with dbSession() as session:
            query = session.query(user_account). \
                filter(user_account.useridx != self.useridx). \
                filter(user_account.useridx.notin_(friend_list))[:50]. \
                all()

            for account in query:
                commander = dbCommander(account)
                data.append(commander.parsing())

        return data
示例#2
0
    def execute(self):
        with dbSession() as session:
            query = session.query(user_account). \
                filter(user_account.username == self.username, user_account.password == self.password)

            commander = dbCommander(query)
            values = commander.to_list()

            if len(values) == 0:
                return 0

            else:
                # update login date
                query[0].login_date = datetime.now()
                try:
                    session.commit()
                except Exception as error:
                    print(error)
                    return 0

                with cache.get_pipeline('LoginCount') as pipeline:
                    try:
                        pipeline.set('Login', 1)
                        pipeline.execute()

                    except Exception as error:
                        print(error)

                # Testing
                with cache.get_pipeline('ranking') as pipeline:
                    try:
                        pipeline.zincrby('ranking:arena', 1,
                                         str(self.username))
                        pipeline.execute()

                    except Exception as error:
                        print(error)

                return 1
示例#3
0
    def execute(self):
        with cache.get_pipeline('sharding') as pipeline:
            try:
                pipeline.hset(
                    str(self.useridx) + ':FriendList', self.targetidx,
                    self.state)
                pipeline.execute()

                pipeline.hset(
                    str(self.targetidx) + ':FriendList', self.useridx,
                    self.state)
                pipeline.execute()
            except Exception as error:
                print(error)
                return

        return
示例#4
0
    def execute(self):
        with cache.get_pipeline('sharding') as pipeline:
            pipeline.hget(str(self.targetidx) + ':FriendList', self.useridx)
            state = pipeline.execute()

            if state == None or state != E_Friend_Request_State.block:
                try:
                    pipeline.hset(
                        str(self.targetidx) + ':FriendList', self.useridx,
                        E_Friend_Request_State.pending)
                    pipeline.execute()
                    self.out_result = responseResultType.success

                except Exception as error:
                    print(error)

            else:
                self.out_result = responseResultType.pool_condition
                return

            return self.out_result