feat: improved SubscriptionRepository

This commit is contained in:
moonleay 2023-10-15 13:18:05 +02:00
parent 5a39f49824
commit 613d16ef62

View file

@ -46,6 +46,27 @@ object SubscriptionRepository {
return dataList
}
fun getAllChannel(channelId: Long): List<SubscriptionData> {
val dataList = mutableListOf<SubscriptionData>()
transaction {
SubscriptionsTable.select {
SubscriptionsTable.channelId eq channelId
}.forEach {
dataList.add(
SubscriptionData(
it[SubscriptionsTable.id],
it[SubscriptionsTable.serverId],
it[SubscriptionsTable.channelId],
EmbedUtil.getColorFromString(it[SubscriptionsTable.subscriptionColor]),
it[SubscriptionsTable.subscriptionName],
it[SubscriptionsTable.feedUrl]
)
)
}
}
return dataList
}
fun get(channelId: Long, feedName: String): SubscriptionData? {
var data: SubscriptionData? = null
@ -66,6 +87,16 @@ object SubscriptionRepository {
return data
}
fun existsWithUrl(channelId: Long, feedUrl: String): Boolean {
var exists = false
transaction {
exists = SubscriptionsTable.select {
(SubscriptionsTable.channelId eq channelId) and (SubscriptionsTable.feedUrl eq feedUrl)
}.count() > 0
}
return exists
}
fun exists(channelId: Long, feedName: String): Boolean {
var exists = false
transaction {