added from stores
This commit is contained in:
parent
f4bd2a69e4
commit
08d2446329
@ -45,3 +45,49 @@ func (f StoreFilter) Filter (stores []Store) []Store {
|
|||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ListingFilter struct{
|
||||||
|
Limit int
|
||||||
|
|
||||||
|
IncludeIds []int
|
||||||
|
ExcludeIds []int
|
||||||
|
|
||||||
|
FromStores []int
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func (f ListingFilter) Filter (listings []Listing) []Listing {
|
||||||
|
result := make([]Listing, 0)
|
||||||
|
|
||||||
|
if len(f.IncludeIds) > 0 {
|
||||||
|
for _, l := range listings {
|
||||||
|
if f.Limit > 0 && len(result) >= f.Limit {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if slices.Contains(f.IncludeIds, l.Id) {
|
||||||
|
result = append(result, l)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for _, l := range listings {
|
||||||
|
if f.Limit > 0 && len(result) >= f.Limit {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if slices.Contains(f.ExcludeIds, l.Id) || slices.Contains(f.IncludeIds, l.Id) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(f.FromStores) > 0 && !slices.Contains(f.FromStores, l.Store.Id) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
result = append(result, l)
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
@ -17,6 +17,7 @@ type RenderingConfig struct {
|
|||||||
SearchInputName string
|
SearchInputName string
|
||||||
|
|
||||||
StoreFilter diyhrt.StoreFilter
|
StoreFilter diyhrt.StoreFilter
|
||||||
|
ListingFilter diyhrt.ListingFilter
|
||||||
|
|
||||||
Listings []diyhrt.Listing
|
Listings []diyhrt.Listing
|
||||||
Stores []diyhrt.Store
|
Stores []diyhrt.Store
|
||||||
@ -44,6 +45,10 @@ func DefaultRenderingConfig() RenderingConfig {
|
|||||||
Limit: 0,
|
Limit: 0,
|
||||||
IncludeIds: []int{7},
|
IncludeIds: []int{7},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
ListingFilter: diyhrt.ListingFilter{
|
||||||
|
FromStores: []int{7},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,6 +59,6 @@ func (rc *RenderingConfig) LoadDiyHrt(listings []diyhrt.Listing) {
|
|||||||
existingStores[listing.Store.Id] = listing.Store
|
existingStores[listing.Store.Id] = listing.Store
|
||||||
}
|
}
|
||||||
|
|
||||||
rc.Listings = listings
|
rc.Listings = rc.ListingFilter.Filter(listings)
|
||||||
rc.Stores = rc.StoreFilter.Filter(slices.Collect(maps.Values(existingStores)))
|
rc.Stores = rc.StoreFilter.Filter(slices.Collect(maps.Values(existingStores)))
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1
|
exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1
|
Loading…
x
Reference in New Issue
Block a user