Skip to content

Commit

Permalink
Merge 8ec2563 into cf9c152
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregor Billing committed Feb 7, 2021
2 parents cf9c152 + 8ec2563 commit c6f2cd4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ object WCIFScrambleMatcher {
}

val matchedRound = findRound(events, activity)
?: return activity

val actGroup = activity.activityCode.groupNumber

// uh oh. no child activities where there should be some.
Expand Down Expand Up @@ -305,11 +307,10 @@ object WCIFScrambleMatcher {
return activity.copy(scrambleSetId = scrambleSet.id)
}

private fun findRound(events: List<Event>, activity: Activity): Round {
private fun findRound(events: List<Event>, activity: Activity): Round? {
return events
.filter { it.id == activity.activityCode.eventId }
.flatMap { it.rounds }
.find { it.idCode.isParentOf(activity.activityCode) }
?: ScrambleMatchingException.error("An activity of the schedule did not match an event: $activity")
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.worldcubeassociation.tnoodle.server.webscrambles.zip.folder

import org.slf4j.LoggerFactory
import org.worldcubeassociation.tnoodle.server.model.EventData
import org.worldcubeassociation.tnoodle.server.webscrambles.Translate
import org.worldcubeassociation.tnoodle.server.webscrambles.pdf.FmcGenericSolutionSheet
Expand Down Expand Up @@ -77,10 +78,20 @@ data class PrintingFolder(val uniqueTitles: Map<String, ScrambleDrawingData>, va
}

if (wcifSchedule.isNotEmpty()) {
val orderedScramblesFolder = OrderedScramblesFolder(globalTitle, scrambleDrawingData)
val orderedScramblesNode = orderedScramblesFolder.assemble(wcifSchedule, generationDate, versionTag)
val drawingScrambleSets = scrambleDrawingData.scrambleSheets.map { it.scrambleSet }

folder(orderedScramblesNode)
if (wcifSchedule.containsAll(drawingScrambleSets)) {
val orderedScramblesFolder = OrderedScramblesFolder(globalTitle, scrambleDrawingData)
val orderedScramblesNode = orderedScramblesFolder.assemble(wcifSchedule, generationDate, versionTag)

folder(orderedScramblesNode)
} else {
val requiredIds = drawingScrambleSets.map { it.id }
val unmatchedActivities = wcifSchedule.leafActivities
.filter { it.scrambleSetId !in requiredIds }

LOGGER.warn("Skipping OrderedScrambles because there are unmatched activities: $unmatchedActivities")
}
}

val safeGlobalTitle = globalTitle.toFileSafeString()
Expand All @@ -92,8 +103,17 @@ data class PrintingFolder(val uniqueTitles: Map<String, ScrambleDrawingData>, va
}

companion object {
val LOGGER = LoggerFactory.getLogger(PrintingFolder::class.java)

private fun Schedule.isNotEmpty() = leafActivities.isNotEmpty()

private fun Schedule.containsAll(scrambleSets: Collection<ScrambleSet>): Boolean {
val scheduleMatchedIds = allActivities.mapNotNull { it.scrambleSetId }
val requiredIds = scrambleSets.map { it.id }

return scheduleMatchedIds.containsAll(requiredIds)
}

val FMC_LOCALES_BY_TAG = Translate.TRANSLATED_LOCALES.associateBy { it.toLanguageTag() }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ object APIIntegrationTest {
fun `test that every upcoming competition produces some output without error`() {
val competitionsLimit = 10
val upcomingRaw = URL("https://www.worldcubeassociation.org/api/v0/competitions/").readText()
val upcomingComps = JsonConfig.SERIALIZER.decodeFromString(ListSerializer(UpcomingCompetition.serializer()), upcomingRaw).shuffled().take(competitionsLimit)
val upcomingComps = JsonConfig.SERIALIZER.decodeFromString(ListSerializer(UpcomingCompetition.serializer()), upcomingRaw).shuffled()//.take(competitionsLimit)

val generationDate = LocalDateTime.now()
val testCompCount = upcomingComps.size

for ((i, upcomingComp) in upcomingComps.withIndex()) {
if (upcomingComp.id != "ShowgroundShowdown2021") {
continue
}

val id = upcomingComp.id
println("(${i+1}/$testCompCount) Testing ZIP builder for '${upcomingComp.name}' (id $id)")

Expand Down

0 comments on commit c6f2cd4

Please sign in to comment.