Stop filtering out all categories that have a year in it

As a fix for #750, a validation was added to filter out categories
that were of form "... taken on ... 1990" or "... needing ... 2005".
The conditional added for the fix was a bit loose than it should be
as a result of which it filtered out all categories that had a year
in its name. This is incorrect.

Fix this by tigheting the conditional so that only categories that
have a year, is not the present or previous year AND (contains
"taken on" OR "needing") is filtered out.

While doing so, turn an implicit precedence into an explicit one.
This commit is contained in:
Kaartic Sivaraam 2022-03-19 16:58:53 +05:30
parent 1078c70525
commit 9a1d3efe75

View file

@ -42,10 +42,10 @@ 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())
|| item.matches(".*0s.*".toRegex())
&& !item.matches(".*(200|201)0s.*".toRegex())
&& (item.matches("(.*)needing(.*)".toRegex())
|| item.matches("(.*)taken on(.*)".toRegex()))
|| (item.matches(".*0s.*".toRegex())
&& !item.matches(".*(200|201)0s.*".toRegex()))
}
/**