Formatting

This commit is contained in:
Matt Soucy 2020-08-18 21:01:00 -04:00
parent b85099fbbd
commit 1159b87a53
10 changed files with 240 additions and 258 deletions

View File

@ -1,14 +1,13 @@
package me.msoucy.gbat
import java.io.File
import org.jetbrains.exposed.sql.*
import org.jetbrains.exposed.sql.transactions.transaction
import me.msoucy.gbat.models.CondensedAnalysis
import me.msoucy.gbat.models.Condensation
import me.msoucy.gbat.models.CondensedAnalysis
import me.msoucy.gbat.models.KnowledgeModel
import me.msoucy.gbat.models.LineModel
import me.msoucy.gbat.models.RiskModel
import org.jetbrains.exposed.sql.*
import org.jetbrains.exposed.sql.transactions.transaction
fun analyze(
riskModel: RiskModel,
@ -26,7 +25,7 @@ fun analyze(
changes.forEach { change ->
changesProcessed++
if (changesProcessed % 1000 == 0 && verbose) {
System.err.println("Analyzer applied change #${changesProcessed}")
System.err.println("Analyzer applied change #$changesProcessed")
}
lineModel.apply(change.eventType, change.lineNum, change.lineVal ?: "")
knowledgeModel.apply(change.eventType, author, change.lineNum)

View File

@ -1,10 +1,10 @@
package me.msoucy.gbat
import me.msoucy.gbat.models.RiskModel
import me.msoucy.gbat.models.SummaryModel
import com.xenomachina.argparser.ArgParser
import com.xenomachina.argparser.InvalidArgumentException
import com.xenomachina.argparser.default
import com.xenomachina.argparser.mainBody
import java.io.File
import java.util.concurrent.Executors
import kotlin.math.pow
import kotlin.system.exitProcess
import kotlin.text.Regex
@ -12,14 +12,9 @@ import kotlin.text.RegexOption
import kotlin.text.startsWith
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
import com.xenomachina.argparser.ArgParser
import com.xenomachina.argparser.InvalidArgumentException
import com.xenomachina.argparser.default
import com.xenomachina.argparser.mainBody
import me.msoucy.gbat.models.RiskModel
import me.msoucy.gbat.models.SummaryModel
import org.jetbrains.exposed.sql.*
import org.jetbrains.exposed.sql.transactions.transaction
val REALLY_LONG_TIME = 864000
val DEFAULT_INTERESTING_RES = mutableListOf(
@ -136,13 +131,8 @@ fun main(args: Array<String>) = mainBody {
val riskModel = RiskModel(riskThresh, default_bus_risk, risk_file, departed)
val dbFname = File(outDir, "summary.db")
dbFname.delete();
dbFname.delete()
val summaryDb = Database.connect("jdbc:sqlite:${dbFname.absolutePath}", driver = "org.sqlite.JDBC")
transaction(summaryDb) {
addLogger(StdOutSqlLogger)
// exec("PRAGMA journal_mode = OFF")
// exec("PRAGMA synchronous = OFF")
}
val summaryModel = SummaryModel(summaryDb)
runBlocking {
@ -160,6 +150,6 @@ fun main(args: Array<String>) = mainBody {
renderSummary(projectRootFile, summaryModel, outDir)
// Render summary
System.err.println("Done, summary is in ${outDir}/index.html")
System.err.println("Done, summary is in $outDir/index.html")
}
}

View File

@ -3,7 +3,6 @@ package me.msoucy.gbat
import java.io.File
import kotlin.math.abs
import kotlin.math.max
import me.msoucy.gbat.models.ChangeType
import me.msoucy.gbat.models.Event
@ -14,14 +13,16 @@ data class HistoryItem(
val authorDiffs: List<Pair<String, List<Event>>>
)
fun parseHistory(repo : GitRepo,
fun parseHistory(
repo: GitRepo,
projectRoot: File,
fname: File,
verbose : Boolean = false) : HistoryItem {
verbose: Boolean = false
): HistoryItem {
val entries = repo.log(fname)
val repoRoot = repo.root()
if (verbose) {
System.err.println("Parsing history for ${fname}")
System.err.println("Parsing history for $fname")
}
return HistoryItem(repoRoot, projectRoot, fname,
entries.map { (author, diff) ->

View File

@ -1,20 +1,18 @@
package me.msoucy.gbat.models
import java.io.File
import java.nio.file.Path
import java.nio.file.Paths
import me.msoucy.gbat.copyOf
import me.msoucy.gbat.mutableCopyOf
import org.jetbrains.exposed.dao.id.IntIdTable
import org.jetbrains.exposed.sql.*
import org.jetbrains.exposed.sql.transactions.transaction
import me.msoucy.gbat.copyOf
import me.msoucy.gbat.mutableCopyOf
class KnowledgeModel(val db: Database, val constant: Double, val riskModel: RiskModel) {
class KnowledgeAcct(var knowledgeAcctId : Int,
class KnowledgeAcct(
var knowledgeAcctId: Int,
var authors: List<String>,
var authorsStr : String)
var authorsStr: String
)
object AuthorsTable : IntIdTable("authors", "authorid") {
val author = text("author").uniqueIndex("authors_idx")

View File

@ -1,13 +1,5 @@
package me.msoucy.gbat.models
import java.io.File
import java.nio.file.Path
import java.nio.file.Paths
import kotlin.io.forEachLine
import org.jetbrains.exposed.dao.id.IntIdTable
import org.jetbrains.exposed.sql.*
import org.jetbrains.exposed.sql.transactions.transaction
class LineModel() {
inner class Line(var num: Int, var text: String)
val model = mutableSetOf<Line>()

View File

@ -3,10 +3,12 @@ package me.msoucy.gbat.models
import java.io.File
import kotlin.io.forEachLine
class RiskModel(val threshold : Double,
class RiskModel(
val threshold: Double,
val default: Double,
val busRiskFile: File?,
val departedFile : File?) {
val departedFile: File?
) {
val departed = mutableSetOf<String>()
val risks = mutableMapOf<String, Double>().withDefault { default }