Fix other users dashboards

When an user visit other user dashboard with cold page load, dashboard
doesn't load because preloading will preload queries for user dashboard
(self) that will not work for other user dashboard.

This is fixed by restricting regexp for identifying which dashboard url
should get preloading.

Change-Id: Ie2c51fa4a403e0af53c948e55b0d0ecd358a9014
diff --git a/java/com/google/gerrit/httpd/raw/IndexPreloadingUtil.java b/java/com/google/gerrit/httpd/raw/IndexPreloadingUtil.java
index 383d982..448d803 100644
--- a/java/com/google/gerrit/httpd/raw/IndexPreloadingUtil.java
+++ b/java/com/google/gerrit/httpd/raw/IndexPreloadingUtil.java
@@ -52,7 +52,7 @@
       Pattern.compile(CHANGE_CANONICAL_URL + BASE_PATCH_NUM_URL_PART + "?" + "/?$");
   public static final Pattern DIFF_URL_PATTERN =
       Pattern.compile(CHANGE_CANONICAL_URL + BASE_PATCH_NUM_URL_PART + "(/(.+))" + "/?$");
-  public static final Pattern DASHBOARD_PATTERN = Pattern.compile(".*/dashboard/.+$");
+  public static final Pattern DASHBOARD_PATTERN = Pattern.compile(".*/dashboard/self$");
 
   // These queries should be kept in sync with PolyGerrit:
   // polygerrit-ui/app/elements/core/gr-navigation/gr-navigation.ts
diff --git a/javatests/com/google/gerrit/httpd/raw/IndexPreloadingUtilTest.java b/javatests/com/google/gerrit/httpd/raw/IndexPreloadingUtilTest.java
index b6c8d74..284e8c7 100644
--- a/javatests/com/google/gerrit/httpd/raw/IndexPreloadingUtilTest.java
+++ b/javatests/com/google/gerrit/httpd/raw/IndexPreloadingUtilTest.java
@@ -17,6 +17,7 @@
 import static com.google.common.truth.Truth.assertThat;
 import static com.google.common.truth.Truth8.assertThat;
 import static com.google.gerrit.httpd.raw.IndexPreloadingUtil.computeChangeRequestsPath;
+import static com.google.gerrit.httpd.raw.IndexPreloadingUtil.parseRequestedPage;
 
 import com.google.gerrit.httpd.raw.IndexPreloadingUtil.RequestedPage;
 import org.junit.Test;
@@ -47,4 +48,14 @@
     assertThat(computeChangeRequestsPath("/c/Scripts/+/232/1//COMMIT_MSG", RequestedPage.DIFF))
         .hasValue("changes/Scripts~232");
   }
+
+  @Test
+  public void preloadOnlyForSelfDashboard() throws Exception {
+    assertThat(parseRequestedPage("https://gerrit-review.googlesource.com/dashboard/self"))
+        .isEqualTo(RequestedPage.DASHBOARD);
+    assertThat(parseRequestedPage("https://gerrit-review.googlesource.com/dashboard/1085901"))
+        .isEqualTo(RequestedPage.PAGE_WITHOUT_PRELOADING);
+    assertThat(parseRequestedPage("https://gerrit-review.googlesource.com/dashboard/gerrit"))
+        .isEqualTo(RequestedPage.PAGE_WITHOUT_PRELOADING);
+  }
 }