mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-28 13:23:58 +01:00
original logic fix
from https://github.com/commons-app/apps-android-commons/pull/5761#pullrequestreview-2144120347
This commit is contained in:
parent
8916362704
commit
eafb363863
1 changed files with 20 additions and 11 deletions
|
|
@ -40,17 +40,26 @@ class CategoriesModel @Inject constructor(
|
||||||
val prevYearInString = prevYear.toString()
|
val prevYearInString = prevYear.toString()
|
||||||
Timber.d("Previous year: %s", prevYearInString)
|
Timber.d("Previous year: %s", prevYearInString)
|
||||||
|
|
||||||
//Check if item contains a 4-digit word anywhere within the string (.* is wildcard) (Issue #47)
|
val is20xxsYear = item.matches(".*0s.*".toRegex())
|
||||||
//And that item does not equal the current year or previous year
|
|
||||||
//And if it is an irrelevant category such as Media_needing_categories_as_of_16_June_2017(Issue #750)
|
if (is20xxsYear) {
|
||||||
//Check if the year in the form of XX(X)0s is relevant, i.e. in the 2000s or 2010s as stated in Issue #1029
|
//Check if the year in the form of XX(X)0s is relevant, i.e. in the 2000s or 2010s as stated in Issue #1029
|
||||||
return item.matches(".*(19|20)\\d{2}.*".toRegex())
|
// If not, check if it is an irrelevant category such as Media_needing_categories_as_of_16_June_2017(Issue #750)
|
||||||
&& !item.contains(curYearInString)
|
return !item.matches(".*20[0-2]0s.*".toRegex())
|
||||||
&& !item.contains(prevYearInString)
|
|| item.matches("(.*)needing(.*)".toRegex())
|
||||||
|| item.matches("(.*)needing(.*)".toRegex())
|
|| item.matches("(.*)taken on(.*)".toRegex())
|
||||||
|| item.matches("(.*)taken on(.*)".toRegex())
|
}
|
||||||
|| item.matches(".*0s.*".toRegex())
|
else {
|
||||||
&& !item.matches(".*20[0-2]0s.*".toRegex())
|
// If it is not an year in 20xxs form, then check if item contains a 4-digit word
|
||||||
|
// anywhere within the string (.* is wildcard) (Issue #47)
|
||||||
|
// And that item does not equal the current year or previous year
|
||||||
|
// And if it is an irrelevant category such as Media_needing_categories_as_of_16_June_2017(Issue #750)
|
||||||
|
return item.matches(".*(19|20)\\d{2}.*".toRegex())
|
||||||
|
&& !item.contains(yearInString)
|
||||||
|
&& !item.contains(prevYearInString)
|
||||||
|
|| item.matches("(.*)needing(.*)".toRegex())
|
||||||
|
|| item.matches("(.*)taken on(.*)".toRegex())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue