refactor: rename containsYear to isSpammyCategory

This is done as the name containsYear is ambiguous.
It not just checks for year to identify spammy categories.
This commit is contained in:
Kaartic Sivaraam 2024-07-17 09:46:59 +05:30
parent 4fe4310343
commit fe74c77abf
3 changed files with 6 additions and 5 deletions

View file

@ -27,11 +27,12 @@ class CategoriesModel @Inject constructor(
private var selectedExistingCategories: MutableList<String> = mutableListOf()
/**
* Returns true if the item contains an year which should be ignored
* @param item
* Returns true if an item is considered to be a spammy category which should be ignored
*
* @param item a category item that needs to be validated to know if it is spammy or not
* @return
*/
fun containsYear(item: String): Boolean {
fun isSpammyCategory(item: String): Boolean {
//Check for current and previous year to exclude these categories from removal
val now = Calendar.getInstance()
val curYear = now[Calendar.YEAR]

View file

@ -149,7 +149,7 @@ public class UploadRepository {
* @return
*/
public boolean containsYear(String name) {
return categoriesModel.containsYear(name);
return categoriesModel.isSpammyCategory(name);
}
/**

View file

@ -156,7 +156,7 @@ class UploadRepositoryUnitTest {
@Test
fun testContainsYear() {
assertEquals(
repository.containsYear(""), categoriesModel.containsYear("")
repository.containsYear(""), categoriesModel.isSpammyCategory("")
)
}