Skip to content

Commit e0bac7b

Browse files
committed
chore(activityfeed): correct timestamp mapping
Signed-off-by: Brandon McAnsh <[email protected]>
1 parent 1d16c65 commit e0bac7b

File tree

3 files changed

+261
-2
lines changed

3 files changed

+261
-2
lines changed
Lines changed: 252 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,252 @@
1+
{
2+
"formatVersion": 1,
3+
"database": {
4+
"version": 7,
5+
"identityHash": "f506a555bb289d4b34e7e12b8251a401",
6+
"entities": [
7+
{
8+
"tableName": "messages",
9+
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`idBase58` TEXT NOT NULL, `text` TEXT NOT NULL, `amountUsdc` INTEGER, `amountNative` INTEGER, `nativeCurrency` TEXT, `rate` REAL, `state` TEXT NOT NULL, `timestamp` INTEGER NOT NULL, `metadata` TEXT, PRIMARY KEY(`idBase58`))",
10+
"fields": [
11+
{
12+
"fieldPath": "idBase58",
13+
"columnName": "idBase58",
14+
"affinity": "TEXT",
15+
"notNull": true
16+
},
17+
{
18+
"fieldPath": "text",
19+
"columnName": "text",
20+
"affinity": "TEXT",
21+
"notNull": true
22+
},
23+
{
24+
"fieldPath": "amountUsdc",
25+
"columnName": "amountUsdc",
26+
"affinity": "INTEGER"
27+
},
28+
{
29+
"fieldPath": "amountNative",
30+
"columnName": "amountNative",
31+
"affinity": "INTEGER"
32+
},
33+
{
34+
"fieldPath": "nativeCurrency",
35+
"columnName": "nativeCurrency",
36+
"affinity": "TEXT"
37+
},
38+
{
39+
"fieldPath": "rate",
40+
"columnName": "rate",
41+
"affinity": "REAL"
42+
},
43+
{
44+
"fieldPath": "state",
45+
"columnName": "state",
46+
"affinity": "TEXT",
47+
"notNull": true
48+
},
49+
{
50+
"fieldPath": "timestamp",
51+
"columnName": "timestamp",
52+
"affinity": "INTEGER",
53+
"notNull": true
54+
},
55+
{
56+
"fieldPath": "metadata",
57+
"columnName": "metadata",
58+
"affinity": "TEXT"
59+
}
60+
],
61+
"primaryKey": {
62+
"autoGenerate": false,
63+
"columnNames": [
64+
"idBase58"
65+
]
66+
}
67+
},
68+
{
69+
"tableName": "pool_metadata",
70+
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`idBase58` TEXT NOT NULL, `creatorBase58` TEXT NOT NULL, `pagingTokenBase58` TEXT, `name` TEXT NOT NULL, `buyInAmount` INTEGER NOT NULL, `buyInCurrency` TEXT NOT NULL, `fundingDestinationBase58` TEXT NOT NULL, `isOpen` INTEGER NOT NULL, `resolution` TEXT, `timestamp` INTEGER NOT NULL, `closedTimestamp` INTEGER, `derivationIndex` INTEGER NOT NULL DEFAULT -1, `rendezvousSignature` TEXT NOT NULL DEFAULT '', `betSummary` TEXT, `userSummary` TEXT, PRIMARY KEY(`idBase58`))",
71+
"fields": [
72+
{
73+
"fieldPath": "idBase58",
74+
"columnName": "idBase58",
75+
"affinity": "TEXT",
76+
"notNull": true
77+
},
78+
{
79+
"fieldPath": "creatorBase58",
80+
"columnName": "creatorBase58",
81+
"affinity": "TEXT",
82+
"notNull": true
83+
},
84+
{
85+
"fieldPath": "pagingTokenBase58",
86+
"columnName": "pagingTokenBase58",
87+
"affinity": "TEXT"
88+
},
89+
{
90+
"fieldPath": "name",
91+
"columnName": "name",
92+
"affinity": "TEXT",
93+
"notNull": true
94+
},
95+
{
96+
"fieldPath": "buyInAmount",
97+
"columnName": "buyInAmount",
98+
"affinity": "INTEGER",
99+
"notNull": true
100+
},
101+
{
102+
"fieldPath": "buyInCurrency",
103+
"columnName": "buyInCurrency",
104+
"affinity": "TEXT",
105+
"notNull": true
106+
},
107+
{
108+
"fieldPath": "fundingDestinationBase58",
109+
"columnName": "fundingDestinationBase58",
110+
"affinity": "TEXT",
111+
"notNull": true
112+
},
113+
{
114+
"fieldPath": "isOpen",
115+
"columnName": "isOpen",
116+
"affinity": "INTEGER",
117+
"notNull": true
118+
},
119+
{
120+
"fieldPath": "resolution",
121+
"columnName": "resolution",
122+
"affinity": "TEXT"
123+
},
124+
{
125+
"fieldPath": "timestamp",
126+
"columnName": "timestamp",
127+
"affinity": "INTEGER",
128+
"notNull": true
129+
},
130+
{
131+
"fieldPath": "closedTimestamp",
132+
"columnName": "closedTimestamp",
133+
"affinity": "INTEGER"
134+
},
135+
{
136+
"fieldPath": "derivationIndex",
137+
"columnName": "derivationIndex",
138+
"affinity": "INTEGER",
139+
"notNull": true,
140+
"defaultValue": "-1"
141+
},
142+
{
143+
"fieldPath": "rendezvousSignature",
144+
"columnName": "rendezvousSignature",
145+
"affinity": "TEXT",
146+
"notNull": true,
147+
"defaultValue": "''"
148+
},
149+
{
150+
"fieldPath": "betSummary",
151+
"columnName": "betSummary",
152+
"affinity": "TEXT"
153+
},
154+
{
155+
"fieldPath": "userSummary",
156+
"columnName": "userSummary",
157+
"affinity": "TEXT"
158+
}
159+
],
160+
"primaryKey": {
161+
"autoGenerate": false,
162+
"columnNames": [
163+
"idBase58"
164+
]
165+
}
166+
},
167+
{
168+
"tableName": "pool_bet_metadata",
169+
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`idBase58` TEXT NOT NULL, `poolIdBase58` TEXT NOT NULL, `userIdBase58` TEXT NOT NULL, `selectedOutcome` TEXT NOT NULL, `payoutDestinationBase58` TEXT NOT NULL, `timestamp` INTEGER NOT NULL, `hasSubmittedIntent` INTEGER NOT NULL DEFAULT false, PRIMARY KEY(`idBase58`))",
170+
"fields": [
171+
{
172+
"fieldPath": "idBase58",
173+
"columnName": "idBase58",
174+
"affinity": "TEXT",
175+
"notNull": true
176+
},
177+
{
178+
"fieldPath": "poolIdBase58",
179+
"columnName": "poolIdBase58",
180+
"affinity": "TEXT",
181+
"notNull": true
182+
},
183+
{
184+
"fieldPath": "userIdBase58",
185+
"columnName": "userIdBase58",
186+
"affinity": "TEXT",
187+
"notNull": true
188+
},
189+
{
190+
"fieldPath": "selectedOutcome",
191+
"columnName": "selectedOutcome",
192+
"affinity": "TEXT",
193+
"notNull": true
194+
},
195+
{
196+
"fieldPath": "payoutDestinationBase58",
197+
"columnName": "payoutDestinationBase58",
198+
"affinity": "TEXT",
199+
"notNull": true
200+
},
201+
{
202+
"fieldPath": "timestamp",
203+
"columnName": "timestamp",
204+
"affinity": "INTEGER",
205+
"notNull": true
206+
},
207+
{
208+
"fieldPath": "hasSubmittedIntent",
209+
"columnName": "hasSubmittedIntent",
210+
"affinity": "INTEGER",
211+
"notNull": true,
212+
"defaultValue": "false"
213+
}
214+
],
215+
"primaryKey": {
216+
"autoGenerate": false,
217+
"columnNames": [
218+
"idBase58"
219+
]
220+
}
221+
},
222+
{
223+
"tableName": "pool_rendezvous_keys",
224+
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`poolIdBase58` TEXT NOT NULL, `rendezvousSeedBase58` TEXT NOT NULL, PRIMARY KEY(`poolIdBase58`))",
225+
"fields": [
226+
{
227+
"fieldPath": "poolIdBase58",
228+
"columnName": "poolIdBase58",
229+
"affinity": "TEXT",
230+
"notNull": true
231+
},
232+
{
233+
"fieldPath": "rendezvousSeedBase58",
234+
"columnName": "rendezvousSeedBase58",
235+
"affinity": "TEXT",
236+
"notNull": true
237+
}
238+
],
239+
"primaryKey": {
240+
"autoGenerate": false,
241+
"columnNames": [
242+
"poolIdBase58"
243+
]
244+
}
245+
}
246+
],
247+
"setupQueries": [
248+
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
249+
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'f506a555bb289d4b34e7e12b8251a401')"
250+
]
251+
}
252+
}

