def test_posting_to_feedback_thread_results_in_subscription(self): # The viewer posts a message to the thread. message_text = 'text' feedback_services.create_thread( 'exp_id', 'state_name', self.viewer_id, 'subject', message_text) thread_ids_subscribed_to = self._get_thread_ids_subscribed_to( self.viewer_id) self.assertEqual(len(thread_ids_subscribed_to), 1) full_thread_id = thread_ids_subscribed_to[0] thread_id = feedback_services.get_thread_id_from_full_thread_id( full_thread_id) self.assertEqual( feedback_services.get_messages('exp_id', thread_id)[0]['text'], message_text) # The editor posts a follow-up message to the thread. new_message_text = 'new text' feedback_services.create_message( 'exp_id', thread_id, self.editor_id, '', '', new_message_text) # The viewer and editor are now both subscribed to the thread. self.assertEqual( self._get_thread_ids_subscribed_to(self.viewer_id), [full_thread_id]) self.assertEqual( self._get_thread_ids_subscribed_to(self.editor_id), [full_thread_id])
def test_posting_to_feedback_thread_results_in_subscription(self): # The viewer posts a message to the thread. message_text = 'text' feedback_services.create_thread('exp_id', 'state_name', self.viewer_id, 'subject', message_text) thread_ids_subscribed_to = self._get_thread_ids_subscribed_to( self.viewer_id) self.assertEqual(len(thread_ids_subscribed_to), 1) full_thread_id = thread_ids_subscribed_to[0] thread_id = feedback_services.get_thread_id_from_full_thread_id( full_thread_id) self.assertEqual( feedback_services.get_messages('exp_id', thread_id)[0]['text'], message_text) # The editor posts a follow-up message to the thread. new_message_text = 'new text' feedback_services.create_message('exp_id', thread_id, self.editor_id, '', '', new_message_text) # The viewer and editor are now both subscribed to the thread. self.assertEqual(self._get_thread_ids_subscribed_to(self.viewer_id), [full_thread_id]) self.assertEqual(self._get_thread_ids_subscribed_to(self.editor_id), [full_thread_id])
def map(item): user_id = item.id job_queued_msec = RecentUpdatesMRJobManager._get_job_queued_msec() reducer_key = '%s@%s' % (user_id, job_queued_msec) exploration_ids_list = item.activity_ids collection_ids_list = item.collection_ids feedback_thread_ids_list = item.feedback_thread_ids (most_recent_activity_commits, tracked_exp_models_for_feedback) = ( RecentUpdatesMRJobManager._get_most_recent_activity_commits( exp_models.ExplorationModel, exploration_ids_list, 'exploration', feconf.UPDATE_TYPE_EXPLORATION_COMMIT, feconf.COMMIT_MESSAGE_EXPLORATION_DELETED)) for exp_model in tracked_exp_models_for_feedback: threads = feedback_services.get_all_threads(exp_model.id, False) for thread in threads: full_thread_id = (feedback_models.FeedbackThreadModel. generate_full_thread_id( exp_model.id, thread['thread_id'])) if full_thread_id not in feedback_thread_ids_list: feedback_thread_ids_list.append(full_thread_id) # TODO(bhenning): Implement a solution to having feedback threads for # collections. most_recent_activity_commits += ( RecentUpdatesMRJobManager._get_most_recent_activity_commits( collection_models.CollectionModel, collection_ids_list, 'collection', feconf.UPDATE_TYPE_COLLECTION_COMMIT, feconf.COMMIT_MESSAGE_COLLECTION_DELETED))[0] for recent_activity_commit_dict in most_recent_activity_commits: yield (reducer_key, recent_activity_commit_dict) for feedback_thread_id in feedback_thread_ids_list: exp_id = feedback_services.get_exp_id_from_full_thread_id( feedback_thread_id) thread_id = feedback_services.get_thread_id_from_full_thread_id( feedback_thread_id) last_message = ( feedback_models.FeedbackMessageModel.get_most_recent_message( exp_id, thread_id)) yield (reducer_key, { 'type': feconf.UPDATE_TYPE_FEEDBACK_MESSAGE, 'activity_id': last_message.exploration_id, 'activity_title': exp_models.ExplorationModel.get_by_id( last_message.exploration_id).title, 'author_id': last_message.author_id, 'last_updated_ms': utils.get_time_in_millisecs(last_message.created_on), 'subject': last_message.get_thread_subject(), })
def map(item): user_id = item.id job_queued_msec = RecentUpdatesMRJobManager._get_job_queued_msec() reducer_key = '%s@%s' % (user_id, job_queued_msec) exploration_ids_list = item.activity_ids collection_ids_list = item.collection_ids feedback_thread_ids_list = item.feedback_thread_ids (most_recent_activity_commits, tracked_exp_models_for_feedback) = ( RecentUpdatesMRJobManager._get_most_recent_activity_commits( exp_models.ExplorationModel, exploration_ids_list, 'exploration', feconf.UPDATE_TYPE_EXPLORATION_COMMIT, feconf.COMMIT_MESSAGE_EXPLORATION_DELETED)) for exp_model in tracked_exp_models_for_feedback: threads = feedback_services.get_all_threads(exp_model.id, False) for thread in threads: full_thread_id = ( feedback_models.FeedbackThreadModel.generate_full_thread_id( exp_model.id, thread['thread_id'])) if full_thread_id not in feedback_thread_ids_list: feedback_thread_ids_list.append(full_thread_id) # TODO(bhenning): Implement a solution to having feedback threads for # collections. most_recent_activity_commits += ( RecentUpdatesMRJobManager._get_most_recent_activity_commits( collection_models.CollectionModel, collection_ids_list, 'collection', feconf.UPDATE_TYPE_COLLECTION_COMMIT, feconf.COMMIT_MESSAGE_COLLECTION_DELETED))[0] for recent_activity_commit_dict in most_recent_activity_commits: yield (reducer_key, recent_activity_commit_dict) for feedback_thread_id in feedback_thread_ids_list: exp_id = feedback_services.get_exp_id_from_full_thread_id( feedback_thread_id) thread_id = feedback_services.get_thread_id_from_full_thread_id( feedback_thread_id) last_message = ( feedback_models.FeedbackMessageModel.get_most_recent_message( exp_id, thread_id)) yield (reducer_key, { 'type': feconf.UPDATE_TYPE_FEEDBACK_MESSAGE, 'activity_id': last_message.exploration_id, 'activity_title': exp_models.ExplorationModel.get_by_id( last_message.exploration_id).title, 'author_id': last_message.author_id, 'last_updated_ms': utils.get_time_in_millisecs( last_message.created_on), 'subject': last_message.get_thread_subject(), })