Пример #1
0
    def accumulate(self, rhs):
        """Accumulates data from rhs into self."""
        stats_framework.accumulate(
            self, rhs, ['bot_ids', 'bot_ids_bad', 'buckets', 'users'])
        self.bot_ids = sorted(set(self.bot_ids) | set(rhs.bot_ids))
        self.bot_ids_bad = sorted(set(self.bot_ids_bad) | set(rhs.bot_ids_bad))
        lhs_dimensions = dict((i.dimensions, i) for i in self.buckets)
        rhs_dimensions = dict((i.dimensions, i) for i in rhs.buckets)
        for key in set(rhs_dimensions):
            if key not in lhs_dimensions:
                # Make a copy of the right hand side so no aliasing occurs.
                lhs_dimensions[key] = rhs_dimensions[key].__class__()
                # Call the root method directly so 'enhancements' do not get in the way.
                lhs_dimensions[key].populate(
                    **ndb.Model.to_dict(rhs_dimensions[key]))
            else:
                lhs_dimensions[key].accumulate(rhs_dimensions[key])
        self.buckets = sorted(lhs_dimensions.itervalues(),
                              key=lambda i: i.dimensions)

        lhs_users = dict((i.user, i) for i in self.users)
        rhs_users = dict((i.user, i) for i in rhs.users)
        for key in set(rhs_users):
            if key not in lhs_users:
                # Make a copy of the right hand side so no aliasing occurs.
                lhs_users[key] = rhs_users[key].__class__()
                # Call the root method directly so 'enhancements' do not get in the way.
                lhs_users[key].populate(**ndb.Model.to_dict(lhs_users[key]))
            else:
                lhs_users[key].accumulate(rhs_users[key])
        self.users = sorted(lhs_users.itervalues(), key=lambda i: i.user)
Пример #2
0
  def accumulate(self, rhs):
    """Accumulates data from rhs into self."""
    stats_framework.accumulate(
        self, rhs, ['bot_ids', 'bot_ids_bad', 'buckets', 'users'])
    self.bot_ids = sorted(set(self.bot_ids) | set(rhs.bot_ids))
    self.bot_ids_bad = sorted(set(self.bot_ids_bad) | set(rhs.bot_ids_bad))
    lhs_dimensions = dict((i.dimensions, i) for i in self.buckets)
    rhs_dimensions = dict((i.dimensions, i) for i in rhs.buckets)
    for key in set(rhs_dimensions):
      if key not in lhs_dimensions:
        # Make a copy of the right hand side so no aliasing occurs.
        lhs_dimensions[key] = rhs_dimensions[key].__class__()
        # Call the root method directly so 'enhancements' do not get in the way.
        lhs_dimensions[key].populate(**ndb.Model.to_dict(rhs_dimensions[key]))
      else:
        lhs_dimensions[key].accumulate(rhs_dimensions[key])
    self.buckets = sorted(
        lhs_dimensions.itervalues(), key=lambda i: i.dimensions)

    lhs_users = dict((i.user, i) for i in self.users)
    rhs_users = dict((i.user, i) for i in rhs.users)
    for key in set(rhs_users):
      if key not in lhs_users:
        # Make a copy of the right hand side so no aliasing occurs.
        lhs_users[key] = rhs_users[key].__class__()
        # Call the root method directly so 'enhancements' do not get in the way.
        lhs_users[key].populate(**ndb.Model.to_dict(lhs_users[key]))
      else:
        lhs_users[key].accumulate(rhs_users[key])
    self.users = sorted(lhs_users.itervalues(), key=lambda i: i.user)
Пример #3
0
 def accumulate(self, rhs):
   assert self.user == rhs.user
   stats_framework.accumulate(self, rhs, ['user'])
Пример #4
0
 def accumulate(self, rhs):
   assert self.dimensions == rhs.dimensions
   stats_framework.accumulate(
       self, rhs, ['bot_ids', 'bot_ids_bad', 'dimensions'])
   self.bot_ids = sorted(set(self.bot_ids) | set(rhs.bot_ids))
   self.bot_ids_bad = sorted(set(self.bot_ids_bad) | set(rhs.bot_ids_bad))
Пример #5
0
 def accumulate(self, rhs):
     # accumulate() specifically handles where default value is a class instance.
     return stats_framework.accumulate(self, rhs, ['d'])
Пример #6
0
 def accumulate(self, rhs):
     return stats_framework.accumulate(self, rhs, [])
Пример #7
0
 def accumulate(self, rhs):
   # accumulate() specifically handles where default value is a class instance.
   return stats_framework.accumulate(self, rhs, ['d'])
Пример #8
0
 def accumulate(self, rhs):
   return stats_framework.accumulate(self, rhs, [])
Пример #9
0
 def accumulate(self, rhs):
     assert self.user == rhs.user
     stats_framework.accumulate(self, rhs, ['user'])
Пример #10
0
 def accumulate(self, rhs):
     assert self.dimensions == rhs.dimensions
     stats_framework.accumulate(self, rhs,
                                ['bot_ids', 'bot_ids_bad', 'dimensions'])
     self.bot_ids = sorted(set(self.bot_ids) | set(rhs.bot_ids))
     self.bot_ids_bad = sorted(set(self.bot_ids_bad) | set(rhs.bot_ids_bad))