def test_new_feedback_thread_creation_events(self): exp_id = 'exp_id' event_services.FeedbackThreadCreatedEventHandler.record(exp_id) thread = feedback_services.get_thread_analytics(exp_id) self.assertEqual(thread.id, exp_id) self.assertEqual(thread.num_open_threads, 1) self.assertEqual(thread.num_total_threads, 1) event_services.FeedbackThreadCreatedEventHandler.record(exp_id) thread = feedback_services.get_thread_analytics(exp_id) self.assertEqual(thread.id, exp_id) self.assertEqual(thread.num_open_threads, 2) self.assertEqual(thread.num_total_threads, 2)
def get(self, exploration_id): feedback_thread_analytics = ( feedback_services.get_thread_analytics(exploration_id)) self.values.update({ 'num_open_threads': (feedback_thread_analytics.num_open_threads), 'num_total_threads': (feedback_thread_analytics.num_total_threads), }) self.render_json(self.values)
def get(self): """Handles GET requests.""" if self.user_id is None: raise self.PageNotFoundException subscribed_summaries = ( exp_services.get_exploration_summaries_matching_ids( subscription_services.get_exploration_ids_subscribed_to( self.user_id))) def _get_intro_card_color(category): return ( feconf.CATEGORIES_TO_COLORS[category] if category in feconf.CATEGORIES_TO_COLORS else feconf.DEFAULT_COLOR) explorations_list = [] for exp_summary in subscribed_summaries: if exp_summary is None: continue feedback_thread_analytics = feedback_services.get_thread_analytics( exp_summary.id) explorations_list.append({ 'id': exp_summary.id, 'title': exp_summary.title, 'category': exp_summary.category, 'objective': exp_summary.objective, 'language_code': exp_summary.language_code, 'last_updated': utils.get_time_in_millisecs( exp_summary.exploration_model_last_updated), 'created_on': utils.get_time_in_millisecs( exp_summary.exploration_model_created_on), 'status': exp_summary.status, 'community_owned': exp_summary.community_owned, 'is_editable': True, 'thumbnail_icon_url': ( utils.get_thumbnail_icon_url_for_category( exp_summary.category)), 'thumbnail_bg_color': utils.get_hex_color_for_category( exp_summary.category), 'ratings': exp_summary.ratings, 'num_open_threads': ( feedback_thread_analytics.num_open_threads), 'num_total_threads': ( feedback_thread_analytics.num_total_threads), }) explorations_list = sorted( explorations_list, key=lambda x: (x['num_open_threads'], x['last_updated']), reverse=True) self.values.update({ 'explorations_list': explorations_list, }) self.render_json(self.values)
def test_recording_reopening_feedback_thread_events(self): exp_id = 'exp_id' # Changing Status from closed to open. event_services.FeedbackThreadStatusChangedEventHandler.record( exp_id, '', feedback_models.STATUS_CHOICES_OPEN) thread = feedback_services.get_thread_analytics(exp_id) self.assertEqual(thread.id, exp_id) self.assertEqual(thread.num_open_threads, 1) # Changing Status from open to closed. event_services.FeedbackThreadStatusChangedEventHandler.record( exp_id, feedback_models.STATUS_CHOICES_OPEN, '') thread = feedback_services.get_thread_analytics(exp_id) self.assertEqual(thread.id, exp_id) self.assertEqual(thread.num_open_threads, 0)
def get(self, exploration_id): feedback_thread_analytics = feedback_services.get_thread_analytics( exploration_id) self.values.update({ 'num_open_threads': ( feedback_thread_analytics['num_open_threads']), 'num_total_threads': ( feedback_thread_analytics['num_total_threads']), }) self.render_json(self.values)
def get(self): """Handles GET requests.""" if self.user_id is None: raise self.PageNotFoundException subscribed_summaries = exp_services.get_exploration_summaries_matching_ids( subscription_services.get_activity_ids_subscribed_to(self.user_id) ) def _get_intro_card_color(category): return ( feconf.CATEGORIES_TO_COLORS[category] if category in feconf.CATEGORIES_TO_COLORS else feconf.DEFAULT_COLOR ) explorations_list = [] for exp_summary in subscribed_summaries: if exp_summary is None: continue feedback_thread_analytics = feedback_services.get_thread_analytics(exp_summary.id) explorations_list.append( { "id": exp_summary.id, "title": exp_summary.title, "category": exp_summary.category, "objective": exp_summary.objective, "language_code": exp_summary.language_code, "last_updated": utils.get_time_in_millisecs(exp_summary.exploration_model_last_updated), "created_on": utils.get_time_in_millisecs(exp_summary.exploration_model_created_on), "status": exp_summary.status, "community_owned": exp_summary.community_owned, "is_editable": True, "thumbnail_image_url": ( "/images/gallery/exploration_background_%s_small.png" % _get_intro_card_color(exp_summary.category) ), "ratings": exp_summary.ratings, "num_open_threads": (feedback_thread_analytics["num_open_threads"]), "num_total_threads": (feedback_thread_analytics["num_total_threads"]), } ) explorations_list = sorted( explorations_list, key=lambda x: (x["num_open_threads"], x["last_updated"]), reverse=True ) self.values.update({"explorations_list": explorations_list}) self.render_json(self.values)
def get(self): """Handles GET requests.""" if self.user_id is None: raise self.PageNotFoundException def _get_intro_card_color(category): return (feconf.CATEGORIES_TO_COLORS[category] if category in feconf.CATEGORIES_TO_COLORS else feconf.DEFAULT_COLOR) subscribed_exploration_summaries = ( exp_services.get_exploration_summaries_matching_ids( subscription_services.get_exploration_ids_subscribed_to( self.user_id))) subscribed_collection_summaries = ( collection_services.get_collection_summaries_matching_ids( subscription_services.get_collection_ids_subscribed_to( self.user_id))) explorations_list = [] collections_list = [] for exp_summary in subscribed_exploration_summaries: if exp_summary is None: continue feedback_thread_analytics = feedback_services.get_thread_analytics( exp_summary.id) # TODO(sll): Reuse _get_displayable_exp_summary_dicts() in # summary_services, instead of replicating it like this. explorations_list.append({ 'id': exp_summary.id, 'title': exp_summary.title, 'category': exp_summary.category, 'objective': exp_summary.objective, 'language_code': exp_summary.language_code, 'last_updated': utils.get_time_in_millisecs( exp_summary.exploration_model_last_updated), 'created_on': utils.get_time_in_millisecs( exp_summary.exploration_model_created_on), 'status': exp_summary.status, 'community_owned': exp_summary.community_owned, 'thumbnail_icon_url': (utils.get_thumbnail_icon_url_for_category( exp_summary.category)), 'thumbnail_bg_color': utils.get_hex_color_for_category(exp_summary.category), 'ratings': exp_summary.ratings, 'num_open_threads': (feedback_thread_analytics.num_open_threads), 'num_total_threads': (feedback_thread_analytics.num_total_threads), }) explorations_list = sorted(explorations_list, key=lambda x: (x['num_open_threads'], x['last_updated']), reverse=True) if (self.username in config_domain.WHITELISTED_COLLECTION_EDITOR_USERNAMES.value): for collection_summary in subscribed_collection_summaries: if collection_summary is None: continue # TODO(sll): Reuse _get_displayable_collection_summary_dicts() # in summary_services, instead of replicating it like this. collections_list.append({ 'id': collection_summary.id, 'title': collection_summary.title, 'category': collection_summary.category, 'objective': collection_summary.objective, 'language_code': collection_summary.language_code, 'last_updated': utils.get_time_in_millisecs( collection_summary.collection_model_last_updated), 'created_on': utils.get_time_in_millisecs( collection_summary.collection_model_created_on), 'status': collection_summary.status, 'community_owned': collection_summary.community_owned, 'thumbnail_icon_url': (utils.get_thumbnail_icon_url_for_category( collection_summary.category)), 'thumbnail_bg_color': utils.get_hex_color_for_category( collection_summary.category), }) self.values.update({ 'explorations_list': explorations_list, 'collections_list': collections_list, }) self.render_json(self.values)
def get(self): """Handles GET requests.""" if self.user_id is None: raise self.PageNotFoundException def _get_intro_card_color(category): return ( feconf.CATEGORIES_TO_COLORS[category] if category in feconf.CATEGORIES_TO_COLORS else feconf.DEFAULT_COLOR) subscribed_exploration_summaries = ( exp_services.get_exploration_summaries_matching_ids( subscription_services.get_exploration_ids_subscribed_to( self.user_id))) subscribed_collection_summaries = ( collection_services.get_collection_summaries_matching_ids( subscription_services.get_collection_ids_subscribed_to( self.user_id))) explorations_list = [] collections_list = [] for exp_summary in subscribed_exploration_summaries: if exp_summary is None: continue feedback_thread_analytics = feedback_services.get_thread_analytics( exp_summary.id) # TODO(sll): Reuse _get_displayable_exp_summary_dicts() in # summary_services, instead of replicating it like this. explorations_list.append({ 'id': exp_summary.id, 'title': exp_summary.title, 'category': exp_summary.category, 'objective': exp_summary.objective, 'language_code': exp_summary.language_code, 'last_updated': utils.get_time_in_millisecs( exp_summary.exploration_model_last_updated), 'created_on': utils.get_time_in_millisecs( exp_summary.exploration_model_created_on), 'status': exp_summary.status, 'community_owned': exp_summary.community_owned, 'thumbnail_icon_url': ( utils.get_thumbnail_icon_url_for_category( exp_summary.category)), 'thumbnail_bg_color': utils.get_hex_color_for_category( exp_summary.category), 'ratings': exp_summary.ratings, 'num_open_threads': ( feedback_thread_analytics.num_open_threads), 'num_total_threads': ( feedback_thread_analytics.num_total_threads), }) explorations_list = sorted( explorations_list, key=lambda x: (x['num_open_threads'], x['last_updated']), reverse=True) if (self.username in config_domain.WHITELISTED_COLLECTION_EDITOR_USERNAMES.value): for collection_summary in subscribed_collection_summaries: if collection_summary is None: continue # TODO(sll): Reuse _get_displayable_collection_summary_dicts() # in summary_services, instead of replicating it like this. collections_list.append({ 'id': collection_summary.id, 'title': collection_summary.title, 'category': collection_summary.category, 'objective': collection_summary.objective, 'language_code': collection_summary.language_code, 'last_updated': utils.get_time_in_millisecs( collection_summary.collection_model_last_updated), 'created_on': utils.get_time_in_millisecs( collection_summary.collection_model_created_on), 'status': collection_summary.status, 'community_owned': collection_summary.community_owned, 'thumbnail_icon_url': ( utils.get_thumbnail_icon_url_for_category( collection_summary.category)), 'thumbnail_bg_color': utils.get_hex_color_for_category( collection_summary.category), }) self.values.update({ 'explorations_list': explorations_list, 'collections_list': collections_list, }) self.render_json(self.values)