From fb927e14fd2727a504ea180fcf62dcfda040cab7 Mon Sep 17 00:00:00 2001 From: MIPPL Date: Wed, 12 Aug 2020 12:55:09 +0200 Subject: [PATCH] implement query to remove older duplicate mappings --- .idea/caches/build_file_checksums.ser | Bin 544 -> 544 bytes app/build.gradle | 4 ++-- .../tools/sqlite/BetMappingTxDataStore.java | 20 ++++++++++++++++++ .../wallets/wagerr/WalletWagerrManager.java | 12 +++++++---- 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index ff1beb34b130b5465046cc584d8a563f4dba8491..03c14274c075fc8a29261bd3e39720b430c90e86 100644 GIT binary patch delta 35 tcmV+;0Nnqe1fT?vm;~ZUB>Rz^cM!u9Ds2Rs^>79_ZHR#6g{6}t0sRVH4_E*I delta 35 tcmV+;0Nnqe1fT?vm;|`twvCaTcM$4vRr4|F-U`Q6*6l>T#6puJ0sTK|5=8(2 diff --git a/app/build.gradle b/app/build.gradle index 3dd1f6877..dce6e6283 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,8 +7,8 @@ android { applicationId = 'com.wagerrwallet' minSdkVersion 23 targetSdkVersion 28 - versionCode 279 - versionName "279" + versionCode 280 + versionName "280" multiDexEnabled true // Similar to other properties in the defaultConfig block, diff --git a/app/src/main/java/com/wagerrwallet/tools/sqlite/BetMappingTxDataStore.java b/app/src/main/java/com/wagerrwallet/tools/sqlite/BetMappingTxDataStore.java index 89bb6cab8..fb2c2c006 100644 --- a/app/src/main/java/com/wagerrwallet/tools/sqlite/BetMappingTxDataStore.java +++ b/app/src/main/java/com/wagerrwallet/tools/sqlite/BetMappingTxDataStore.java @@ -272,6 +272,26 @@ public void deleteTxByHash(Context app, String iso, String hash) { } } + public void deleteDuplicateMappings(Context app) { + Cursor cursor = null; + try { + database = openDatabase(); + Log.e(TAG, "mapping transaction deleted" ); + String QUERY = "delete from "+BRSQLiteHelper.BMTX_TABLE_NAME+" where " + BRSQLiteHelper.BMTX_COLUMN_ID + " in (select " + BRSQLiteHelper.BMTX_COLUMN_ID + " " + + "from "+BRSQLiteHelper.BMTX_TABLE_NAME+" where "+ BRSQLiteHelper.BMTX_MAPPINGID +" in " + + "(select "+ BRSQLiteHelper.BMTX_MAPPINGID +" from "+BRSQLiteHelper.BMTX_TABLE_NAME+" where " + BRSQLiteHelper.BMTX_NAMESPACEID +"=3 " + + "group by " + BRSQLiteHelper.BMTX_NAMESPACEID + ", " + BRSQLiteHelper.BMTX_MAPPINGID + " " + + "having count(*)>1) " + + "and " + BRSQLiteHelper.BMTX_COLUMN_ID + " not in (select max(" + BRSQLiteHelper.BMTX_COLUMN_ID + ") from "+BRSQLiteHelper.BMTX_TABLE_NAME+" where "+ BRSQLiteHelper.BMTX_NAMESPACEID +"=3 " + + "group by " + BRSQLiteHelper.BMTX_NAMESPACEID + ", " + BRSQLiteHelper.BMTX_MAPPINGID + " " + + "having count(*)>1) )"; + + database.rawQuery(QUERY, null); + } finally { + closeDatabase(); + } + } + public class BetMappingDupItem { public long NamespaceID; public long MappingID; diff --git a/app/src/main/java/com/wagerrwallet/wallet/wallets/wagerr/WalletWagerrManager.java b/app/src/main/java/com/wagerrwallet/wallet/wallets/wagerr/WalletWagerrManager.java index 255c034a2..fa9a57f62 100644 --- a/app/src/main/java/com/wagerrwallet/wallet/wallets/wagerr/WalletWagerrManager.java +++ b/app/src/main/java/com/wagerrwallet/wallet/wallets/wagerr/WalletWagerrManager.java @@ -304,11 +304,15 @@ public List getTxUiHolders() { } protected void CleanChainBugs(Context app) { + BetMappingTxDataStore bm = BetMappingTxDataStore.getInstance(app); // fake team mappings for ID 187. - BetMappingTxDataStore.getInstance(app).deleteTxByHash(app,"wgr", "cc89779e8e57d49e5e6d3e16ad57e648b19d86fb8f4714bc7df5abd3f92daa1d"); - BetMappingTxDataStore.getInstance(app).deleteTxByHash(app,"wgr", "d8e1e8389bbcffe1c79cf11e2206281377e54b99219ec6ccec296c2adb8ad65f"); - BetMappingTxDataStore.getInstance(app).deleteTxByHash(app,"wgr", "929972a7b2fdf55f6da7488ccaf7312fd5d22c4bca003ca089293c93f1c32917"); - BetMappingTxDataStore.getInstance(app).deleteTxByHash(app,"wgr", "e4e3a4f782569fa3bf0135297942c8a1c791ec869ca036bf530ab95633d17815"); + bm.deleteTxByHash(app,"wgr", "cc89779e8e57d49e5e6d3e16ad57e648b19d86fb8f4714bc7df5abd3f92daa1d"); + bm.deleteTxByHash(app,"wgr", "d8e1e8389bbcffe1c79cf11e2206281377e54b99219ec6ccec296c2adb8ad65f"); + bm.deleteTxByHash(app,"wgr", "929972a7b2fdf55f6da7488ccaf7312fd5d22c4bca003ca089293c93f1c32917"); + bm.deleteTxByHash(app,"wgr", "e4e3a4f782569fa3bf0135297942c8a1c791ec869ca036bf530ab95633d17815"); + + // duplicate mappings + bm.deleteDuplicateMappings(app); } @Override