mirror of
https://github.com/Kvan7/Exiled-Exchange-2.git
synced 2026-09-26 14:45:44 +00:00
use new "collapse" filter
This commit is contained in:
@@ -75,7 +75,7 @@
|
|||||||
<td colspan="100" class="text-transparent">***</td>
|
<td colspan="100" class="text-transparent">***</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-else :key="result.id">
|
<tr v-else :key="result.id">
|
||||||
<td class="px-2 whitespace-no-wrap">{{ result.priceAmount }} {{ result.priceCurrency }} <span v-if="result.listedTimes > 2" class="rounded px-1 text-gray-800 bg-gray-400 -mr-2"><span class="font-sans">×</span> {{ result.listedTimes }}</span></td>
|
<td class="px-2 whitespace-no-wrap">{{ result.priceAmount }} {{ result.priceCurrency }}</td>
|
||||||
<td v-if="item.stackSize" class="px-2 text-right">{{ result.stackSize }}</td>
|
<td v-if="item.stackSize" class="px-2 text-right">{{ result.stackSize }}</td>
|
||||||
<td v-if="filters.itemLevel" class="px-2 whitespace-no-wrap text-right">{{ result.itemLevel }}</td>
|
<td v-if="filters.itemLevel" class="px-2 whitespace-no-wrap text-right">{{ result.itemLevel }}</td>
|
||||||
<td v-if="item.rarity === 'Gem'" class="pl-2 whitespace-no-wrap">{{ result.level }}</td>
|
<td v-if="item.rarity === 'Gem'" class="pl-2 whitespace-no-wrap">{{ result.level }}</td>
|
||||||
@@ -124,9 +124,6 @@ import { artificialSlowdown } from './artificial-slowdown'
|
|||||||
const slowdown = artificialSlowdown(900)
|
const slowdown = artificialSlowdown(900)
|
||||||
|
|
||||||
const SHOW_RESULTS = 20
|
const SHOW_RESULTS = 20
|
||||||
const API_FETCH_LIMIT = 100
|
|
||||||
const MIN_NOT_GROUPED = 7
|
|
||||||
const MIN_GROUPED = 10
|
|
||||||
|
|
||||||
function useTradeApi () {
|
function useTradeApi () {
|
||||||
let searchId = 0
|
let searchId = 0
|
||||||
@@ -134,46 +131,8 @@ function useTradeApi () {
|
|||||||
const searchResult = shallowRef<SearchResult | null>(null)
|
const searchResult = shallowRef<SearchResult | null>(null)
|
||||||
const fetchResults = shallowRef<PricingResult[]>([])
|
const fetchResults = shallowRef<PricingResult[]>([])
|
||||||
|
|
||||||
const groupedResults = computed(() => {
|
|
||||||
const out: Array<PricingResult & { listedTimes: number }> = []
|
|
||||||
|
|
||||||
for (const result of fetchResults.value) {
|
|
||||||
if (result == null) break
|
|
||||||
|
|
||||||
if (out.length === 0) {
|
|
||||||
out.push({ listedTimes: 1, ...result })
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
const existingRes = out.find((added, idx) =>
|
|
||||||
(
|
|
||||||
added.accountName === result.accountName &&
|
|
||||||
added.priceCurrency === result.priceCurrency &&
|
|
||||||
added.priceAmount === result.priceAmount
|
|
||||||
) ||
|
|
||||||
(
|
|
||||||
added.accountName === result.accountName &&
|
|
||||||
(out.length - idx) <= 2 // last or prev
|
|
||||||
)
|
|
||||||
)
|
|
||||||
if (existingRes) {
|
|
||||||
if (existingRes.stackSize) {
|
|
||||||
existingRes.stackSize += result.stackSize!
|
|
||||||
} else {
|
|
||||||
existingRes.listedTimes += 1
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
out.push({ listedTimes: 1, ...result })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return out
|
|
||||||
})
|
|
||||||
|
|
||||||
async function search (filters: ItemFilters, stats: StatFilter[], item: ParsedItem) {
|
async function search (filters: ItemFilters, stats: StatFilter[], item: ParsedItem) {
|
||||||
try {
|
try {
|
||||||
// NOTE: rate limiting https://www.pathofexile.com/forum/view-thread/2079853#p15244273
|
|
||||||
|
|
||||||
searchId += 1
|
searchId += 1
|
||||||
error.value = null
|
error.value = null
|
||||||
searchResult.value = null
|
searchResult.value = null
|
||||||
@@ -188,7 +147,6 @@ function useTradeApi () {
|
|||||||
}
|
}
|
||||||
searchResult.value = _searchResult
|
searchResult.value = _searchResult
|
||||||
|
|
||||||
// first two req are parallel, then sequential on demand
|
|
||||||
{
|
{
|
||||||
const r1 = (_searchResult.total > 0)
|
const r1 = (_searchResult.total > 0)
|
||||||
? requestResults(_searchResult.id, _searchResult.result.slice(0, 10))
|
? requestResults(_searchResult.id, _searchResult.result.slice(0, 10))
|
||||||
@@ -201,34 +159,12 @@ function useTradeApi () {
|
|||||||
: Promise.resolve()
|
: Promise.resolve()
|
||||||
await Promise.all([r1, r2])
|
await Promise.all([r1, r2])
|
||||||
}
|
}
|
||||||
|
|
||||||
let fetched = 20
|
|
||||||
async function fetchMore (): Promise<void> {
|
|
||||||
if (_searchId !== searchId) return
|
|
||||||
|
|
||||||
const totalGrouped = groupedResults.value.length
|
|
||||||
const totalNotGrouped = groupedResults.value.reduce((len, res) =>
|
|
||||||
res.listedTimes <= 2 ? len + 1 : len, 0)
|
|
||||||
|
|
||||||
if (
|
|
||||||
(totalNotGrouped < MIN_NOT_GROUPED || totalGrouped < MIN_GROUPED) &&
|
|
||||||
fetched < _searchResult.total &&
|
|
||||||
fetched < API_FETCH_LIMIT
|
|
||||||
) {
|
|
||||||
await requestResults(_searchResult.id, _searchResult.result.slice(fetched, fetched + 10))
|
|
||||||
.then(results => { _fetchResults.push(...results) })
|
|
||||||
|
|
||||||
fetched += 10
|
|
||||||
return fetchMore()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return fetchMore()
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
error.value = err.message
|
error.value = err.message
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return { error, searchResult, fetchResults, groupedResults, search }
|
return { error, searchResult, groupedResults: fetchResults, search }
|
||||||
}
|
}
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ interface TradeRequest { /* eslint-disable camelcase */
|
|||||||
}
|
}
|
||||||
trade_filters: {
|
trade_filters: {
|
||||||
filters: {
|
filters: {
|
||||||
sale_type: { option: 'priced' }
|
collapse?: FilterBoolean
|
||||||
indexed?: { option?: string }
|
indexed?: { option?: string }
|
||||||
price?: FilterRange | { option?: string }
|
price?: FilterRange | { option?: string }
|
||||||
}
|
}
|
||||||
@@ -230,7 +230,7 @@ export function createTradeRequest (filters: ItemFilters, stats: StatFilter[], i
|
|||||||
filters: {
|
filters: {
|
||||||
trade_filters: {
|
trade_filters: {
|
||||||
filters: {
|
filters: {
|
||||||
sale_type: { option: 'priced' }
|
collapse: { option: 'true' }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user