def get(self): """Handles GET requests.""" num_unseen_notifications = 0 if self.user_id and self.username: last_seen_msec = subscription_services.get_last_seen_notifications_msec(self.user_id) _, recent_notifications = user_jobs.DashboardRecentUpdatesAggregator.get_recent_notifications(self.user_id) for notification in recent_notifications: if notification["last_updated_ms"] > last_seen_msec and notification["author_id"] != self.user_id: num_unseen_notifications += 1 self.render_json({"num_unseen_notifications": num_unseen_notifications})
def get(self): """Handles GET requests.""" num_unseen_notifications = 0 last_seen_msec = ( subscription_services.get_last_seen_notifications_msec( self.user_id)) _, recent_notifications = ( user_jobs_continuous.DashboardRecentUpdatesAggregator. get_recent_user_changes(self.user_id)) for notification in recent_notifications: if (notification['last_updated_ms'] > last_seen_msec and notification['author_id'] != self.user_id): num_unseen_notifications += 1 self.render_json({ 'num_unseen_notifications': num_unseen_notifications, })
def get(self): """Handles GET requests.""" num_unseen_notifications = 0 if self.user_id and self.username: last_seen_msec = ( subscription_services.get_last_seen_notifications_msec( self.user_id)) _, recent_notifications = ( user_jobs_continuous.DashboardRecentUpdatesAggregator.get_recent_notifications( # pylint: disable=line-too-long self.user_id)) for notification in recent_notifications: if (notification['last_updated_ms'] > last_seen_msec and notification['author_id'] != self.user_id): num_unseen_notifications += 1 self.render_json({ 'num_unseen_notifications': num_unseen_notifications, })
def get(self): """Handles GET requests.""" num_unseen_notifications = 0 if self.user_id and self.username: last_seen_msec = ( subscription_services.get_last_seen_notifications_msec( self.user_id)) _, recent_updates = ( user_jobs.DashboardRecentUpdatesAggregator.get_recent_updates( self.user_id)) for update in recent_updates: if (update['last_updated_ms'] > last_seen_msec and update['author_id'] != self.user_id): num_unseen_notifications += 1 self.render_json({ 'num_unseen_notifications': num_unseen_notifications, })
def get(self): """Handles GET requests.""" num_unseen_notifications = 0 if self.user_id and self.username: last_seen_msec = ( subscription_services.get_last_seen_notifications_msec( self.user_id)) _, recent_updates = ( user_jobs.DashboardRecentUpdatesAggregator.get_recent_updates( self.user_id)) for update in recent_updates: if (update['last_updated_ms'] > last_seen_msec and update['author_id'] != self.user_id): num_unseen_notifications += 1 self.render_json({ 'num_unseen_notifications': num_unseen_notifications, })
def get(self): """Handles GET requests.""" if self.user_id is None: raise self.PageNotFoundException job_queued_msec, recent_notifications = ( user_jobs_continuous.DashboardRecentUpdatesAggregator. get_recent_notifications( # pylint: disable=line-too-long self.user_id)) last_seen_msec = ( subscription_services.get_last_seen_notifications_msec( self.user_id)) # Replace author_ids with their usernames. author_ids = [ notification['author_id'] for notification in recent_notifications if notification['author_id'] ] author_usernames = user_services.get_usernames(author_ids) author_id_to_username = { None: '', } for ind, author_id in enumerate(author_ids): author_id_to_username[author_id] = author_usernames[ind] for notification in recent_notifications: notification['author_username'] = ( author_id_to_username[notification['author_id']]) del notification['author_id'] subscription_services.record_user_has_seen_notifications( self.user_id, job_queued_msec if job_queued_msec else 0.0) self.values.update({ # This may be None if no job has ever run for this user. 'job_queued_msec': job_queued_msec, # This may be None if this is the first time the user has seen # the dashboard. 'last_seen_msec': last_seen_msec, 'recent_notifications': recent_notifications, }) self.render_json(self.values)
def get(self): """Handles GET requests.""" if self.user_id is None: raise self.PageNotFoundException job_queued_msec, recent_updates = ( user_jobs.DashboardRecentUpdatesAggregator.get_recent_updates( self.user_id)) last_seen_msec = ( subscription_services.get_last_seen_notifications_msec( self.user_id)) # Replace author_ids with their usernames. author_ids = [ update['author_id'] for update in recent_updates if update['author_id'] ] author_usernames = user_services.get_usernames(author_ids) author_id_to_username = { None: '', } for ind in range(len(author_ids)): author_id_to_username[author_ids[ind]] = author_usernames[ind] for update in recent_updates: update['author_username'] = ( author_id_to_username[update['author_id']]) del update['author_id'] subscription_services.record_user_has_seen_notifications( self.user_id, job_queued_msec if job_queued_msec else 0.0) self.values.update({ # This may be None if no job has ever run for this user. 'job_queued_msec': job_queued_msec, # This may be None if this is the first time the user has seen # the dashboard. 'last_seen_msec': last_seen_msec, 'recent_updates': recent_updates, }) self.render_json(self.values)
def get(self): """Handles GET requests.""" if self.user_id is None: raise self.PageNotFoundException job_queued_msec, recent_notifications = ( user_jobs_continuous.DashboardRecentUpdatesAggregator.get_recent_notifications( # pylint: disable=line-too-long self.user_id)) last_seen_msec = ( subscription_services.get_last_seen_notifications_msec( self.user_id)) # Replace author_ids with their usernames. author_ids = [ notification['author_id'] for notification in recent_notifications if notification['author_id']] author_usernames = user_services.get_usernames(author_ids) author_id_to_username = { None: '', } for ind, author_id in enumerate(author_ids): author_id_to_username[author_id] = author_usernames[ind] for notification in recent_notifications: notification['author_username'] = ( author_id_to_username[notification['author_id']]) del notification['author_id'] subscription_services.record_user_has_seen_notifications( self.user_id, job_queued_msec if job_queued_msec else 0.0) self.values.update({ # This may be None if no job has ever run for this user. 'job_queued_msec': job_queued_msec, # This may be None if this is the first time the user has seen # the dashboard. 'last_seen_msec': last_seen_msec, 'recent_notifications': recent_notifications, }) self.render_json(self.values)
def get(self): """Handles GET requests.""" if self.user_id is None: raise self.PageNotFoundException job_queued_msec, recent_updates = ( user_jobs.DashboardRecentUpdatesAggregator.get_recent_updates( self.user_id)) last_seen_msec = ( subscription_services.get_last_seen_notifications_msec( self.user_id)) # Replace author_ids with their usernames. author_ids = [ update['author_id'] for update in recent_updates if update['author_id']] author_usernames = user_services.get_usernames(author_ids) author_id_to_username = { None: '', } for ind in range(len(author_ids)): author_id_to_username[author_ids[ind]] = author_usernames[ind] for update in recent_updates: update['author_username'] = ( author_id_to_username[update['author_id']]) del update['author_id'] subscription_services.record_user_has_seen_notifications( self.user_id, job_queued_msec if job_queued_msec else 0.0) self.values.update({ # This may be None if no job has ever run for this user. 'job_queued_msec': job_queued_msec, # This may be None if this is the first time the user has seen # the dashboard. 'last_seen_msec': last_seen_msec, 'recent_updates': recent_updates, }) self.render_json(self.values)
def get(self): """Handles GET requests.""" if self.user_id is None: raise self.PageNotFoundException job_queued_msec, recent_notifications = user_jobs.DashboardRecentUpdatesAggregator.get_recent_notifications( self.user_id ) last_seen_msec = subscription_services.get_last_seen_notifications_msec(self.user_id) # Replace author_ids with their usernames. author_ids = [notification["author_id"] for notification in recent_notifications if notification["author_id"]] author_usernames = user_services.get_usernames(author_ids) author_id_to_username = {None: ""} for ind in range(len(author_ids)): author_id_to_username[author_ids[ind]] = author_usernames[ind] for notification in recent_notifications: notification["author_username"] = author_id_to_username[notification["author_id"]] del notification["author_id"] subscription_services.record_user_has_seen_notifications( self.user_id, job_queued_msec if job_queued_msec else 0.0 ) self.values.update( { # This may be None if no job has ever run for this user. "job_queued_msec": job_queued_msec, # This may be None if this is the first time the user has seen # the dashboard. "last_seen_msec": last_seen_msec, "recent_notifications": recent_notifications, } ) self.render_json(self.values)