You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by ba...@apache.org on 2015/05/04 03:43:42 UTC
svn commit: r1677520 -
/continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/ViewBuildsReportAction.java
Author: batkinson
Date: Mon May 4 01:43:42 2015
New Revision: 1677520
URL: http://svn.apache.org/r1677520
Log:
Removed filtering made unnecessary by permissions-sensitive queries.
Modified:
continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/ViewBuildsReportAction.java
Modified: continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/ViewBuildsReportAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/ViewBuildsReportAction.java?rev=1677520&r1=1677519&r2=1677520&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/ViewBuildsReportAction.java (original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/ViewBuildsReportAction.java Mon May 4 01:43:42 2015
@@ -294,40 +294,15 @@ public class ViewBuildsReportAction
groupIds.addAll( permittedGroupMap.values() );
}
- // Users can preview a limited number of records (use export for more)
- int offset = 0;
- List<BuildResult> results;
- filteredResults = new ArrayList<BuildResult>();
- populating:
- do
- {
-
- // Fetch a batch of records (may be filtered based on permissions)
- results = getContinuum().getBuildResultsInRange( groupIds, fromDate, toDate, buildStatus, triggeredBy,
- offset, MAX_BROWSE_SIZE );
- offset += MAX_BROWSE_SIZE;
-
- for ( BuildResult result : results )
- {
- if ( permittedGroupMap.containsKey( result.getProject().getProjectGroup().getName() ) )
- {
- filteredResults.add( result );
- }
-
- if ( filteredResults.size() >= MAX_BROWSE_SIZE )
- {
- break populating; // Halt when we have filled a batch equivalent with results
- }
- }
- }
- while ( results.size() == MAX_BROWSE_SIZE ); // Keep fetching until batch is empty or incomplete
+ filteredResults = getContinuum().getBuildResultsInRange(
+ groupIds, fromDate, toDate, buildStatus, triggeredBy, 0, MAX_BROWSE_SIZE );
+ int resultSize = filteredResults.size();
if ( filteredResults.size() == MAX_BROWSE_SIZE )
{
addActionMessage( getText( "projectBuilds.report.limitedResults" ) );
}
- int resultSize = filteredResults.size();
pageTotal = resultSize / rowCount + ( resultSize % rowCount == 0 ? 0 : 1 );
if ( resultSize > 0 && ( page < 1 || page > pageTotal ) )
@@ -387,16 +362,17 @@ public class ViewBuildsReportAction
try
{
- // First, build the output file
+ // HTTP headers so the browser treats the file nicely for the user
rawResponse.setContentType( "text/csv" );
rawResponse.addHeader( "Content-disposition", "attachment;filename=continuum_project_builds_report.csv" );
- Writer output = rawResponse.getWriter();
+ Writer output = rawResponse.getWriter();
DateFormat dateTimeFormat = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSSZ" );
+ // Now, stream the file to the browser in pieces
try
{
- // Write the header
+ // Write the CSV file header
output.append( "Group,Project,ID,Build#,Started,Duration,Triggered By,Status\n" );
// Limit query to scan only what the user is permitted to see
@@ -419,19 +395,12 @@ public class ViewBuildsReportAction
results = getContinuum().getBuildResultsInRange( groupIds, fromDate, toDate, buildStatus,
triggeredBy, offset, EXPORT_BATCH_SIZE );
- offset += EXPORT_BATCH_SIZE; // Ensure we advance through results
+ // Ensure we advance through results
+ offset += EXPORT_BATCH_SIZE;
// Convert each build result to a line in the CSV file
for ( BuildResult result : results )
{
-
- if ( !permittedGroupMap.containsKey( result.getProject().getProjectGroup().getName() ) )
- {
- continue;
- }
-
- exported += 1;
-
Project project = result.getProject();
ProjectGroup projectGroup = project.getProjectGroup();
@@ -452,8 +421,11 @@ public class ViewBuildsReportAction
buildDuration,
result.getUsername(),
stateName );
+
output.append( formattedLine );
+ exported += 1;
+
if ( exported >= MAX_EXPORT_SIZE )
{
log.warn( "build report export hit limit of {} records", MAX_EXPORT_SIZE );