refactoring
This commit is contained in:
+19
-19
@@ -41,7 +41,7 @@ public.filters = {
|
||||
},
|
||||
|
||||
['left'] = {
|
||||
input_type = -list('30m', '2h', '8h', '24h'),
|
||||
input_type = list('30m', '2h', '8h', '24h'),
|
||||
validator = function(index)
|
||||
return function(auction_record)
|
||||
return auction_record.duration == index
|
||||
@@ -50,7 +50,7 @@ public.filters = {
|
||||
},
|
||||
|
||||
['rarity'] = {
|
||||
input_type = -list('poor', 'common', 'uncommon', 'rare', 'epic'),
|
||||
input_type = list('poor', 'common', 'uncommon', 'rare', 'epic'),
|
||||
validator = function(index)
|
||||
return function(auction_record)
|
||||
return auction_record.quality == index - 1
|
||||
@@ -203,11 +203,11 @@ public.filters = {
|
||||
}
|
||||
|
||||
function operator(str)
|
||||
local operator = str == 'not' and -list('operator', 'not', 1)
|
||||
for name in -temp-set('and', 'or') do
|
||||
local operator = str == 'not' and list('operator', 'not', 1)
|
||||
for name in temp-set('and', 'or') do
|
||||
for arity in present(select(3, strfind(str, '^'..name..'(%d*)$'))) do
|
||||
arity = tonumber(arity)
|
||||
operator = not (arity and arity < 2) and -list('operator', name, arity)
|
||||
operator = not (arity and arity < 2) and list('operator', name, arity)
|
||||
end
|
||||
end
|
||||
return operator or nil
|
||||
@@ -225,7 +225,7 @@ do
|
||||
end
|
||||
for number in present(tonumber(select(3, strfind(str, '^(%d+)$')))) do
|
||||
if number >= 1 and number <= 60 then
|
||||
for filter in -temp-set('min_level', 'max_level') do
|
||||
for filter in temp-set('min_level', 'max_level') do
|
||||
if not self[filter] then
|
||||
self[filter] = {str, number}
|
||||
return true
|
||||
@@ -233,11 +233,11 @@ do
|
||||
end
|
||||
end
|
||||
end
|
||||
for _, parser in -list(
|
||||
-list('class', info.item_class_index),
|
||||
-list('subclass', L(info.item_subclass_index, index(self.class, 2) or 0, _1)),
|
||||
-list('slot', L(info.item_slot_index, index(self.class, 2) or 0, index(self.subclass, 2) or 0, _1)),
|
||||
-list('quality', info.item_quality_index)
|
||||
for _, parser in list(
|
||||
list('class', info.item_class_index),
|
||||
list('subclass', L(info.item_subclass_index, index(self.class, 2) or 0, _1)),
|
||||
list('slot', L(info.item_slot_index, index(self.class, 2) or 0, index(self.subclass, 2) or 0, _1)),
|
||||
list('quality', info.item_quality_index)
|
||||
) do
|
||||
if not self[parser[1]] then
|
||||
tinsert(parser, str)
|
||||
@@ -250,7 +250,7 @@ do
|
||||
if not self[str] and (str == 'usable' or str == 'exact' and self.name and size(self) == 1) then
|
||||
self[str] = {str, 1}
|
||||
elseif i == 1 and strlen(str) <= 63 then
|
||||
self.name = -list(str, unquote(str))
|
||||
self.name = list(str, unquote(str))
|
||||
-- return nil, 'The name filter must not be longer than 63 characters'
|
||||
else
|
||||
return
|
||||
@@ -300,14 +300,14 @@ function public.parse_query_string(str)
|
||||
return nil, 'Invalid input for '..parts[i]..'. Expecting: '..input_type
|
||||
end
|
||||
end
|
||||
tinsert(post_filter, -list('filter', parts[i], parts[i + 1]))
|
||||
tinsert(post_filter, list('filter', parts[i], parts[i + 1]))
|
||||
i = i + 1
|
||||
else
|
||||
tinsert(post_filter, -list('filter', parts[i]))
|
||||
tinsert(post_filter, list('filter', parts[i]))
|
||||
end
|
||||
elseif not blizzard_filter_parser(parts[i], i) then
|
||||
if parts[i] ~= '' then
|
||||
tinsert(post_filter, -list('filter', 'tooltip', parts[i]))
|
||||
tinsert(post_filter, list('filter', 'tooltip', parts[i]))
|
||||
else
|
||||
return nil, 'Empty modifier'
|
||||
end
|
||||
@@ -315,7 +315,7 @@ function public.parse_query_string(str)
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
return -object('blizzard', blizzard_filter_parser(), 'post', post_filter)
|
||||
return T('blizzard', blizzard_filter_parser(), 'post', post_filter)
|
||||
end
|
||||
|
||||
function public.query(query_string)
|
||||
@@ -492,7 +492,7 @@ end
|
||||
function blizzard_query(components)
|
||||
local filters = components.blizzard
|
||||
|
||||
local query = -object('name', filters.name and filters.name[2])
|
||||
local query = T('name', filters.name and filters.name[2])
|
||||
|
||||
local item_info, class_index, subclass_index, slot_index
|
||||
local item_id = aux.cache.item_id(filters.name[2])
|
||||
@@ -513,7 +513,7 @@ function blizzard_query(components)
|
||||
query.slot = slot_index
|
||||
query.quality = item_info.quality
|
||||
else
|
||||
for key in -temp-set('min_level', 'max_level', 'class', 'subclass', 'slot', 'usable', 'quality') do
|
||||
for key in temp-set('min_level', 'max_level', 'class', 'subclass', 'slot', 'usable', 'quality') do
|
||||
query[key] = index(filters[key], 2)
|
||||
end
|
||||
end
|
||||
@@ -559,7 +559,7 @@ end
|
||||
|
||||
function public.query_builder()
|
||||
local filter
|
||||
return -object(
|
||||
return T(
|
||||
'appended', function(part)
|
||||
return query_builder(not filter and part or filter..'/'..part)
|
||||
end,
|
||||
|
||||
Reference in New Issue
Block a user