Fix product performance grouped JSON build
This commit is contained in:
@@ -4,16 +4,6 @@ import api from 'src/services/api'
|
||||
const GROUPED_TTL_MS = 2 * 60 * 1000
|
||||
const IMAGE_TTL_MS = 15 * 60 * 1000
|
||||
|
||||
function normalizeUploadsPath (storagePath) {
|
||||
const raw = String(storagePath || '').trim()
|
||||
if (!raw) return ''
|
||||
const normalized = raw.replace(/\\/g, '/')
|
||||
const idx = normalized.toLowerCase().indexOf('/uploads/')
|
||||
if (idx >= 0) return normalized.slice(idx)
|
||||
if (normalized.toLowerCase().startsWith('uploads/')) return `/${normalized}`
|
||||
return ''
|
||||
}
|
||||
|
||||
function resolveProductImageUrl (item) {
|
||||
return resolveProductImageUrls(item)[0] || ''
|
||||
}
|
||||
@@ -32,18 +22,9 @@ function resolveProductImageUrls (item) {
|
||||
const fullURL = String(item.full_url || item.fullUrl || '').trim()
|
||||
addURL(fullURL)
|
||||
|
||||
const uploadsPath = normalizeUploadsPath(item.storage_path || item.storage || '')
|
||||
addURL(uploadsPath)
|
||||
|
||||
const fileName = String(item.file_name || item.FileName || '').trim()
|
||||
if (fileName) addURL(`/uploads/image/${fileName}`)
|
||||
|
||||
const contentURL = String(item.content_url || item.ContentURL || '').trim()
|
||||
if (contentURL.startsWith('/api/')) addURL(contentURL)
|
||||
else if (contentURL.startsWith('/')) addURL(`/api${contentURL}`)
|
||||
|
||||
const imageId = Number(item.id || item.ID || 0)
|
||||
if (Number.isFinite(imageId) && imageId > 0) addURL(`/api/product-images/${imageId}/content`)
|
||||
return urls
|
||||
}
|
||||
|
||||
@@ -206,7 +187,7 @@ export const useProductPerformanceStore = defineStore('product-performance-store
|
||||
urun_ana_grubu: params.urunAnaGrubu || params.urun_ana_grubu || '',
|
||||
group_levels: Array.isArray(params.groupLevels) ? params.groupLevels : String(params.groupLevels || '').split(',').filter(Boolean),
|
||||
fields: Array.isArray(params.fields) ? params.fields : String(params.fields || '').split(',').filter(Boolean),
|
||||
limit: params.limit || 5000
|
||||
limit: params.limit || 50000
|
||||
}, { timeout: 60000 }).then(resp => {
|
||||
const data = resp?.data && typeof resp.data === 'object' ? resp.data : {}
|
||||
this.groupedFilterOptionsByKey = { ...this.groupedFilterOptionsByKey, [key]: data }
|
||||
|
||||
Reference in New Issue
Block a user