def _serve_site_organizations(self): orgs_dict = [] orgs = Organization.query() for o in orgs.iter(): orgs_dict.append(o.to_dict()) self.write_json_response(orgs_dict)
def _gen_analytics(self): log.info('Hourly Analytic Generator Stated') hours = int(self.request.get('hours', 1)) for h in reversed(xrange(hours)): log.info('Generation for hour %s', h) start = datetime.now().replace(minute=0, second=0, microsecond=0) - timedelta(hours=h) log.info('Start Time: %s', start) ana_count = 0 orgs = Organization.query() for org in orgs.iter(keys_only=True, limit=3): log.info('Generating Analytics for %s', org.id()) users = User.query(User.organization == org).order( User.first_name) for usr in users.iter(keys_only=True, limit=3): ana_count += self._create_analytic(start=start, org=org, usr=usr) ana_count += self._create_analytic(start=start) log.info( 'Hourly Analytic Generator Finished: %s Analytics created', ana_count)