Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

defaulting every MM as rated match #486

Merged
merged 23 commits into from
May 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ In this configuration, we'll run the direct app in a docker container locally bu

## Test Users

direct_user/topcoder2001 (Use this user to login to Direct and create challenges in the Topcoder DEV environment. You can alsoo use this user to manipulate challenges in Online Review)
direct_user/topcoder2001 (Use this user to login to Direct and create challenges in the Topcoder DEV environment. You can alsoo use this user to manipulate challenges in Online Review).

## **old** instructions

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2549,7 +2549,7 @@ public abstract class AbstractInformixProjectPersistence implements ProjectPersi
*/
private static final String INSERT_MM_ROUND_SQL = "INSERT INTO informixoltp:round(round_id, contest_id, name, status, "
+ "registration_limit, invitational, round_type_id, short_name, rated_ind) "
+ "VALUES (?, ?, ?, 'F', 1024, 0, 13, ?, 0)";
+ "VALUES (?, ?, ?, 'F', 1024, 0, 13, ?, 1)";

/**
* Sql statement for updating MM round
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3862,11 +3862,11 @@ else if (isDevContest)
contest.getProjectHeader().setProperty(ProjectPropertyType.TRACK_LATE_DELIVERABLES_PROJECT_PROPERTY_KEY, "false");
}

if (isCodeContest(contest) || isF2FContest(contest) || isDesignF2FContest(contest)) {
// no rated for Code || F2F || Design F2F
if (isF2FContest(contest) || isDesignF2FContest(contest)) {
// no rated for F2F || Design F2F
contest.getProjectHeader().setProperty(ProjectPropertyType.RATED_PROJECT_PROPERTY_KEY, "No");

// no Reiliability for Code || F2F || Design F2F
// no Reliability for Code || F2F || Design F2F
contest.getProjectHeader().setProperty(ProjectPropertyType.RELIABILITY_BONUS_ELIGIBLE_PROJECT_PROPERTY_KEY, "false");
contest.getProjectHeader().setProperty(ProjectPropertyType.RELIABILITY_BONUS_COST_PROJECT_PROPERTY_KEY, "0");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1594,6 +1594,7 @@ public FullProjectData createProject(Project projectHeader, com.topcoder.project
phase.setId(0);
}

setScorecards(projectHeader, projectPhases);
// call phaseManager.updatePhases(projectPhases,operator)
Util.log(logger, Level.DEBUG, "Starts calling ProjectManager#updatePhases method.");
phaseManager.updatePhases(projectPhases, operator);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,27 @@
import com.topcoder.direct.services.view.action.contest.launch.ContestAction;
import com.topcoder.direct.services.view.dto.contest.ContestRoundType;
import com.topcoder.direct.services.view.dto.contest.ContestType;
import com.topcoder.direct.services.view.util.AmazonS3URI;
import com.topcoder.direct.services.view.util.DirectUtils;
import com.topcoder.management.deliverable.Submission;
import com.topcoder.management.deliverable.Upload;
import com.topcoder.management.resource.Resource;
import com.topcoder.service.project.SoftwareCompetition;
import com.topcoder.servlet.request.FileUpload;
import com.topcoder.servlet.request.UploadedFile;
import com.topcoder.shared.util.logging.Logger;
import org.apache.commons.io.FilenameUtils;

import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.HttpResponseException;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;

/**
Expand Down Expand Up @@ -65,6 +67,11 @@
*/
public class DownloadAllSoftwareSubmissionsAction extends ContestAction {

/**
* Logging instance
*/
private static final Logger logger = Logger.getLogger(DownloadAllSoftwareSubmissionsAction.class);

/**
* The id of the final submission type.
*
Expand Down Expand Up @@ -287,15 +294,42 @@ public void run() {
byte[] buffer = new byte[8192];
int read;
InputStream is = null;
DefaultHttpClient httpClient = new DefaultHttpClient();
try {
for (Submission sub : submissionsToDownload) {
String submissionFileZipName;
// url != null is s3
// url != null is s3/external url
if (sub.getUpload().getUrl() != null) {
S3Object s3Object = DirectUtils.getS3Client().getObject(new GetObjectRequest(s3Bucket,
DirectUtils.getS3FileKey(sub.getUpload().getUrl())));
is = s3Object.getObjectContent();
submissionFileZipName = DirectUtils.getS3FileKey(sub.getUpload().getUrl());
try {
AmazonS3URI s3Uri = DirectUtils.getS3Uri(sub.getUpload().getUrl());
if (s3Uri != null) {
S3Object s3Object = DirectUtils.getS3Client().getObject(new GetObjectRequest(s3Bucket,
DirectUtils.getS3FileKey(sub.getUpload().getUrl())));
is = s3Object.getObjectContent();
submissionFileZipName = "Submission-" + sub.getId() + "-" + DirectUtils.getS3FileKey(sub.getUpload().getUrl());
} else {
// external url other than s3
HttpGet request = new HttpGet(sub.getUpload().getUrl());
HttpResponse response = httpClient.execute(request);
// skip status code >=400
if (response.getStatusLine().getStatusCode() >= HttpStatus.SC_BAD_REQUEST) {
throw new HttpResponseException(response.getStatusLine().getStatusCode(), "Invalid file from external");
}

HttpEntity entity = response.getEntity();
if (entity != null) {
is = entity.getContent();
} else {
throw new HttpResponseException(HttpStatus.SC_BAD_REQUEST, "Invalid response from external");
}
submissionFileZipName = "Submission-" + sub.getId() + "-" + DirectUtils.getFileNameFromUrl(sub.getUpload().getUrl());
}
} catch (Exception e) {
logger.error("Fail to get submission " + sub.getId() + " url: " + sub.getUpload().getUrl() +
" message: " + e.getMessage());
logger.info("Skipping submission " + sub.getId() + " url: " + sub.getUpload().getUrl());
continue;
}
} else {
UploadedFile file;
if (DirectUtils.isStudio(contest)) {
Expand Down Expand Up @@ -350,6 +384,10 @@ public void run() {
// ignore
}
}
} finally {
if (httpClient != null) {
httpClient.getConnectionManager().shutdown();
}
}
try {
zos.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,22 @@

import com.amazonaws.services.s3.model.GetObjectRequest;
import com.amazonaws.services.s3.model.S3Object;
import com.amazonaws.services.s3.model.S3Object;
import com.topcoder.direct.services.view.action.BaseDirectStrutsAction;
import com.topcoder.direct.services.view.dto.contest.ContestType;
import com.topcoder.direct.services.view.util.AmazonS3URI;
import com.topcoder.direct.services.view.util.DirectUtils;
import com.topcoder.management.deliverable.Submission;
import com.topcoder.management.resource.Resource;
import com.topcoder.service.project.SoftwareCompetition;
import com.topcoder.servlet.request.FileUpload;
import com.topcoder.servlet.request.UploadedFile;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.HttpResponseException;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

import java.io.InputStream;

Expand Down Expand Up @@ -91,9 +99,9 @@ public class DownloadSoftwareSubmissionAction extends BaseDirectStrutsAction {
private SoftwareCompetition contest;

/**
* S3 url of uploaded file. Null if it use local file
* External url of uploaded file. Null if it use local file
*/
private String s3Url;
private String externalUrl;

/**
* S3 bucket
Expand Down Expand Up @@ -144,7 +152,7 @@ protected void executeAction() throws Exception {
uploadedFile = fileUpload.getUploadedFile(submission.getUpload().getParameter());
}
} else {
s3Url = submission.getUpload().getUrl();
externalUrl = submission.getUpload().getUrl();
}

}
Expand All @@ -157,10 +165,27 @@ protected void executeAction() throws Exception {
* if any error occurs when getting the input stream of the uploaded file.
*/
public InputStream getInputStream() throws Exception {
if (s3Url != null) {
S3Object s3Object = DirectUtils.getS3Client().getObject(new GetObjectRequest(s3Bucket,
DirectUtils.getS3FileKey(s3Url)));
return s3Object.getObjectContent();
if (externalUrl != null) {
AmazonS3URI s3Uri = DirectUtils.getS3Uri(externalUrl);
if (s3Uri != null) {
S3Object s3Object = DirectUtils.getS3Client().getObject(new GetObjectRequest(s3Bucket,
DirectUtils.getS3FileKey(externalUrl)));
return s3Object.getObjectContent();
} else {
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpGet request = new HttpGet(externalUrl);
HttpResponse response = httpClient.execute(request);
// skip status code >=400
if (response.getStatusLine().getStatusCode() >= HttpStatus.SC_BAD_REQUEST) {
throw new HttpResponseException(response.getStatusLine().getStatusCode(), "Invalid file from external");
}

HttpEntity entity = response.getEntity();
if (entity == null) {
throw new HttpResponseException(HttpStatus.SC_BAD_REQUEST, "Invalid response from external");
}
return entity.getContent();
}
}

if (contest.getProjectHeader().getProjectCategory().getId() == ContestType.COPILOT_POSTING.getId()) {
Expand Down Expand Up @@ -188,8 +213,12 @@ public InputStream getInputStream() throws Exception {
* if any error occurs when getting the file name of the uploaded file.
*/
public String getContentDisposition() throws Exception {
if (s3Url != null) {
return "attachment; filename=\"submission-" + submission.getId() + "-" + DirectUtils.getS3FileKey(s3Url) + "\"";
if (externalUrl != null) {
AmazonS3URI s3Uri = DirectUtils.getS3Uri(externalUrl);
if (s3Uri != null) {
return "attachment; filename=\"submission-" + submission.getId() + "-" + DirectUtils.getS3FileKey(externalUrl) + "\"";
}
return "attachment; filename=\"submission-" + submission.getId() + "-" + DirectUtils.getFileNameFromUrl(externalUrl) + "\"";
}

if (contest.getProjectHeader().getProjectCategory().getId() == ContestType.COPILOT_POSTING.getId()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,11 @@ private Object getMapResult(SoftwareCompetition bean) {

// retrieve review scorecard id.
for(com.topcoder.project.phases.Phase phase : bean.getProjectPhases().getAllPhases()){
if(phase.getPhaseType().getName().equals(com.topcoder.project.phases.PhaseType.REVIEW_PHASE.getName())){
if(phase.getPhaseType().getName().equals(com.topcoder.project.phases.PhaseType.REVIEW_PHASE.getName()) && phase.getAttributes().get("Scorecard ID") != null){
result.put("reviewScorecardId", phase.getAttributes().get("Scorecard ID").toString());
}

if(phase.getPhaseType().getName().equals(com.topcoder.project.phases.PhaseType.ITERATIVE_REVIEW_PHASE.getName())){
if(phase.getPhaseType().getName().equals(com.topcoder.project.phases.PhaseType.ITERATIVE_REVIEW_PHASE.getName()) && phase.getAttributes().get("Scorecard ID") != null){
result.put("iterativeReviewScorecardId", phase.getAttributes().get("Scorecard ID").toString());
}
}
Expand Down
Loading