Exemplo n.º 1
0
 def get(self):
     new_running_list = copy.deepcopy(running_list)
     for item in new_running_list:
         item['_oid'] = repr(item['_oid'])
     running_list_size = len(running_list)
     running_list_content = new_running_list
     timer_list_size = len(timer_list)
     
     auto_id_running = running_t.get_auto_incre()
     running_length = running_t.count()
     
     auto_id_waitting = waitting_t.get_auto_incre()
     waitting_length = waitting_t.count()
     
     # 获取所有用户排队的位置
     user_waitting = list()
     result = waitting_t.query()
     
     auto_id = waitting_t.get_auto_incre() - 1
     waitting = waitting_t.count() - 1
     deleted = auto_id - waitting
     for line in result:
         if line.has_key("instance_data"):
             temp_dic = dict()
             temp_list = list()
             temp_dic[line['user_id']] = line['auto_id'] - deleted
             temp_list.append(temp_dic)
             user_waitting.append(temp_list)
     
     result = dict(
         running_list_size = running_list_size,
         running_list_content = running_list_content,
         timer_list_size = timer_list_size,
         
         auto_id_running = auto_id_running,
         running_length = running_length,
         
         auto_id_waitting = auto_id_waitting,
         waitting_length = waitting_length,
         
         user_waitting = user_waitting
     )
     
     self.write(result)
Exemplo n.º 2
0
    def get(self):
        '''
        根据用户id返回用户排队的序号
        找不到则返回-1
        '''
        return_list = list()
        user_id = self.get_argument("user_id")
        result = waitting_t.query(user_id=user_id)

        # 用户正在排队的位置 = 排队位置 - 被删除的
        # 被删除的 = 计数器 - 正在等待的
        auto_id = waitting_t.get_auto_incre() - 1
        waitting = waitting_t.count() - 1
        deleted = auto_id - waitting
        for line in result:
            temp = dict()
            #temp['request_id'] = line['_id']
            temp['position'] = line['auto_id'] - deleted
            return_list.append(temp)
        if not return_list:
            self.write(dict(status=[]))
            return
        self.write(dict(status=return_list))
        return
Exemplo n.º 3
0
 def get(self):
     '''
     根据用户id返回用户排队的序号
     找不到则返回-1
     '''
     return_list = list()
     user_id = self.get_argument("user_id")
     result = waitting_t.query(user_id=user_id)
     
     # 用户正在排队的位置 = 排队位置 - 被删除的
     # 被删除的 = 计数器 - 正在等待的
     auto_id = waitting_t.get_auto_incre() - 1
     waitting = waitting_t.count() - 1
     deleted = auto_id - waitting
     for line in result:
         temp = dict()
         #temp['request_id'] = line['_id']
         temp['position'] = line['auto_id'] - deleted
         return_list.append(temp)
     if not return_list:
         self.write(dict(status=[]))
         return
     self.write(dict(status=return_list))
     return