Repository: oppia/oppia

Issue:
The number of open feedback items displayed in the creator dashboard is incorrect.
When I go to my creator dashboard, this exploration at the top of the list appears to have the most number of open feedback (8):

![dashboard1](https://cloud.githubusercontent.com/assets/10575562/24437703/7ae99b16-13f7-11e7-90e6-15e1d1c7a99f.png)

However, on clicking the lesson and examining the feedback page, I only see two feedback threads in total:

![dashboard2](https://cloud.githubusercontent.com/assets/10575562/24437719/914a0314-13f7-11e7-9a71-2ed87e8da9ab.png)

Other entries on the creator dashboard appear to be similarly incorrect (e.g. the next exploration is claimed to have 8 open feedback, but in reality it actually has two open feedback, one closed feedback and one accepted suggestion). So it's probably a generic issue and not something that is related to any particular exploration.

This is misleading, and needs to be fixed.


Discussion:
@526avijitgupta, would you mind taking a look into this, please? 
Assigning @kevinlee12 for (at least) investigation and breakdown.
Hi @kevinlee12! Did you manage to figure out why this is happening?
Oops, this fell completely out of the radar in the mist of the chaos...I'm hoping to get to the investigation early next week. 

> On Apr 14, 2017, at 1:21 AM, Sean Lip <notifications@github.com> wrote:
> 
> Hi @kevinlee12! Did you manage to figure out why this is happening?
> 
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub, or mute the thread.
> 

Unassigning myself since I'm unable to get to this soon
I tried to replicate this issue but was unable to do so. The things I tried are : 

Created 5 new explorations.
=> The creator of the explorations creating new feedback threads for each exploration.
=> Tried different permutations by changing the status of feedback thread to all the available options.
=> The creator of the explorations providing feedback for explorations anonymously.
=> Other logged in user providing feedback.
=> Other new user providing feedback without logging in. 

The count of the number of feedbacks for each of the explorations was correct in each case.

/cc @seanlip 
Thanks, @kirankonduru! I will probably take this up and see if I can find any clues, since the issue occurs on my creator dashboard.

Resolving patch:
diff --git a/core/controllers/dashboard.py b/core/controllers/dashboard.py
--- a/core/controllers/dashboard.py
+++ b/core/controllers/dashboard.py
@@ -154,21 +154,27 @@ def _get_intro_card_color(category):
         def _round_average_ratings(rating):
             return round(rating, feconf.AVERAGE_RATINGS_DASHBOARD_PRECISION)
 
-        exploration_ids_subscribed_to = (
-            subscription_services.get_exploration_ids_subscribed_to(
-                self.user_id))
-
-        subscribed_exploration_summaries = filter(None, (
+        # We need to do the filtering because some activities that were
+        # originally subscribed to may have been deleted since.
+        subscribed_exploration_summaries = [
+            summary for summary in
             exp_services.get_exploration_summaries_matching_ids(
-                exploration_ids_subscribed_to)))
-        subscribed_collection_summaries = filter(None, (
+                subscription_services.get_exploration_ids_subscribed_to(
+                    self.user_id))
+            if summary is not None]
+        subscribed_collection_summaries = [
+            summary for summary in
             collection_services.get_collection_summaries_matching_ids(
                 subscription_services.get_collection_ids_subscribed_to(
-                    self.user_id))))
+                    self.user_id))
+            if summary is not None]
+
+        exploration_ids_subscribed_to = [
+            summary.id for summary in subscribed_exploration_summaries]
 
-        exp_summary_list = summary_services.get_displayable_exp_summary_dicts(
+        exp_summary_dicts = summary_services.get_displayable_exp_summary_dicts(
             subscribed_exploration_summaries)
-        collection_summary_list = []
+        collection_summary_dicts = []
 
         feedback_thread_analytics = (
             feedback_services.get_thread_analytics_multi(
@@ -180,7 +186,7 @@ def _round_average_ratings(rating):
 
         total_unresolved_answers = 0
 
-        for ind, exploration in enumerate(exp_summary_list):
+        for ind, exploration in enumerate(exp_summary_dicts):
             exploration.update(feedback_thread_analytics[ind].to_dict())
             exploration.update({
                 'num_unresolved_answers': (
@@ -195,8 +201,8 @@ def _round_average_ratings(rating):
             })
             total_unresolved_answers += exploration['num_unresolved_answers']
 
-        exp_summary_list = sorted(
-            exp_summary_list,
+        exp_summary_dicts = sorted(
+            exp_summary_dicts,
             key=lambda x: (x['num_open_threads'], x['last_updated_msec']),
             reverse=True)
 
@@ -205,7 +211,7 @@ def _round_average_ratings(rating):
             for collection_summary in subscribed_collection_summaries:
                 # TODO(sll): Reuse _get_displayable_collection_summary_dicts()
                 # in summary_services, instead of replicating it like this.
-                collection_summary_list.append({
+                collection_summary_dicts.append({
                     'id': collection_summary.id,
                     'title': collection_summary.title,
                     'category': collection_summary.category,
@@ -259,8 +265,8 @@ def _round_average_ratings(rating):
             subscribers_list.append(subscriber_summary)
 
         self.values.update({
-            'explorations_list': exp_summary_list,
-            'collections_list': collection_summary_list,
+            'explorations_list': exp_summary_dicts,
+            'collections_list': collection_summary_dicts,
             'dashboard_stats': dashboard_stats,
             'last_week_stats': last_week_stats,
             'subscribers_list': subscribers_list


Test patch: