by Mark Abersold
This is the result of a question I asked myself one day: "What is the most hopeless sports town in North America?" I decided to gather the data together and calculate it.
Java 17 - if you are using IntelliJ, check under Settings -> Build, Execution & Deployment -> Build Tools -> Gradle. Check Gradle JVM to make sure you have a compatible Java SDK selected.
There are two components that need to run: the API and UI. The API is a KTOR-based application written in Kotlin and running on the Java virtual machine. The UI is a React-based application using Material UI.
Please note, the first time you run the API, you will need to generate and seed the database.
Open src/main/kotlin/mabersold/Application.kt
. Just click the "run" button next to main
. Be sure to go to your run configurations and save the new configuration that was just generated.
This is built in Kotlin using the KTor framework. You can build it and run it using gradle.
gradle build
gradle run
Or, if you don't have gradle installed, using the handy gradlew files that are included.
gradlew build
gradlew run
Once built, direct your browser to http://localhost:8080 to see the output.
You will need to generate the database schema with a command line argument. You only need to use this the first time you run the application, or if you ever want to reset the database.
Run with the command line argument --createSchema
to create the database schema. This will create an H2 database file called maximum_futility.db
in the build directory.
gradle run --args="--createSchema"
If you are running in IntelliJ IDEA, edit your run configuration and add --createSchema
to your program arguments.
In addition to creating the database, this will also seed the database with the actual sports result data.
You will need node and npm to run the UI. Navigate to the directory mf-web-ui
and run npm install
to install dependencies. Then, to run the UI, just run npm start
.
The data is stored in an H2 database. Although the main output is by city, the data is stored by franchise. When you load the main page, it maps the franchise data to city data. It also performs all the necessary calculations to give you the output.
Look under src/main/resources/data for the CSV files that are used to populate the database.
Please file an issue to correct it! Or, if you're feeling confident, you can make the change yourself and open a pull request.