Skip to content

Commit

Permalink
Include the latest patchset only in manual trigger page
Browse files Browse the repository at this point in the history
Gerrit search in manual trigger page shows all patchsets in a change.
But session needs much memory if result has many rows.
It causes poor PermGen space.

This patch adds a feature that includes the latest patchset only in
search result.

Fix for JENKINS-21064

Task-Url: https://issues.jenkins-ci.org/browse/JENKINS-21064
  • Loading branch information
rinrinne committed Sep 16, 2014
1 parent 8804f89 commit 8a9839c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
Expand Up @@ -278,20 +278,23 @@ public String toReadableHtml(String subject) {
* @param queryString the query to send to Gerrit.
* @param request the request.
* @param selectedServer the selected Gerrit server.
* @param allPatchSets if the result includes all patchsets in a change.
* @param response the response.
* @throws IOException if the query fails.
*/
@SuppressWarnings("unused")
//Called from jelly
public void doGerritSearch(@QueryParameter("queryString") final String queryString,
@QueryParameter("selectedServer") final String selectedServer, StaplerRequest request,
@QueryParameter("selectedServer") final String selectedServer,
@QueryParameter("allPatchSets") final boolean allPatchSets, StaplerRequest request,
StaplerResponse response) throws IOException {

HttpSession session = request.getSession();
// Create session if nothing.
if (session == null) {
session = request.getSession(true);
}
session.setAttribute("allPatchSets", allPatchSets);
session.setAttribute("selectedServer", selectedServer);
if (!isServerEnabled(selectedServer)) {
response.sendRedirect2(".");
Expand All @@ -306,7 +309,17 @@ public void doGerritSearch(@QueryParameter("queryString") final String queryStri
session.setAttribute("queryString", queryString);

try {
List<JSONObject> json = handler.queryJava(queryString, true, true, false);
List<JSONObject> json = handler.queryJava(queryString, allPatchSets, true, false);
if (!allPatchSets) {
for (JSONObject j : json) {
if (j.containsKey("id")) {
JSONArray jsonArray = new JSONArray();
jsonArray.add(j.getJSONObject("currentPatchSet"));
j.put("patchSets", jsonArray);
j.remove("currentPatchSet");
}
}
}
session.setAttribute(SESSION_RESULT, json);
//TODO Implement some smart default selection.
//That can notice that a specific revision is searched or that there is only one result etc.
Expand Down
@@ -0,0 +1,5 @@
<div>
<p>Check if you want to get all patchsets in a change by query.</p>

<p>If disabled, result includes the latest patchset only.</p>
</div>
@@ -0,0 +1,5 @@
<div>
<p>チェンジ内の全てのパッチセットを検索結果として得たい場合、この機能を有効にします。</p>

<p>無効にした場合は、最新のパッチセットのみ検索結果に表示します。</p>
</div>
Expand Up @@ -54,6 +54,12 @@
value="${request.session.getAttribute('queryString')}"
default="status:open"/>
</f:entry>
<f:entry title="${%Include All Patchsets}"
help="help-allPatchSets">
<f:checkbox name="allPatchSets"
checked="${request.session.getAttribute('allPatchSets')}"
default="false"/>
</f:entry>
<f:block>
<f:submit value="${%Search}"/>
</f:block>
Expand Down

0 comments on commit 8a9839c

Please sign in to comment.