Merge pull request #1716 from 1hitsong/includeSpecialChars

Include special characters when filtering by #
This commit is contained in:
1hitsong 2024-03-10 17:53:10 -04:00 committed by GitHub
commit 00dbb7cbb9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -136,6 +136,36 @@ sub loadItems()
resp = APIRequest(url, params)
data = getJson(resp)
' If user has filtered by #, include special characters sorted after Z as well
if isValid(params.NameLessThan)
if LCase(params.NameLessThan) = "a"
' Use same params except for name filter param
params.NameLessThan = ""
params.NameStartsWithOrGreater = "z"
' Perform 2nd API lookup for items starting with Z or greater
startsWithZAndGreaterResp = APIRequest(url, params)
startsWithZAndGreaterData = getJson(startsWithZAndGreaterResp)
if isValidAndNotEmpty(startsWithZAndGreaterData)
specialCharacterItems = []
' Filter out items starting with Z
for each item in startsWithZAndGreaterData.Items
itemName = LCase(item.name)
if not itemName.StartsWith("z")
specialCharacterItems.Push(item)
end if
end for
' Append data to results from before A
data.Items.Append(specialCharacterItems)
data.TotalRecordCount += specialCharacterItems.Count()
end if
end if
end if
if data <> invalid
if data.TotalRecordCount <> invalid then m.top.totalRecordCount = data.TotalRecordCount