Skip to content

Commit

Permalink
Merge pull request pc2ccs#987 from SamanwaySadhu/I978_update_resultFi…
Browse files Browse the repository at this point in the history
…les_with_new_rules

I978: Update generated results file according to new WF honor degrees proposed by Bill
  • Loading branch information
johnbrvc authored Aug 28, 2024
2 parents fcdc36f + b0e437b commit 3d9e104
Show file tree
Hide file tree
Showing 128 changed files with 4,087 additions and 5,056 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Copyright (C) 1989-2019 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau.
// Copyright (C) 1989-2024 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau.
package edu.csus.ecs.pc2.core.list;

import java.io.Serializable;
import java.util.Comparator;
import java.text.Normalizer;

/**
* Compare the name of one team with another, ignoring case.
Expand Down Expand Up @@ -44,6 +45,12 @@ public int compare(String displayNameOne, String displayNameTwo) {
}
}
}

/**
* strip accents off string to make them accent insensitive
*/
displayNameOne = Normalizer.normalize(displayNameOne, Normalizer.Form.NFD);
displayNameTwo = Normalizer.normalize(displayNameTwo, Normalizer.Form.NFD);
/*
* Perform quick check to see if the 2 strings have a chance of being in the same ballpark
*/
Expand Down
10 changes: 9 additions & 1 deletion src/edu/csus/ecs/pc2/core/list/AccountNameComparator.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Copyright (C) 1989-2019 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau.
// Copyright (C) 1989-2024 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau.
package edu.csus.ecs.pc2.core.list;

import java.io.Serializable;
import java.util.Comparator;
import java.text.Normalizer;

/**
* Compare the name of one team with another.
Expand Down Expand Up @@ -44,6 +45,13 @@ public int compare(String displayNameOne, String displayNameTwo) {
}
}
}

/**
* strip accents off string to make them accent insensitive
*/
displayNameOne = Normalizer.normalize(displayNameOne, Normalizer.Form.NFD);
displayNameTwo = Normalizer.normalize(displayNameTwo, Normalizer.Form.NFD);

if (displayNameOne.charAt(0) != displayNameTwo.charAt(0)) {
// if first character different then just regular sort
return displayNameOne.compareTo(displayNameTwo);
Expand Down
65 changes: 65 additions & 0 deletions src/edu/csus/ecs/pc2/core/report/ResultsCSVReport.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Copyright (C) 1989-2024 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau.
package edu.csus.ecs.pc2.core.report;

import java.io.PrintWriter;

import edu.csus.ecs.pc2.core.log.Log;
import edu.csus.ecs.pc2.core.model.Filter;
import edu.csus.ecs.pc2.exports.ccs.ResultsFile;

public class ResultsCSVReport extends AbstractReport {

/**
* Generates the results.csv report
*
* @author Samanway Sadhu
*/
private static final long serialVersionUID = -6988627277661871941L;

private ResultsFile resultsFile = new ResultsFile();

@Override
public String getReportTitle() {
return "results.csv report";
}

@Override
public String[] createReport(Filter filter) {
return resultsFile.createCSVFileLines(getContest());
}

@Override
public String getPluginTitle() {
return "results.csv";
}

public void writeReport(PrintWriter printWriter) {

printWriter.println();

try {

printHeader(printWriter);

try {

String[] lines = resultsFile.createCSVFileLines(getContest());

for (String line : lines) {
printWriter.println(line);
}
} catch (Exception e) {
printWriter.println("Exception in report: " + e.getMessage());
e.printStackTrace(printWriter);
}

printFooter(printWriter);

printWriter.close();
printWriter = null;

} catch (Exception e) {
log.log(Log.INFO, "Exception writing report", e);
}
}
}
1 change: 1 addition & 0 deletions src/edu/csus/ecs/pc2/core/report/ResultsTSVReport.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Copyright (C) 1989-2024 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau.
package edu.csus.ecs.pc2.core.report;

import java.io.PrintWriter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.util.Comparator;

import edu.csus.ecs.pc2.core.list.AccountList;
import edu.csus.ecs.pc2.core.list.AccountNameComparator;
import edu.csus.ecs.pc2.core.list.AccountNameCaseComparator;
import edu.csus.ecs.pc2.core.model.Account;

/**
Expand All @@ -23,7 +23,7 @@ public class FinalsStandingsRecordComparator implements Serializable, Comparator
*/
private static final long serialVersionUID = 2417425534254224622L;

private AccountNameComparator accountNameComparator = new AccountNameComparator();
private AccountNameCaseComparator accountNameCaseComparator = new AccountNameCaseComparator();

private AccountList cachedAccountList;

Expand Down Expand Up @@ -89,7 +89,7 @@ public int compare(StandingsRecord o1, StandingsRecord o2) {
nameB = accountB.getDisplayName();
b5 = teamB.getClientId().hashCode();
// nameComparison = nameA.toLowerCase().compareTo(nameB.toLowerCase());
nameComparison = accountNameComparator.compare(nameA, nameB);
nameComparison = accountNameCaseComparator.compare(nameA, nameB);

//
// Primary Sort = number of solved problems (high to low)
Expand Down
Loading

0 comments on commit 3d9e104

Please sign in to comment.