Beispiel #1
0
class Party(object):
    def __init__(self, id):
        self.id = id
        self._queue = Queue(self.id)

    def pop_track(self):
        research_base = copy.deepcopy(self._queue)
        missing_tracks = config.PARTY_QUEUE_PANIC - (len(self._queue) - 1);
        logging.info("Es fehlen " + str(missing_tracks) + " Tracks");
        if(missing_tracks > 0):
            for t in find_similar_tracks(research_base.all, missing_tracks):
                logging.info("Track hinzugefuegt")
                # add simillar track to queue, no votes.
                self._queue.add(t.to_dict(), 0)
        track, votes = self._queue.pop()
        return track

    def get_queue(self, version=None):
        if version and not version < self._queue.version:
            # No changes to the queue
            return
        return [x for x in self._queue.all], self._queue.version

    def get_event_id(self):
        return stores.parties[self.id]['event_id']

    def vote(self, user, track_uri):
        user_vote_key = '%s:%s' % (user, track_uri,)
        if user_vote_key not in stores.votes:
            self._queue.vote(track_uri)
            stores.votes.timeout_store(user_vote_key, 1, config.USER_REPEAT_VOTE_WAIT)
Beispiel #2
0
class Party(object):
    def __init__(self, id):
        self.id = id
        self._queue = Queue(self.id)

    def pop_track(self):
        track, votes = self._queue.pop()
        if not track:
            # queue is empty, should never happen...
            return None
        if len(self._queue) < config.PARTY_QUEUE_PANIC:
            for t in find_similar_tracks(self._queue.all):
                # add simillar track to queue, no votes.
                self._queue.add(t.to_dict(), 0)
        return track

    def get_queue(self, version=None):
        if version and not version < self._queue.version:
            # No changes to the queue
            return
        return [x for x in self._queue.all], self._queue.version

    def get_event_id(self):
        return stores.parties[self.id]['event_id']

    def vote(self, user, track_uri):
        user_vote_key = '%s:%s' % (user, track_uri,)
        if user_vote_key not in stores.votes:
            self._queue.vote(track_uri)
            stores.votes.timeout_store(user_vote_key, 1, config.USER_REPEAT_VOTE_WAIT)
Beispiel #3
0
 def __init__(self, id):
     self.id = id
     self._queue = Queue(self.id)
Beispiel #4
0
 def __init__(self, id):
     self.id = id
     self._queue = Queue(self.id)
Beispiel #5
0
 def __init__(self, id):
     self.id = id
     self._queue = Queue(self.id)
     self._played = Played(self.id)