Exemple #1
0
 def remove(self, key, columns=None):
     """Remove a key from the column family stub."""
     if key not in self.rows:
         raise NotFoundException()
     if columns is None:
         del self.rows[key]
     else:
         for c in columns:
             if c in self.rows[key]:
                 del self.rows[key][c]
         if not self.rows[key]:
             del self.rows[key]
     return gm_timestamp()
Exemple #2
0
 def remove(self, key, columns=None):
     """Remove a key from the column family stub."""
     if key not in self.rows:
         raise NotFoundException()
     if columns is None:
         del self.rows[key]
     else:
         for c in columns:
             if c in self.rows[key]:
                 del self.rows[key][c]
         if not self.rows[key]:
             del self.rows[key]
     return gm_timestamp()
Exemple #3
0
def recompute_listings():
    # when removing the _fullname override from LiveUpdateEvent, the format of
    # event fullnames changed. this recomputes the static listings so that they
    # contain appropriate data going forward.
    #
    # this does not do anything to the active or reported listings. in the
    # prior case, we assume it will be regenerated properly one minute from
    # now. in the latter case, humans should ensure that the listing is empty
    # of reports before running this job.

    items_by_state = collections.defaultdict(list)
    queries_by_state = {
        "live": queries.get_live_events,
        "complete": queries.get_complete_events,
    }

    for event in models.LiveUpdateEvent._all():
        items_by_state[event.state].append(event)

    timestamp = gm_timestamp()
    with CachedQueryMutator() as m:
        for state, query_fn in queries_by_state.iteritems():
            query = query_fn("new", "all")

            items = items_by_state[state]
            sorted_items = sorted(items, key=lambda ev: ev._date, reverse=True)
            listing = [item for item in sorted_items][:MAX_CACHED_ITEMS]
            cols = query._cols_from_things(listing)

            query._raw_replace(
                mutator=m,
                cols=cols,
                ttl=None,
                job_timestamp=timestamp,
                clobber=True,
            )
Exemple #4
0
    def __setitem__(self, key, value, timestamp=None):
        if timestamp is None:
            timestamp = self.__timestamp or gm_timestamp()

        self.store[key] = (value, timestamp)
Exemple #5
0
    def __setitem__(self, key, value, timestamp=None):
        if timestamp is None:
            timestamp = self.__timestamp or gm_timestamp()

        super(OrderedDictWithTime, self).__setitem__(key, (value, timestamp))
Exemple #6
0
    def __setitem__(self, key, value, timestamp=None):
        if timestamp is None:
            timestamp = self.__timestamp or gm_timestamp()

        self.store[key] = (value, timestamp)