in intellij-plugin/educational-core/src/com/jetbrains/edu/learning/statistics/EduLaunchesReporter.kt [27:57]
fun sendStats(course: Course) {
if (ApplicationManager.getApplication().isUnitTestMode) {
return
}
val properties = PropertiesComponent.getInstance()
val lastUpdate = properties.getLong(LAST_UPDATE, 0L)
val shouldUpdate = lastUpdate == 0L || System.currentTimeMillis() - lastUpdate > TimeUnit.DAYS.toMillis(1)
if (shouldUpdate) {
properties.setValue(LAST_UPDATE, System.currentTimeMillis().toString())
val url = getUpdateUrl(course)
ApplicationManager.getApplication().executeOnPooledThread {
try {
HttpRequests.request(url).connect {
try {
JDOMUtil.load(it.reader)
}
catch (e: JDOMException) {
LOG.warn(e)
}
LOG.info("updated: $url")
}
}
catch (ignored: UnknownHostException) {
// No internet connections, no need to log anything
}
catch (e: IOException) {
LOG.warn(e)
}
}
}
}