Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I978: Update generated results file according to new WF honor degrees proposed by Bill #987

Merged
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
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
Loading