the Kotlin team is back at full speed after tough ...
# feed
p
the Kotlin team is back at full speed after tough beginning of the year đŸ’Ș
📈 9
❀ 2
🎉 5
source (save as .main.kts file):
Copy code
#!/usr/bin/env kotlin

@file:DependsOn("org.eclipse.jgit:org.eclipse.jgit:6.5.0.202303070854-r")
@file:DependsOn("org.jetbrains.lets-plot:lets-plot-kotlin-jvm:4.3.0")
@file:DependsOn("org.jetbrains.lets-plot:lets-plot-image-export:3.1.0")

import org.eclipse.jgit.api.Git
import org.jetbrains.letsPlot.Stat
import org.jetbrains.letsPlot.export.ggsave
import org.jetbrains.letsPlot.geom.geomBar
import org.jetbrains.letsPlot.ggsize
import org.jetbrains.letsPlot.label.ggtitle
import org.jetbrains.letsPlot.letsPlot
import java.io.File
import java.text.SimpleDateFormat
import java.time.Instant
import java.util.Date

val repo = Git.open(File("...path.to.cloned.Kotlin.repo..."))
var formatter = SimpleDateFormat("yyyy-MM-dd")

val datesInGroups = repo.log().call().map { commit ->
    val instant = Instant.ofEpochSecond(commit.commitTime.toLong())
    val date = Date.from(instant)
    formatter.format(date)
}.groupingBy { it.substring(0..6) }
    .eachCount()

val plotData = mapOf(
    "yearMonth" to datesInGroups.keys.sorted(),
    "count" to datesInGroups.entries.sortedBy { it.key }.map { it.value },
)

var plot = letsPlot(plotData) +
        geomBar(stat = Stat.identity) { x = "yearMonth"; y = "count" } +
        ggsize(1920, 1080) +
        ggtitle("Number of commits monthly in JetBrains/kotlin repository")

ggsave(plot, "Kotlin commit history.png")
b
Do you have that file hosted anywhere? For folks that have ktx installed it could be as simple as running
ktx run <https://domain.com/path/to/file.main.kts|https://domain.com/path/to/file.main.kts>
p
nope, not hosting anywhere yet, but I can put it in some repo today
đŸ‘đŸŸ 1
👍 1
b
Can you attach it as file in this thread? I want to try something out 😀
p
if you want to try running from Slack’s hosting, I realized that I need to add a piece that clones the repo. The script now assumes the repo is cloned and you need to put a path in place of
...<http://path.to|path.to>.cloned.Kotlin.repo...
b
Ah 😀
p
Copy code
ktx run <https://raw.githubusercontent.com/krzema12/PersonalConfigs/master/scripts/PlotCommitsCount.main.kts> /path/to/your/repo
👍 1
ktx works! 🚀
🎉 3
s
the last time I did plots, I was still in university and used Matlab 😆 I completely missed lets-plot-kotlin đŸ˜źđŸ€©
👍 2