"""
__author__ = 'xumingming'
"""
import random

from django.conf import settings
from gm_types.doris import CARD_TYPE

# from libs.cache import ssdb_client

# class Recaller(object):
#     def __get__(self, instance, owner):
#         if instance is None:
#             return self
#         key = Recaller.get_feed_key(instance.device_id, instance.feed_type)
#         data = ssdb_client.zrrange(key, 2 * instance.offset, 2 * instance.size)
#         data = list(map(lambda x: x.decode('utf-8'), data))
#         feeds = data[::2]
#         recall_size = len(feeds) if len(feeds) <= instance.size else instance.size
#         recall = random.sample(feeds, recall_size)
#         instance.recall_ = recall
#
#     @staticmethod
#     def get_feed_key(device, feed_type):
#         if feed_type == CARD_TYPE.DIARY:
#             return settings.FEED_DIARY_NAME.format(device)
#         elif feed_type == CARD_TYPE.QUESTION:
#             return settings.FEED_QUESTION_NAME.format(device)
#         elif feed_type == CARD_TYPE.ANSWER:
#             return settings.FEED_ANSWER_NAME.format(device)
#         elif feed_type == CARD_TYPE.ARTICLE:
#             return settings.FEED_ARTICLE_NAME.format(device)
#         else:
#             return None
#
#
# class DiaryRecaller(Recaller):
#     pass
#
#
# class QuestionRecaller(Recaller):
#     pass
#
#
# class ArticleRecaller(Recaller):
#     pass
#
#
# class AnswerRecaller(Recaller):
#     pass
