Skip to content

Commit 6e07007

Browse files
committed
Db: Remove unnecessary 'termsId' from 'WCGlobalAttributeModel' table
FYI: Similarly to this 364c18d change, which completely removed everything 'WCAttributeTermModel', this related 'termsId' column/code is also unnecessary and can be safely removed from its associated 'WCGlobalAttributeModel' table.
1 parent 9c0dbf9 commit 6e07007

File tree

4 files changed

+0
-31
lines changed

4 files changed

+0
-31
lines changed

WooCommerce/src/main/kotlin/com/woocommerce/android/model/ProductGlobalAttribute.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ data class ProductGlobalAttribute(
1616
val type: String,
1717
val orderBy: String,
1818
val hasArchives: Boolean,
19-
val termsId: String,
2019
val remoteId: Long
2120
) : Parcelable {
2221
fun toDataModel(cachedAttribute: WCGlobalAttributeModel? = null): WCGlobalAttributeModel {
@@ -28,7 +27,6 @@ data class ProductGlobalAttribute(
2827
it.type = type
2928
it.orderBy = orderBy
3029
it.hasArchives = hasArchives
31-
it.termsId = termsId
3230
it.remoteId = remoteId.toInt()
3331
}
3432
}
@@ -58,6 +56,5 @@ fun WCGlobalAttributeModel.toAppModel(): ProductGlobalAttribute {
5856
type = this.type,
5957
orderBy = this.orderBy,
6058
hasArchives = this.hasArchives,
61-
termsId = this.termsId
6259
)
6360
}

libs/fluxc-plugin/src/main/kotlin/org/wordpress/android/fluxc/model/attribute/WCGlobalAttributeModel.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ data class WCGlobalAttributeModel(
1515
@Column var type: String = "",
1616
@Column var orderBy: String = "",
1717
@Column var hasArchives: Boolean = false,
18-
@Column var termsId: String = "",
1918
@Column var remoteId: Int = 0
2019
) : Identifiable {
2120
override fun setId(id: Int) {

libs/fluxc-plugin/src/main/kotlin/org/wordpress/android/fluxc/persistence/WCGlobalAttributeSqlUtils.kt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,6 @@ object WCGlobalAttributeSqlUtils {
6363
}
6464
?: insertSingleAttribute(attribute)
6565

66-
fun updateSingleAttributeTermsMapping(attributeID: Int, termsMapping: String, siteID: Int) =
67-
fetchSingleStoredAttribute(attributeID, siteID)
68-
?.let {
69-
it.termsId = termsMapping
70-
updateSingleStoredAttribute(it, siteID)
71-
}
72-
7366
private fun deleteCompleteAttributesList(siteID: Int) =
7467
WellSql.delete(WCGlobalAttributeModel::class.java)
7568
.where().beginGroup()

libs/fluxc-plugin/src/main/kotlin/org/wordpress/android/fluxc/store/WCGlobalAttributeStore.kt

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import org.wordpress.android.fluxc.persistence.WCGlobalAttributeSqlUtils.getCurr
1414
import org.wordpress.android.fluxc.persistence.WCGlobalAttributeSqlUtils.insertFromScratchCompleteAttributesList
1515
import org.wordpress.android.fluxc.persistence.WCGlobalAttributeSqlUtils.insertOrUpdateSingleAttribute
1616
import org.wordpress.android.fluxc.persistence.WCGlobalAttributeSqlUtils.insertSingleAttribute
17-
import org.wordpress.android.fluxc.persistence.WCGlobalAttributeSqlUtils.updateSingleAttributeTermsMapping
1817
import org.wordpress.android.fluxc.persistence.WCGlobalAttributeSqlUtils.updateSingleStoredAttribute
1918
import org.wordpress.android.fluxc.tools.CoroutineEngine
2019
import org.wordpress.android.util.AppLog
@@ -58,15 +57,6 @@ class WCGlobalAttributeStore @Inject constructor(
5857
pageSize: Int = DEFAULT_PAGE_SIZE
5958
) = restClient.fetchAllAttributeTerms(site, attributeID, page, pageSize)
6059
.result?.map { mapper.responseToAttributeTermModel(it, attributeID.toInt(), site) }
61-
?.apply {
62-
map { it.remoteId.toString() }
63-
.takeIf { it.isNotEmpty() }
64-
?.reduce { total, new -> "$total;$new" }
65-
?.let { termsId ->
66-
updateSingleAttributeTermsMapping(attributeID.toInt(), termsId, site.id)
67-
?: handleMissingAttribute(site, attributeID, termsId)
68-
}
69-
}
7060
?.let { WooResult(it) }
7161

7262
suspend fun fetchAttribute(
@@ -183,16 +173,6 @@ class WCGlobalAttributeStore @Inject constructor(
183173
?: WooResult(WooError(GENERIC_ERROR, UNKNOWN))
184174
}
185175

186-
private suspend fun handleMissingAttribute(
187-
site: SiteModel,
188-
attributeID: Long,
189-
termsId: String
190-
) {
191-
fetchAttribute(site, attributeID)
192-
.model
193-
?.let { updateSingleAttributeTermsMapping(attributeID.toInt(), termsId, site.id) }
194-
}
195-
196176
companion object {
197177
const val DEFAULT_PAGE_SIZE = 100
198178
const val DEFAULT_PAGE_INDEX = 1

0 commit comments

Comments
 (0)