apps/flipcash/shared/persistence/db/src/main/kotlin/com/flipcash/app/persistence/FlipcashDatabase.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ import org.kin.sdk.base.tools.subByteArray
3636
AutoMigration(from = 3, to = 4, spec = FlipcashDatabase.Migration3To4::class),
3737
AutoMigration(from = 4, to = 5, spec = FlipcashDatabase.Migration4To5::class),
3838
AutoMigration(from = 5, to = 6, spec = FlipcashDatabase.Migration5To6::class),
39+
AutoMigration(from = 6, to = 7, spec = FlipcashDatabase.Migration6To7::class),
3940
],
40-
version = 6,
41+
version = 7,
4142
)
4243
@TypeConverters(PoolResolutionConverter::class, BetOutcomeConverter::class)
4344
abstract class FlipcashDatabase : RoomDatabase() {
@@ -86,6 +87,12 @@ abstract class FlipcashDatabase : RoomDatabase() {
8687
}
8788
}
8889

90+
class Migration6To7 : Migration(6, 7), AutoMigrationSpec {
91+
override fun migrate(db: SupportSQLiteDatabase) {
92+
db.execSQL("DELETE FROM messages")
93+
}
94+
}
95+
8996
companion object {
9097
private var instance: FlipcashDatabase? = null
9198
fun requireInstance() = requireNotNull(instance)

services/flipcash/src/main/kotlin/com/flipcash/services/internal/domain/ActivityFeedMessageMapper.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ internal class ActivityFeedMessageMapper @Inject constructor(
2727
converted = Fiat(fiat = it.nativeAmount, currencyCode = CurrencyCode.tryValueOf(it.currency) ?: CurrencyCode.USD),
2828
)
2929
},
30-
timestamp = Instant.fromEpochSeconds(from.ts.seconds * 1000L),
30+
timestamp = Instant.fromEpochSeconds(from.ts.seconds),
3131
state = when (from.state) {
3232
Model.NotificationState.NOTIFICATION_STATE_PENDING -> NotificationState.PENDING
3333
Model.NotificationState.NOTIFICATION_STATE_COMPLETED -> NotificationState.COMPLETED

0 commit comments

Comments
 (0)