Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
mustafaozhan committed Oct 10, 2023
2 parents 140b890 + fc32957 commit 1cf9781
Show file tree
Hide file tree
Showing 58 changed files with 168 additions and 437 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,15 @@ jobs:
name: androidArtifacts

- name: Firebase App Distribution Google
uses: wzieba/Firebase-Distribution-Github-Action@v1.6.0
uses: wzieba/Firebase-Distribution-Github-Action@v1.7.0
with:
appId: ${{secrets.ANDROID_GOOGLE_FIREBASE_APP_ID}}
token: ${{secrets.FIREBASE_CLI_TOKEN}}
groups: QA
file: google/release/app-google-release.apk

- name: Firebase App Distribution Huawei
uses: wzieba/Firebase-Distribution-Github-Action@v1.6.0
uses: wzieba/Firebase-Distribution-Github-Action@v1.7.0
with:
appId: ${{secrets.ANDROID_HUAWEI_FIREBASE_APP_ID}}
token: ${{secrets.FIREBASE_CLI_TOKEN}}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ jobs:
with:
client-id: ${{secrets.HUAWEI_CLIENT_ID}}
client-key: ${{secrets.HUAWEI_CLIENT_KEY}}
app-id: "104920917"
app-id: ${{secrets.HUAWEI_APP_ID}}
file-extension: "aab"
file-path: "app-huawei-release.aab"
file-name: "app-huawei-release"
Expand Down Expand Up @@ -191,7 +191,7 @@ jobs:
path: artifact

- name: Deploy to Server
uses: easingthemes/[email protected].9
uses: easingthemes/[email protected].10
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ Open `CCC/ios/CCC.xcworkspace` with XCode after the packages are resolved you ca
After you run the app probably your all API calls will fail, it is expected since the private URLs are not shared publicly. If you want the test the app with real API calls, I have prepared a fake response. Please replace all the `getConversion` methods in

- `com.oztechan.ccc.common.core.network.api.backend.BackendApiImpl`
- `com.oztechan.ccc.common.core.network.api.free.FreeApiImpl`
- `com.oztechan.ccc.common.core.network.api.premium.PremiumApiImpl`

with below;
Expand Down
1 change: 0 additions & 1 deletion backend/app/backend-app.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ dependencies {
}

