From c8555000c4e64c4cbbfcef1d170b5a55b38fcedf Mon Sep 17 00:00:00 2001
From: Arunkumar Ramadass <arunkumar-3.r-3@cognizant.com>
Date: Mon, 19 Jun 2017 16:09:12 +0530
Subject: [PATCH] Added fix for BUG 1697585. Modified the logic to remove
 repeated module names from the response array.

Closes Bug: 1697585
Modified File: dashboard/templates/_macros/module_details.html
Bug: The module names are repeated if the "Release" is selected as "All"
and any Official Module is selected.
Solution: In the response modules array the module names were repeated.
Removed the duplicates from the array.

Change-Id: I91317961a24614b90106ea84eb61178aa7255788
---
 .../dashboard/templates/_macros/module_details.html      | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/stackalytics/dashboard/templates/_macros/module_details.html b/stackalytics/dashboard/templates/_macros/module_details.html
index f2366a44b..15c61e6ac 100644
--- a/stackalytics/dashboard/templates/_macros/module_details.html
+++ b/stackalytics/dashboard/templates/_macros/module_details.html
@@ -6,10 +6,17 @@
             url: makeURI("/api/1.0/modules/{{ module }}", extra_options),
             dataType: "json",
             success: function (data) {
+                var obj = {};
+                var unique_array = [];
                 var module = data["module"];
                 for (var i=0; i < module.modules.length; i++) {
-                    module.modules[i].uri = makeURI('/', {module: module.modules[i].module_name});
+                    if(!obj.hasOwnProperty(module.modules[i].module_name)){
+                        module.modules[i].uri = makeURI('/', {module: module.modules[i].module_name});
+                        unique_array.push(module.modules[i]);
+                    }
+                    obj[module.modules[i].module_name] = module.modules[i];
                 }
+                module.modules=unique_array;
                 $("#module_details_template").tmpl(data["module"]).appendTo("#module_details_container");
             }
         });