mirror of
https://github.com/Shabinder/SpotiFlyer.git
synced 2024-11-26 02:24:31 +01:00
Add Matomo Downloads in Download Card Count
This commit is contained in:
parent
8ae683585d
commit
796acd6c3b
@ -0,0 +1,3 @@
|
|||||||
|
package models.matomo
|
||||||
|
|
||||||
|
typealias MatomoDownloads = ArrayList<MatomoDownloadsItem>
|
@ -0,0 +1,12 @@
|
|||||||
|
package models.matomo
|
||||||
|
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class MatomoDownloadsItem(
|
||||||
|
val idsubdatatable: Int = 0,
|
||||||
|
val label: String = "com.shabinder.spotiflyer",
|
||||||
|
val nb_hits: Int = 0,
|
||||||
|
val nb_visits: Int = 0,
|
||||||
|
val sum_time_spent: Int = 0
|
||||||
|
)
|
@ -4,6 +4,7 @@ import common.*
|
|||||||
import io.ktor.client.features.*
|
import io.ktor.client.features.*
|
||||||
import io.ktor.client.request.*
|
import io.ktor.client.request.*
|
||||||
import io.ktor.client.statement.*
|
import io.ktor.client.statement.*
|
||||||
|
import models.matomo.MatomoDownloads
|
||||||
import utils.RETRY_LIMIT_EXHAUSTED
|
import utils.RETRY_LIMIT_EXHAUSTED
|
||||||
import utils.debug
|
import utils.debug
|
||||||
|
|
||||||
@ -17,7 +18,7 @@ internal suspend fun updateDownloadCards(
|
|||||||
fileName = "README.md"
|
fileName = "README.md"
|
||||||
).decryptedContent
|
).decryptedContent
|
||||||
|
|
||||||
val totalDownloads:Int = GithubService.getGithubRepoReleasesInfo(
|
var totalDownloads:Int = GithubService.getGithubRepoReleasesInfo(
|
||||||
secrets.ownerName,
|
secrets.ownerName,
|
||||||
secrets.repoName
|
secrets.repoName
|
||||||
).let { allReleases ->
|
).let { allReleases ->
|
||||||
@ -35,13 +36,14 @@ internal suspend fun updateDownloadCards(
|
|||||||
return@let totalCount
|
return@let totalCount
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add Matomo Downloads
|
||||||
|
client.get<MatomoDownloads>("https://kind-grasshopper-73.telebit.io/matomo/?module=API&method=Actions.getDownloads&idSite=1&period=year&date=today&format=JSON&token_auth=anonymous").forEach {
|
||||||
|
totalDownloads += it.nb_hits
|
||||||
|
}
|
||||||
|
|
||||||
return getUpdatedContent(
|
return getUpdatedContent(
|
||||||
oldContent,
|
oldContent,
|
||||||
"""
|
"""<a href="https://github.com/Shabinder/SpotiFlyer/releases/latest"><img src="${getDownloadCard(totalDownloads)}" height="125" width="280" alt="Total Downloads"></a>""",
|
||||||
<a href="https://github.com/Shabinder/SpotiFlyer/releases/latest">
|
|
||||||
<img src="${getDownloadCard(totalDownloads)}" height="125" width="280" alt="Total Downloads">
|
|
||||||
</a>""".trim().trimIndent(),
|
|
||||||
secrets.tagName
|
secrets.tagName
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user