Skip to content

Commit

Permalink
#2948 Update output of percentages, fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dwalizer committed Jan 10, 2025
1 parent b5e5f58 commit 8bfdd15
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ class ExcelExportService {
CellStyle dateStyle = workbook.createCellStyle()
dateStyle.setDataFormat((short) 22) // NOTE: 14 = "mm/dd/yyyy"

CellStyle percentStyle = workbook.createCellStyle()
percentStyle.setDataFormat((short) 9)

Cell cell = null

Integer projectPoints = projDefRepo.getTotalPointsByProjectId(projectId) ?: 0
Expand All @@ -103,8 +106,10 @@ class ExcelExportService {
}
row.createCell(columnNumber++).setCellValue(user.userMaxLevel)
row.createCell(columnNumber++).setCellValue(user.totalPoints)
Double percentage = (user.totalPoints / projectPoints) * 100
row.createCell(columnNumber++).setCellValue(percentage)
Double percentage = (user.totalPoints / projectPoints)
cell = row.createCell(columnNumber++)
cell.setCellStyle(percentStyle)
cell.setCellValue(percentage)

cell = row.createCell(columnNumber++)
cell.setCellStyle(dateStyle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ class ExportUserProgressSpec extends ExportBaseIntSpec {
then:
validateExport(excelExport.file, [
["For All Dragons Only"],
["User ID", "Last Name", "First Name", "Org", "Level", "Current Points", "Points First Earned (UTC)", "Points Last Earned (UTC)"],
[getUserIdForDisplay(user2), getName(user2, false), getName(user2), "", "1.0", "60.0", today.format("dd-MMM-yyyy"), today.format("dd-MMM-yyyy")],
[getUserIdForDisplay(user1), getName(user1, false), getName(user1), "", "2.0", "100.0", fiveDaysAgo.format("dd-MMM-yyyy"), oneDayAgo.format("dd-MMM-yyyy")],
["User ID", "Last Name", "First Name", "Org", "Level", "Current Points", "Percent Complete", "Points First Earned (UTC)", "Points Last Earned (UTC)"],
[getUserIdForDisplay(user2), getName(user2, false), getName(user2), "", "1.0", "60.0", "0.2", today.format("dd-MMM-yyyy"), today.format("dd-MMM-yyyy")],
[getUserIdForDisplay(user1), getName(user1, false), getName(user1), "", "2.0", "100.0", "0.3333333333", fiveDaysAgo.format("dd-MMM-yyyy"), oneDayAgo.format("dd-MMM-yyyy")],
["For All Dragons Only"],
])

validateExport(excelExportAfterDelete.file, [
["For All Dragons Only"],
["User ID", "Last Name", "First Name", "Org", "Level", "Current Points", "Points First Earned (UTC)", "Points Last Earned (UTC)"],
[getUserIdForDisplay(user2), getName(user2, false), getName(user2), "", "1.0", "10.0", today.format("dd-MMM-yyyy"), today.format("dd-MMM-yyyy")],
["User ID", "Last Name", "First Name", "Org", "Level", "Current Points", "Percent Complete", "Points First Earned (UTC)", "Points Last Earned (UTC)"],
[getUserIdForDisplay(user2), getName(user2, false), getName(user2), "", "1.0", "10.0", "0.2", today.format("dd-MMM-yyyy"), today.format("dd-MMM-yyyy")],
["For All Dragons Only"],
])
}
Expand Down Expand Up @@ -120,13 +120,13 @@ class ExportUserProgressSpec extends ExportBaseIntSpec {
then:
validateExport(excelExport.file, [
["For All Dragons Only"],
["User ID", "Last Name", "First Name", "Org", "Level", "Current Points", "Points First Earned (UTC)", "Points Last Earned (UTC)"],
[getUserIdForDisplay(users[0]), getName(users[0], false), getName(users[0]), "tag0", "0.0", "10.0", today.format("dd-MMM-yyyy"), today.format("dd-MMM-yyyy")],
[getUserIdForDisplay(users[1]), getName(users[1], false), getName(users[1]), "tag1", "1.0", "20.0", oneDayAgo.format("dd-MMM-yyyy"), today.format("dd-MMM-yyyy")],
[getUserIdForDisplay(users[2]), getName(users[2], false), getName(users[2]), "tag2", "1.0", "30.0", (oneDayAgo-1).format("dd-MMM-yyyy"), today.format("dd-MMM-yyyy")],
[getUserIdForDisplay(users[3]), getName(users[3], false), getName(users[3]), "tag3", "2.0", "50.0", fiveDaysAgo.format("dd-MMM-yyyy"), oneDayAgo.format("dd-MMM-yyyy")],
[getUserIdForDisplay(users[4]), getName(users[4], false), getName(users[4]), "tag4", "3.0", "130.0", (tenDaysAgo+1).format("dd-MMM-yyyy"), oneDayAgo.format("dd-MMM-yyyy")],
[getUserIdForDisplay(users[5]), getName(users[5], false), getName(users[5]), "tag5", "4.0", "140.0", (tenDaysAgo).format("dd-MMM-yyyy"), oneDayAgo.format("dd-MMM-yyyy")],
["User ID", "Last Name", "First Name", "Org", "Level", "Current Points", "Percent Complete", "Points First Earned (UTC)", "Points Last Earned (UTC)"],
[getUserIdForDisplay(users[0]), getName(users[0], false), getName(users[0]), "tag0", "0.0", "10.0", "0.05", today.format("dd-MMM-yyyy"), today.format("dd-MMM-yyyy")],
[getUserIdForDisplay(users[1]), getName(users[1], false), getName(users[1]), "tag1", "1.0", "20.0", "0.1", oneDayAgo.format("dd-MMM-yyyy"), today.format("dd-MMM-yyyy")],
[getUserIdForDisplay(users[2]), getName(users[2], false), getName(users[2]), "tag2", "1.0", "30.0", "0.15", (oneDayAgo-1).format("dd-MMM-yyyy"), today.format("dd-MMM-yyyy")],
[getUserIdForDisplay(users[3]), getName(users[3], false), getName(users[3]), "tag3", "2.0", "50.0", "0.25", fiveDaysAgo.format("dd-MMM-yyyy"), oneDayAgo.format("dd-MMM-yyyy")],
[getUserIdForDisplay(users[4]), getName(users[4], false), getName(users[4]), "tag4", "3.0", "130.0", "0.65", (tenDaysAgo+1).format("dd-MMM-yyyy"), oneDayAgo.format("dd-MMM-yyyy")],
[getUserIdForDisplay(users[5]), getName(users[5], false), getName(users[5]), "tag5", "4.0", "140.0", "0.7", (tenDaysAgo).format("dd-MMM-yyyy"), oneDayAgo.format("dd-MMM-yyyy")],
["For All Dragons Only"],
])
}
Expand Down Expand Up @@ -159,9 +159,9 @@ class ExportUserProgressSpec extends ExportBaseIntSpec {
then:
validateExport(excelExport.file, [
["For Divine Dragon Only"],
["User ID", "Last Name", "First Name", "Org", "Level", "Current Points", "Points First Earned (UTC)", "Points Last Earned (UTC)"],
[getUserIdForDisplay(user2), getName(user2, false), getName(user2), "", "1.0", "60.0", today.format("dd-MMM-yyyy"), today.format("dd-MMM-yyyy")],
[getUserIdForDisplay(user1), getName(user1, false), getName(user1), "", "2.0", "100.0", fiveDaysAgo.format("dd-MMM-yyyy"), oneDayAgo.format("dd-MMM-yyyy")],
["User ID", "Last Name", "First Name", "Org", "Level", "Current Points", "Percent Complete", "Points First Earned (UTC)", "Points Last Earned (UTC)"],
[getUserIdForDisplay(user2), getName(user2, false), getName(user2), "", "1.0", "60.0", "0.2", today.format("dd-MMM-yyyy"), today.format("dd-MMM-yyyy")],
[getUserIdForDisplay(user1), getName(user1, false), getName(user1), "", "2.0", "100.0", "0.3333333333", fiveDaysAgo.format("dd-MMM-yyyy"), oneDayAgo.format("dd-MMM-yyyy")],
["For Divine Dragon Only"],
])
}
Expand Down Expand Up @@ -224,38 +224,38 @@ class ExportUserProgressSpec extends ExportBaseIntSpec {

List<List<String>> expectedDataForSortAsc = [
["For All Dragons Only"],
["User ID", "Last Name", "First Name", "Org", "Level", "Current Points", "Points First Earned (UTC)", "Points Last Earned (UTC)"],
[getUserIdForDisplay(users[0]), getName(users[0], false), getName(users[0]), "tag00", "0.0", "10.0", today.format("dd-MMM-yyyy"), today.format("dd-MMM-yyyy")],
[getUserIdForDisplay(users[1]), getName(users[1], false), getName(users[1]), "tag01", "1.0", "20.0", oneDayAgo.format("dd-MMM-yyyy"), today.format("dd-MMM-yyyy")],
[getUserIdForDisplay(users[2]), getName(users[2], false), getName(users[2]), "tag02", "1.0", "30.0", (oneDayAgo-1).format("dd-MMM-yyyy"), today.format("dd-MMM-yyyy")],
[getUserIdForDisplay(users[3]), getName(users[3], false), getName(users[3]), "tag03", "2.0", "50.0", fiveDaysAgo.format("dd-MMM-yyyy"), oneDayAgo.format("dd-MMM-yyyy")],
[getUserIdForDisplay(users[4]), getName(users[4], false), getName(users[4]), "tag04", "3.0", "130.0", (tenDaysAgo+1).format("dd-MMM-yyyy"), oneDayAgo.format("dd-MMM-yyyy")],
[getUserIdForDisplay(users[5]), getName(users[5], false), getName(users[5]), "tag10", "4.0", "140.0", (tenDaysAgo).format("dd-MMM-yyyy"), oneDayAgo.format("dd-MMM-yyyy")],
["User ID", "Last Name", "First Name", "Org", "Level", "Current Points", "Percent Complete", "Points First Earned (UTC)", "Points Last Earned (UTC)"],
[getUserIdForDisplay(users[0]), getName(users[0], false), getName(users[0]), "tag00", "0.0", "10.0", "0.05", today.format("dd-MMM-yyyy"), today.format("dd-MMM-yyyy")],
[getUserIdForDisplay(users[1]), getName(users[1], false), getName(users[1]), "tag01", "1.0", "20.0", "0.1", oneDayAgo.format("dd-MMM-yyyy"), today.format("dd-MMM-yyyy")],
[getUserIdForDisplay(users[2]), getName(users[2], false), getName(users[2]), "tag02", "1.0", "30.0", "0.15", (oneDayAgo-1).format("dd-MMM-yyyy"), today.format("dd-MMM-yyyy")],
[getUserIdForDisplay(users[3]), getName(users[3], false), getName(users[3]), "tag03", "2.0", "50.0", "0.25", fiveDaysAgo.format("dd-MMM-yyyy"), oneDayAgo.format("dd-MMM-yyyy")],
[getUserIdForDisplay(users[4]), getName(users[4], false), getName(users[4]), "tag04", "3.0", "130.0", "0.65", (tenDaysAgo+1).format("dd-MMM-yyyy"), oneDayAgo.format("dd-MMM-yyyy")],
[getUserIdForDisplay(users[5]), getName(users[5], false), getName(users[5]), "tag10", "4.0", "140.0", "0.7", (tenDaysAgo).format("dd-MMM-yyyy"), oneDayAgo.format("dd-MMM-yyyy")],
["For All Dragons Only"],
]
List<List<String>> expectedDataForSortDesc = [
["For All Dragons Only"],
["User ID", "Last Name", "First Name", "Org", "Level", "Current Points", "Points First Earned (UTC)", "Points Last Earned (UTC)"],
[getUserIdForDisplay(users[5]), getName(users[5], false), getName(users[5]), "tag10", "4.0", "140.0", (tenDaysAgo).format("dd-MMM-yyyy"), oneDayAgo.format("dd-MMM-yyyy")],
[getUserIdForDisplay(users[4]), getName(users[4], false), getName(users[4]), "tag04", "3.0", "130.0", (tenDaysAgo+1).format("dd-MMM-yyyy"), oneDayAgo.format("dd-MMM-yyyy")],
[getUserIdForDisplay(users[3]), getName(users[3], false), getName(users[3]), "tag03", "2.0", "50.0", fiveDaysAgo.format("dd-MMM-yyyy"), oneDayAgo.format("dd-MMM-yyyy")],
[getUserIdForDisplay(users[2]), getName(users[2], false), getName(users[2]), "tag02", "1.0", "30.0", (oneDayAgo-1).format("dd-MMM-yyyy"), today.format("dd-MMM-yyyy")],
[getUserIdForDisplay(users[1]), getName(users[1], false), getName(users[1]), "tag01", "1.0", "20.0", oneDayAgo.format("dd-MMM-yyyy"), today.format("dd-MMM-yyyy")],
[getUserIdForDisplay(users[0]), getName(users[0], false), getName(users[0]), "tag00", "0.0", "10.0", today.format("dd-MMM-yyyy"), today.format("dd-MMM-yyyy")],
["User ID", "Last Name", "First Name", "Org", "Level", "Current Points", "Percent Complete", "Points First Earned (UTC)", "Points Last Earned (UTC)"],
[getUserIdForDisplay(users[5]), getName(users[5], false), getName(users[5]), "tag10", "4.0", "140.0", "0.7", (tenDaysAgo).format("dd-MMM-yyyy"), oneDayAgo.format("dd-MMM-yyyy")],
[getUserIdForDisplay(users[4]), getName(users[4], false), getName(users[4]), "tag04", "3.0", "130.0", "0.65", (tenDaysAgo+1).format("dd-MMM-yyyy"), oneDayAgo.format("dd-MMM-yyyy")],
[getUserIdForDisplay(users[3]), getName(users[3], false), getName(users[3]), "tag03", "2.0", "50.0", "0.25", fiveDaysAgo.format("dd-MMM-yyyy"), oneDayAgo.format("dd-MMM-yyyy")],
[getUserIdForDisplay(users[2]), getName(users[2], false), getName(users[2]), "tag02", "1.0", "30.0", "0.15", (oneDayAgo-1).format("dd-MMM-yyyy"), today.format("dd-MMM-yyyy")],
[getUserIdForDisplay(users[1]), getName(users[1], false), getName(users[1]), "tag01", "1.0", "20.0", "0.1", oneDayAgo.format("dd-MMM-yyyy"), today.format("dd-MMM-yyyy")],
[getUserIdForDisplay(users[0]), getName(users[0], false), getName(users[0]), "tag00", "0.0", "10.0", "0.05", today.format("dd-MMM-yyyy"), today.format("dd-MMM-yyyy")],
["For All Dragons Only"],
]
List<List<String>> expectedDataForQuery = [
["For All Dragons Only"],
["User ID", "Last Name", "First Name", "Org", "Level", "Current Points", "Points First Earned (UTC)", "Points Last Earned (UTC)"],
[getUserIdForDisplay(users[0]), getName(users[0], false), getName(users[0]), "tag00", "0.0", "10.0", today.format("dd-MMM-yyyy"), today.format("dd-MMM-yyyy")],
["User ID", "Last Name", "First Name", "Org", "Level", "Current Points", "Percent Complete", "Points First Earned (UTC)", "Points Last Earned (UTC)"],
[getUserIdForDisplay(users[0]), getName(users[0], false), getName(users[0]), "tag00", "0.0", "10.0", "0.05", today.format("dd-MMM-yyyy"), today.format("dd-MMM-yyyy")],
["For All Dragons Only"],
]
List<List<String>> expectedDataForMinPointsFilter = [
["For All Dragons Only"],
["User ID", "Last Name", "First Name", "Org", "Level", "Current Points", "Points First Earned (UTC)", "Points Last Earned (UTC)"],
[getUserIdForDisplay(users[3]), getName(users[3], false), getName(users[3]), "tag03", "2.0", "50.0", fiveDaysAgo.format("dd-MMM-yyyy"), oneDayAgo.format("dd-MMM-yyyy")],
[getUserIdForDisplay(users[4]), getName(users[4], false), getName(users[4]), "tag04", "3.0", "130.0", (tenDaysAgo+1).format("dd-MMM-yyyy"), oneDayAgo.format("dd-MMM-yyyy")],
[getUserIdForDisplay(users[5]), getName(users[5], false), getName(users[5]), "tag10", "4.0", "140.0", (tenDaysAgo).format("dd-MMM-yyyy"), oneDayAgo.format("dd-MMM-yyyy")],
["User ID", "Last Name", "First Name", "Org", "Level", "Current Points", "Percent Complete", "Points First Earned (UTC)", "Points Last Earned (UTC)"],
[getUserIdForDisplay(users[3]), getName(users[3], false), getName(users[3]), "tag03", "2.0", "50.0", "0.25", fiveDaysAgo.format("dd-MMM-yyyy"), oneDayAgo.format("dd-MMM-yyyy")],
[getUserIdForDisplay(users[4]), getName(users[4], false), getName(users[4]), "tag04", "3.0", "130.0", "0.65", (tenDaysAgo+1).format("dd-MMM-yyyy"), oneDayAgo.format("dd-MMM-yyyy")],
[getUserIdForDisplay(users[5]), getName(users[5], false), getName(users[5]), "tag10", "4.0", "140.0", "0.7", (tenDaysAgo).format("dd-MMM-yyyy"), oneDayAgo.format("dd-MMM-yyyy")],
["For All Dragons Only"],
]

Expand Down

0 comments on commit 8bfdd15

Please sign in to comment.