-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
80a0ba2
commit 4023899
Showing
8 changed files
with
135 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
HaveAMagicalDay/app/src/main/kotlin/com/michaeltchuang/cron/utils/Constants.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
package com.michaeltchuang.cron.utils | ||
|
||
object Constants { | ||
const val ALGOD_API_ADDR = "https://testnet-algorand.api.purestake.io/ps2" | ||
const val ALGOD_API_ADDR = "https://testnet-api.algonode.cloud" | ||
const val ALGOD_PORT = 443 | ||
const val ALGOD_API_TOKEN_KEY = "X-API-Key" | ||
const val ALGOD_API_TOKEN = "B3SU4KcVKi94Jap2VXkK83xx38bsv95K5UZm2lab" | ||
const val COINFLIP_APP_ID_TESTNET = 115885218L | ||
const val TEST_ADDRESS = "LMRZRYVM3EXPLNGW7VRIIZ4CQKW5IVPDDXCKFZKCLJF35CNJMEKJNUTJIQ" | ||
const val TEST_PASSPHRASE = "swing enrich bring novel oak gadget barely deer bottom brown where fossil can intact cactus rail pumpkin cost actual famous gauge deny pink above rubber" | ||
const val DEFAULT_MICRO_ALGO_TRANSFER_AMOUNT = 888 | ||
const val DEFAULT_VLOG_TIME = "T08:08:08.888" | ||
const val VOL2_START_DATE = "2023-02-20" | ||
const val HISTORY_CSV_FILE = "greeting-history.log" | ||
} |
26 changes: 26 additions & 0 deletions
26
HaveAMagicalDay/app/src/main/kotlin/com/michaeltchuang/cron/utils/DateUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.michaeltchuang.cron.utils | ||
|
||
import java.time.Duration | ||
import java.time.LocalDateTime | ||
|
||
class DateUtils() { | ||
fun calculateVlogNum(returnEighth: Boolean, startDateStr: String, endDateStr: String) : Int { | ||
val from = LocalDateTime.parse(startDateStr + Constants.DEFAULT_VLOG_TIME) | ||
val to = LocalDateTime.parse(endDateStr + Constants.DEFAULT_VLOG_TIME) | ||
val days = Duration.between(from, to).toDays() | ||
println("${days} days between ${startDateStr} and ${endDateStr}") | ||
|
||
if(returnEighth) { | ||
return (days / 7 * 8).toInt() | ||
} else if (days % 7 == 0L) { | ||
return ((days / 7 * 8) - 1).toInt() | ||
} else { | ||
return ((days / 7 * 8) + (days % 7)).toInt() | ||
} | ||
} | ||
|
||
fun calculateVolumeNum(returnEighth: Boolean, startDateStr: String, endDateStr: String) : Int { | ||
//hardcode to volume 2 for now | ||
return 2 | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
HaveAMagicalDay/app/src/test/kotlin/com/michaeltchuang/cron/UnitTests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package com.michaeltchuang.cron | ||
|
||
import com.michaeltchuang.cron.data.AlgorandRepository | ||
import com.michaeltchuang.cron.utils.Constants | ||
import com.michaeltchuang.cron.utils.DateUtils | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
|
||
class UnitTests { | ||
val VOL2_VLOG1_DATE = "2023-02-21" | ||
val VOL2_VLOG22_DATE = "2023-03-12" | ||
val VOL2_VLOG23_DATE = "2023-03-13" | ||
val VOL2_VLOG24_DATE = "2023-03-13" | ||
val VOL2_VLOG25_DATE = "2023-03-14" | ||
val VOL2_VLOG31_DATE = "2023-03-20" | ||
val VOL2_VLOG39_DATE = "2023-03-27" | ||
val VOL2_VLOG42_DATE = "2023-03-29" | ||
|
||
@Test | ||
fun vlog1() { | ||
val output = DateUtils().calculateVlogNum(false, Constants.VOL2_START_DATE, VOL2_VLOG1_DATE) | ||
assertEquals(output, 1) | ||
} | ||
|
||
@Test | ||
fun vlog22() { | ||
val output = DateUtils().calculateVlogNum(false, Constants.VOL2_START_DATE, VOL2_VLOG22_DATE) | ||
assertEquals(22, output) | ||
} | ||
|
||
@Test | ||
fun vlog23() { | ||
val output = DateUtils().calculateVlogNum(false, Constants.VOL2_START_DATE, VOL2_VLOG23_DATE) | ||
assertEquals(23, output) | ||
} | ||
|
||
@Test | ||
fun vlog24() { | ||
val output = DateUtils().calculateVlogNum(true, Constants.VOL2_START_DATE, VOL2_VLOG24_DATE) | ||
assertEquals(24, output) | ||
} | ||
|
||
@Test | ||
fun vlog25() { | ||
val output = DateUtils().calculateVlogNum(false, Constants.VOL2_START_DATE, VOL2_VLOG25_DATE) | ||
assertEquals(25, output) | ||
} | ||
|
||
@Test | ||
fun vlog31() { | ||
val output = DateUtils().calculateVlogNum(false, Constants.VOL2_START_DATE, VOL2_VLOG31_DATE) | ||
assertEquals(31, output) | ||
} | ||
|
||
@Test | ||
fun vlog39() { | ||
val output = DateUtils().calculateVlogNum(false, Constants.VOL2_START_DATE, VOL2_VLOG39_DATE) | ||
assertEquals(39, output) | ||
} | ||
|
||
@Test | ||
fun vlog42() { | ||
val output = DateUtils().calculateVlogNum(false, Constants.VOL2_START_DATE, VOL2_VLOG42_DATE) | ||
assertEquals(42, output) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
"Date,"Vlog #","Transaction" | ||
2023-03-13,2-23,W2RVPD6SRQRKBIYKFH5JFSSUKWVPVUV6TOL5DOF2D3RQIPJ6IILQ | ||
2023-03-13,2-24,33LDJYKXY6QEKFZPIA2KRTNL6I7ISWZCXEEH3IKCHE4D254CJC5Q |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters