Skip to content
Permalink
Browse files
Include the latest patchset only in manual trigger page
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 8a9839ce165620fd045d062e897c5ca186a52fb9
@@ -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(".");
@@ -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.
@@ -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>
@@ -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>

0 comments on commit 8a9839c

Please sign in to comment.