2019-11-26 10:50:38 +01:00
package moe.kageru.spektacles
2019-11-26 16:02:32 +01:00
import moe.kageru.spektacles.Node.Leaf
2019-11-26 10:50:38 +01:00
import kotlin.system.measureTimeMillis
fun main ( ) {
2019-11-26 13:01:29 +01:00
val time = measureTimeMillis {
spektacle ( )
2019-11-26 10:50:38 +01:00
}
2019-11-26 13:01:29 +01:00
println ( " Time spent: $time ms " )
2019-11-26 10:50:38 +01:00
}
2019-11-26 13:01:29 +01:00
fun spektacle ( ) {
IoHandler . readFile ( " test.log " )
2019-11-26 22:02:39 +01:00
. parse ( )
. filterUsers ( " kageru_ " ) . toList ( )
. filter { it . getMention ( ) . nonEmpty ( ) }
. toLeaf < String , ParsedLine > ( )
. groupBy { it . time . year . toString ( ) }
. groupBy { it . time . monthValue . toString ( ) }
. groupBy { it . getMention ( ) . orNull ( ) !! }
. countLeafs ( )
. sort ( )
//.grouped { it.time.year }
//.mapValues { it.value.groupBy { it.time.month } }.k()
//.ap(mapOf(
2019-11-26 16:02:32 +01:00
//1 to { lines: Map<Month, List<ParsedLine>> -> lines },
//2 to {lines -> lines.filterKeys { it < Month.APRIL }}
2019-11-26 22:02:39 +01:00
//).k())
//.let { it }
//.filterModes(UserMode.OP)
//.filterMonths(Month.APRIL)
//.heatMapByHour()
//.deepMap { it.message }
. let ( :: println )
2019-11-26 10:50:38 +01:00
}
2019-11-26 16:02:32 +01:00
2019-11-26 22:02:39 +01:00
private fun < K , T : Any > List < T > . toLeaf ( ) : Node < K , T > = Leaf ( this )