From ee1d4c8edfc961fd017796052d284f95c2c52a30 Mon Sep 17 00:00:00 2001 From: Matija Nalis Date: Mon, 15 Jul 2024 01:15:29 +0200 Subject: [PATCH] consolidate duplicated code to spammyCategory --- .../fr/free/nrw/commons/category/CategoriesModel.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/fr/free/nrw/commons/category/CategoriesModel.kt b/app/src/main/java/fr/free/nrw/commons/category/CategoriesModel.kt index 8488a5767..663cf2356 100644 --- a/app/src/main/java/fr/free/nrw/commons/category/CategoriesModel.kt +++ b/app/src/main/java/fr/free/nrw/commons/category/CategoriesModel.kt @@ -41,13 +41,14 @@ class CategoriesModel @Inject constructor( Timber.d("Previous year: %s", prevYearInString) val mentionsDecade = item.matches(".*0s.*".toRegex()) + val spammyCategory = item.matches("(.*)needing(.*)".toRegex()) + || item.matches("(.*)taken on(.*)".toRegex()) if (mentionsDecade) { - //Check if the year in the form of XX(X)0s is relevant, i.e. in the 2000s or 2010s (or 2020s) as stated in Issue #1029 + //Check if the year in the form of XX(X)0s is recent/relevant, i.e. in the 2000s or 2010s/2020s as stated in Issue #1029 // If not, check if it is an irrelevant category such as Media_needing_categories_as_of_16_June_2017(Issue #750) return !item.matches(".*20[0-2]0s.*".toRegex()) - || item.matches("(.*)needing(.*)".toRegex()) - || item.matches("(.*)taken on(.*)".toRegex()) + || spammyCategory } else { // If it is not an year in 20xxs form, then check if item contains a 4-digit word @@ -57,8 +58,7 @@ class CategoriesModel @Inject constructor( return item.matches(".*(19|20)\\d{2}.*".toRegex()) && !item.contains(yearInString) && !item.contains(prevYearInString) - || item.matches("(.*)needing(.*)".toRegex()) - || item.matches("(.*)taken on(.*)".toRegex()) + || spammyCategory } }