Fixes
This commit is contained in:
parent
2b4d799d4a
commit
e94b2e1d4b
@ -136,6 +136,7 @@ fun main(args: Array<String>) = mainBody {
|
|||||||
val riskModel = RiskModel(riskThresh, default_bus_risk, risk_file, departed)
|
val riskModel = RiskModel(riskThresh, default_bus_risk, risk_file, departed)
|
||||||
|
|
||||||
val dbFname = File(outDir, "summary.db")
|
val dbFname = File(outDir, "summary.db")
|
||||||
|
dbFname.delete();
|
||||||
val summaryDb = Database.connect("jdbc:sqlite:${dbFname.absolutePath}", driver="org.sqlite.JDBC")
|
val summaryDb = Database.connect("jdbc:sqlite:${dbFname.absolutePath}", driver="org.sqlite.JDBC")
|
||||||
transaction(summaryDb) {
|
transaction(summaryDb) {
|
||||||
addLogger(StdOutSqlLogger)
|
addLogger(StdOutSqlLogger)
|
||||||
|
@ -98,13 +98,27 @@ fun diffWalk(diff : Diff) : List<Event> {
|
|||||||
val maxLen = max(oldLen, newLen)
|
val maxLen = max(oldLen, newLen)
|
||||||
var lineNum = hunk.lineNum
|
var lineNum = hunk.lineNum
|
||||||
|
|
||||||
for (i in 0..maxLen) {
|
for (i in 0 until maxLen) {
|
||||||
if(i < oldLen && i < newLen) {
|
if(i < oldLen && i < newLen) {
|
||||||
events += Event(
|
events += Event(
|
||||||
ChangeType.Change,
|
ChangeType.Change,
|
||||||
lineNum,
|
lineNum,
|
||||||
hunk.newLines[i].substring(1)
|
hunk.newLines[i].substring(1)
|
||||||
)
|
)
|
||||||
|
lineNum++
|
||||||
|
} else if(i < oldLen) {
|
||||||
|
events += Event(
|
||||||
|
ChangeType.Remove,
|
||||||
|
lineNum,
|
||||||
|
null
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
events += Event(
|
||||||
|
ChangeType.Add,
|
||||||
|
lineNum,
|
||||||
|
hunk.newLines[i].substring(1)
|
||||||
|
)
|
||||||
|
lineNum++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ class GitRepo(val projectRoot : File, val git_exe : String) {
|
|||||||
|
|
||||||
private fun parseAuthor(header : List<String>) : String {
|
private fun parseAuthor(header : List<String>) : String {
|
||||||
val segs = header.getOrNull(1)?.trim()?.split("\\s+".toRegex())?: listOf()
|
val segs = header.getOrNull(1)?.trim()?.split("\\s+".toRegex())?: listOf()
|
||||||
return segs.subList(1, segs.size - 2).joinToString(" ")
|
return segs.subList(1, segs.size - 1).joinToString(" ")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun splitEntryHeader(entry : String) : Pair<List<String>, List<String>> {
|
private fun splitEntryHeader(entry : String) : Pair<List<String>, List<String>> {
|
||||||
|
@ -267,7 +267,9 @@ class SummaryModel(val db : Database) {
|
|||||||
|
|
||||||
fun fileSummary(fileId : Int) = transaction(db) {
|
fun fileSummary(fileId : Int) = transaction(db) {
|
||||||
var fileTree = FileTree()
|
var fileTree = FileTree()
|
||||||
lineAllocationGroups.select {
|
lineAllocationGroups
|
||||||
|
.slice(AllocationsTable.knowledge.sum(), AllocationsTable.risk.sum(), AllocationsTable.orphaned.sum(), AuthorsGroupsTable.authors)
|
||||||
|
.select {
|
||||||
LinesTable.fileid eq fileId
|
LinesTable.fileid eq fileId
|
||||||
}.groupBy(AuthorsGroupsTable.id).forEach { row ->
|
}.groupBy(AuthorsGroupsTable.id).forEach { row ->
|
||||||
val authors = row[AuthorsGroupsTable.authors]
|
val authors = row[AuthorsGroupsTable.authors]
|
||||||
@ -276,7 +278,9 @@ class SummaryModel(val db : Database) {
|
|||||||
Join(lineAllocations, FilesTable,
|
Join(lineAllocations, FilesTable,
|
||||||
JoinType.LEFT,
|
JoinType.LEFT,
|
||||||
LinesTable.fileid, FilesTable.id
|
LinesTable.fileid, FilesTable.id
|
||||||
).select { LinesTable.fileid eq fileId }
|
)
|
||||||
|
.slice(AllocationsTable.knowledge.sum(), AllocationsTable.risk.sum(), AllocationsTable.orphaned.sum())
|
||||||
|
.select { LinesTable.fileid eq fileId }
|
||||||
.first().let { row ->
|
.first().let { row ->
|
||||||
fileTree.stats = Statistics(row)
|
fileTree.stats = Statistics(row)
|
||||||
}
|
}
|
||||||
@ -287,13 +291,17 @@ class SummaryModel(val db : Database) {
|
|||||||
.map { it[LinesTable.id].value }
|
.map { it[LinesTable.id].value }
|
||||||
.forEach { lineId ->
|
.forEach { lineId ->
|
||||||
val lineDict = LineDict()
|
val lineDict = LineDict()
|
||||||
lineAllocationGroups.select {
|
lineAllocationGroups
|
||||||
|
.slice(AllocationsTable.knowledge.sum(), AllocationsTable.risk.sum(), AllocationsTable.orphaned.sum(), AuthorsGroupsTable.authors)
|
||||||
|
.select {
|
||||||
LinesTable.id eq lineId
|
LinesTable.id eq lineId
|
||||||
}.groupBy(AuthorsGroupsTable.id).forEach { lineRow ->
|
}.groupBy(AuthorsGroupsTable.id).forEach { lineRow ->
|
||||||
lineDict.authorRisks[lineRow[AuthorsGroupsTable.authors]] = Statistics(lineRow)
|
lineDict.authorRisks[lineRow[AuthorsGroupsTable.authors]] = Statistics(lineRow)
|
||||||
}
|
}
|
||||||
|
|
||||||
lineAllocations.select {
|
lineAllocations
|
||||||
|
.slice(AllocationsTable.knowledge.sum(), AllocationsTable.risk.sum(), AllocationsTable.orphaned.sum())
|
||||||
|
.select {
|
||||||
LinesTable.id eq lineId
|
LinesTable.id eq lineId
|
||||||
}.first().let {
|
}.first().let {
|
||||||
lineDict.stats = Statistics(it)
|
lineDict.stats = Statistics(it)
|
||||||
@ -412,7 +420,7 @@ class SummaryModel(val db : Database) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun findOrCreateDir(dirname : String, projectId : Int, parentDirId : Int) : Int = transaction(db) {
|
private fun findOrCreateDir(dirname : String, projectId : Int, parentDirId : Int) : Int = transaction(db) {
|
||||||
DirsTable.insertIgnoreAndGetId {
|
DirsTable.insertIgnore {
|
||||||
it[dir] = dirname
|
it[dir] = dirname
|
||||||
it[parentdirid] = parentDirId
|
it[parentdirid] = parentDirId
|
||||||
it[projectid] = projectId
|
it[projectid] = projectId
|
||||||
@ -422,8 +430,8 @@ class SummaryModel(val db : Database) {
|
|||||||
DirsTable.parentdirid eq parentDirId
|
DirsTable.parentdirid eq parentDirId
|
||||||
DirsTable.projectid eq projectId
|
DirsTable.projectid eq projectId
|
||||||
}.map {
|
}.map {
|
||||||
it[DirsTable.id]
|
it[DirsTable.id].value
|
||||||
}.first().value
|
}.first()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun splitAllDirs(dirname : File) = dirname.toPath().iterator().asSequence().toList()
|
private fun splitAllDirs(dirname : File) = dirname.toPath().iterator().asSequence().toList()
|
||||||
|
Loading…
Reference in New Issue
Block a user