Modules.Backend.Service.apply {
implementation(project(free))
implementation(project(premium))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.oztechan.ccc.backend.app.module
import co.touchlab.kermit.Logger
import com.oztechan.ccc.backend.controller.api.di.backendControllerAPIModule
import com.oztechan.ccc.backend.controller.sync.di.backendControllerSyncModule
import com.oztechan.ccc.backend.service.free.di.backendServiceFreeModule
import com.oztechan.ccc.backend.service.premium.di.backendServicePremiumModule
import com.oztechan.ccc.common.core.database.di.commonCoreDatabaseModule
import com.oztechan.ccc.common.core.infrastructure.di.commonCoreInfrastructureModule
Expand All @@ -21,7 +20,6 @@ internal fun Application.koinModule() {
modules(
// region Backend modules
// Service modules
backendServiceFreeModule,
backendServicePremiumModule,
// Controller modules
backendControllerSyncModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ internal fun Application.syncModule() {
globalScope.launch(ioDispatcher) {
while (isActive) {
syncController.syncUnPopularCurrencies()
delay(8.hours.inWholeMilliseconds)
delay(12.hours.inWholeMilliseconds)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ internal fun Conversion.toExchangeRateAPIModel() = ExchangeRateAPIModel(
date,
ConversionAPIModel(
base, date, aed, afn, all, amd, ang, aoa, ars, aud, awg, azn, bam, bbd, bdt, bgn, bhd, bif,
bmd, bnd, bob, brl, bsd, btc, btn, bwp, byn, bzd, cad, cdf, chf, clf, clp, cnh, cny, cop,
crc, cuc, cup, cve, czk, djf, dkk, dop, dzd, egp, ern, etb, eur, fjd, fkp, gbp, gel, ggp,
ghs, gip, gmd, gnf, gtq, gyd, hkd, hnl, hrk, htg, huf, idr, ils, imp, inr, iqd, irr, isk,
jep, jmd, jod, jpy, kes, kgs, khr, kmf, kpw, krw, kwd, kyd, kzt, lak, lbp, lkr, lrd, lsl,
lyd, mad, mdl, mga, mkd, mmk, mnt, mop, mro, mru, mur, mvr, mwk, mxn, myr, mzn, nad, ngn,
nio, nok, npr, nzd, omr, pab, pen, pgk, php, pkr, pln, pyg, qar, ron, rsd, rub, rwf, sar,
sbd, scr, sdg, sek, sgd, shp, sll, sos, srd, ssp, std, stn, svc, syp, szl, thb, tjs, tmt,
tnd, top, `try`, ttd, twd, tzs, uah, ugx, usd, uyu, uzs, ves, vnd, vuv, wst, xaf, xag, xau,
xcd, xdr, xof, xpd, xpf, xpt, yer, zar, zmw, zwl
bmd, bnd, bob, brl, bsd, btn, bwp, byn, bzd, cad, cdf, chf, clp, cny, cop, crc, cup, cve,
czk, djf, dkk, dop, dzd, egp, ern, etb, eur, fjd, fkp, fok, gbp, gel, ggp, ghs, gip, gmd,
gnf, gtq, gyd, hkd, hnl, hrk, htg, huf, idr, ils, imp, inr, iqd, irr, isk, jep, jmd, jod,
jpy, kes, kgs, khr, kid, kmf, krw, kwd, kyd, kzt, lak, lbp, lkr, lrd, lsl, lyd, mad, mdl,
mga, mkd, mmk, mnt, mop, mru, mur, mvr, mwk, mxn, myr, mzn, nad, ngn, nio, nok, npr, nzd,
omr, pab, pen, pgk, php, pkr, pln, pyg, qar, ron, rsd, rub, rwf, sar, sbd, scr, sdg, sek,
sgd, shp, sle, sll, sos, srd, ssp, stn, syp, szl, thb, tjs, tmt, tnd, top, `try`, ttd, tvd,
twd, tzs, uah, ugx, usd, uyu, uzs, ves, vnd, vuv, wst, xaf, xcd, xdr, xof, xpf, yer, zar,
zmw, zwl,
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ object Fakes {
122.0, 123.0, 124.0, 125.0, 126.0, 127.0, 128.0, 129.0, 130.0, 131.0, 132.0, 133.0,
134.0, 135.0, 136.0, 137.0, 138.0, 139.0, 140.0, 141.0, 142.0, 143.0, 144.0, 145.0,
146.0, 147.0, 148.0, 149.0, 150.0, 151.0, 152.0, 153.0, 154.0, 155.0, 156.0, 157.0,
158.0, 159.0, 160.0, 161.0, 162.0, 163.0, 164.0, 165.0, 166.0, 167.0, 168.0, 169.0, 170.0
158.0, 159.0, 160.0, 161.0, 162.0
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,17 @@ internal class ConversionMapperTest {
assertEquals(Fakes.conversion.bob, response.conversion.bob)
assertEquals(Fakes.conversion.brl, response.conversion.brl)
assertEquals(Fakes.conversion.bsd, response.conversion.bsd)
assertEquals(Fakes.conversion.btc, response.conversion.btc)
assertEquals(Fakes.conversion.btn, response.conversion.btn)
assertEquals(Fakes.conversion.bwp, response.conversion.bwp)
assertEquals(Fakes.conversion.byn, response.conversion.byn)
assertEquals(Fakes.conversion.bzd, response.conversion.bzd)
assertEquals(Fakes.conversion.cad, response.conversion.cad)
assertEquals(Fakes.conversion.cdf, response.conversion.cdf)
assertEquals(Fakes.conversion.chf, response.conversion.chf)
assertEquals(Fakes.conversion.clf, response.conversion.clf)
assertEquals(Fakes.conversion.clp, response.conversion.clp)
assertEquals(Fakes.conversion.cnh, response.conversion.cnh)
assertEquals(Fakes.conversion.cny, response.conversion.cny)
assertEquals(Fakes.conversion.cop, response.conversion.cop)
assertEquals(Fakes.conversion.crc, response.conversion.crc)
assertEquals(Fakes.conversion.cuc, response.conversion.cuc)
assertEquals(Fakes.conversion.cup, response.conversion.cup)
assertEquals(Fakes.conversion.cve, response.conversion.cve)
assertEquals(Fakes.conversion.czk, response.conversion.czk)
Expand All @@ -62,6 +58,7 @@ internal class ConversionMapperTest {
assertEquals(Fakes.conversion.eur, response.conversion.eur)
assertEquals(Fakes.conversion.fjd, response.conversion.fjd)
assertEquals(Fakes.conversion.fkp, response.conversion.fkp)
assertEquals(Fakes.conversion.fok, response.conversion.fok)
assertEquals(Fakes.conversion.gbp, response.conversion.gbp)
assertEquals(Fakes.conversion.gel, response.conversion.gel)
assertEquals(Fakes.conversion.ggp, response.conversion.ggp)
Expand Down Expand Up @@ -90,8 +87,8 @@ internal class ConversionMapperTest {
assertEquals(Fakes.conversion.kes, response.conversion.kes)
assertEquals(Fakes.conversion.kgs, response.conversion.kgs)
assertEquals(Fakes.conversion.khr, response.conversion.khr)
assertEquals(Fakes.conversion.kid, response.conversion.kid)
assertEquals(Fakes.conversion.kmf, response.conversion.kmf)
assertEquals(Fakes.conversion.kpw, response.conversion.kpw)
assertEquals(Fakes.conversion.krw, response.conversion.krw)
assertEquals(Fakes.conversion.kwd, response.conversion.kwd)
assertEquals(Fakes.conversion.kyd, response.conversion.kyd)
Expand All @@ -109,7 +106,6 @@ internal class ConversionMapperTest {
assertEquals(Fakes.conversion.mmk, response.conversion.mmk)
assertEquals(Fakes.conversion.mnt, response.conversion.mnt)
assertEquals(Fakes.conversion.mop, response.conversion.mop)
assertEquals(Fakes.conversion.mro, response.conversion.mro)
assertEquals(Fakes.conversion.mru, response.conversion.mru)
assertEquals(Fakes.conversion.mur, response.conversion.mur)
assertEquals(Fakes.conversion.mvr, response.conversion.mvr)
Expand Down Expand Up @@ -143,13 +139,12 @@ internal class ConversionMapperTest {
assertEquals(Fakes.conversion.sek, response.conversion.sek)
assertEquals(Fakes.conversion.sgd, response.conversion.sgd)
assertEquals(Fakes.conversion.shp, response.conversion.shp)
assertEquals(Fakes.conversion.sle, response.conversion.sle)
assertEquals(Fakes.conversion.sll, response.conversion.sll)
assertEquals(Fakes.conversion.sos, response.conversion.sos)
assertEquals(Fakes.conversion.srd, response.conversion.srd)
assertEquals(Fakes.conversion.ssp, response.conversion.ssp)
assertEquals(Fakes.conversion.std, response.conversion.std)
assertEquals(Fakes.conversion.stn, response.conversion.stn)
assertEquals(Fakes.conversion.svc, response.conversion.svc)
assertEquals(Fakes.conversion.syp, response.conversion.syp)
assertEquals(Fakes.conversion.szl, response.conversion.szl)
assertEquals(Fakes.conversion.thb, response.conversion.thb)
Expand All @@ -159,6 +154,7 @@ internal class ConversionMapperTest {
assertEquals(Fakes.conversion.top, response.conversion.top)
assertEquals(Fakes.conversion.`try`, response.conversion.`try`)
assertEquals(Fakes.conversion.ttd, response.conversion.ttd)
assertEquals(Fakes.conversion.tvd, response.conversion.tvd)
assertEquals(Fakes.conversion.twd, response.conversion.twd)
assertEquals(Fakes.conversion.tzs, response.conversion.tzs)
assertEquals(Fakes.conversion.uah, response.conversion.uah)
Expand All @@ -171,14 +167,10 @@ internal class ConversionMapperTest {
assertEquals(Fakes.conversion.vuv, response.conversion.vuv)
assertEquals(Fakes.conversion.wst, response.conversion.wst)
assertEquals(Fakes.conversion.xaf, response.conversion.xaf)
assertEquals(Fakes.conversion.xag, response.conversion.xag)
assertEquals(Fakes.conversion.xau, response.conversion.xau)
assertEquals(Fakes.conversion.xcd, response.conversion.xcd)
assertEquals(Fakes.conversion.xdr, response.conversion.xdr)
assertEquals(Fakes.conversion.xof, response.conversion.xof)
assertEquals(Fakes.conversion.xpd, response.conversion.xpd)
assertEquals(Fakes.conversion.xpf, response.conversion.xpf)
assertEquals(Fakes.conversion.xpt, response.conversion.xpt)
assertEquals(Fakes.conversion.yer, response.conversion.yer)
assertEquals(Fakes.conversion.zar, response.conversion.zar)
assertEquals(Fakes.conversion.zmw, response.conversion.zmw)
Expand Down
1 change: 0 additions & 1 deletion backend/controller/sync/backend-controller-sync.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ dependencies {
}

Modules.Backend.Service.apply {
implementation(project(free))
implementation(project(premium))
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,80 +1,43 @@
package com.oztechan.ccc.backend.controller.sync

import co.touchlab.kermit.Logger
import com.oztechan.ccc.backend.service.free.FreeApiService
import com.oztechan.ccc.backend.service.premium.PremiumApiService
import com.oztechan.ccc.common.core.model.Conversion
import com.oztechan.ccc.common.core.model.CurrencyType
import com.oztechan.ccc.common.datasource.conversion.ConversionDataSource
import kotlinx.coroutines.delay
import kotlin.time.Duration.Companion.seconds

internal class SyncControllerImpl(
private val premiumApiService: PremiumApiService,
private val freeApiService: FreeApiService,
private val conversionDataSource: ConversionDataSource
) : SyncController {

override suspend fun syncPrimaryCurrencies() {
Logger.v { "SyncControllerImpl syncPrimaryCurrencies" }
CurrencyType.getPrimaryCurrencies().syncCrossAPI()
CurrencyType.getPrimaryCurrencies().syncCurrencies()
}

override suspend fun syncSecondaryCurrencies() {
Logger.v { "SyncControllerImpl syncSecondaryCurrencies" }
CurrencyType.getSecondaryCurrencies().syncCrossAPI()
CurrencyType.getSecondaryCurrencies().syncCurrencies()
}

override suspend fun syncTertiaryCurrencies() {
Logger.v { "SyncControllerImpl syncTertiaryCurrencies" }
CurrencyType.getTertiaryCurrencies().syncCrossAPI()
}

private suspend fun List<CurrencyType>.syncCrossAPI() = forEach { currencyType ->

delay(1.seconds.inWholeMilliseconds)

// non premium call for filling null values
runCatching { freeApiService.getConversion(currencyType.name) }
.onFailure { Logger.w(it) { it.message.toString() } }
.onSuccess { freeConversion ->

// premium api call
runCatching { premiumApiService.getConversion(currencyType.name) }
.onFailure { Logger.w(it) { it.message.toString() } }
.onSuccess { premiumConversion ->
conversionDataSource.insertConversion(
premiumConversion.fillMissingRatesWith(freeConversion)
)
}
}
CurrencyType.getTertiaryCurrencies().syncCurrencies()
}

override suspend fun syncUnPopularCurrencies() {
Logger.v { "SyncControllerImpl syncUnPopularCurrencies" }
CurrencyType.getNonPopularCurrencies().syncCurrencies()
}

CurrencyType.getNonPopularCurrencies().forEach { currencyType ->

delay(1.seconds.inWholeMilliseconds)
private suspend fun List<CurrencyType>.syncCurrencies() = forEach { currencyType ->

runCatching { freeApiService.getConversion(currencyType.name) }
.onFailure { Logger.w(it) { it.message.toString() } }
.onSuccess { conversionDataSource.insertConversion(it) }
}
}
delay(1.seconds.inWholeMilliseconds)

// unsupported currencies by premium API
private fun Conversion.fillMissingRatesWith(freeConversion: Conversion) = apply {
btc = freeConversion.btc
clf = freeConversion.clf
cnh = freeConversion.cnh
kpw = freeConversion.kpw
mro = freeConversion.mro
std = freeConversion.std
svc = freeConversion.svc
xag = freeConversion.xag
xau = freeConversion.xau
xpd = freeConversion.xpd
xpt = freeConversion.xpt
runCatching { premiumApiService.getConversion(currencyType.name) }
.onFailure { Logger.w(it) { it.message.toString() } }
.onSuccess { conversionDataSource.insertConversion(it) }
}
}
26 changes: 0 additions & 26 deletions backend/service/free/backend-service-free.gradle.kts

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 1cf9781

Please sign in to comment.