From 27adda431f765bfb7d1f5bfb588267e92ce32955 Mon Sep 17 00:00:00 2001 From: Hazel Noack Date: Thu, 10 Jul 2025 14:11:34 +0200 Subject: [PATCH] specifically included otonoko pharmaceuticals --- internal/diyhrt/filter.go | 22 ++++++++++++++-------- internal/rendering/config.go | 17 +++++++---------- tmp/build-errors.log | 2 +- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/internal/diyhrt/filter.go b/internal/diyhrt/filter.go index 979fa60..bba4f3f 100644 --- a/internal/diyhrt/filter.go +++ b/internal/diyhrt/filter.go @@ -17,20 +17,26 @@ type StoreFilter struct{ func (f StoreFilter) Filter (stores []Store) []Store { result := make([]Store, 0) + if len(f.IncludeIds) > 0 { + for _, s := range stores { + if f.Limit > 0 && len(result) >= f.Limit { + break + } + + if slices.Contains(f.IncludeIds, s.Id) { + result = append(result, s) + } + } + } + + for _, s := range stores { if f.Limit > 0 && len(result) >= f.Limit { break } - if len(f.IncludeIds) > 0 { - if slices.Contains(f.IncludeIds, s.Id) { - result = append(result, s) - } - continue - } - - if slices.Contains(f.ExcludeIds, s.Id) { + if slices.Contains(f.ExcludeIds, s.Id) || slices.Contains(f.IncludeIds, s.Id) { continue } diff --git a/internal/rendering/config.go b/internal/rendering/config.go index 732035d..31c9202 100644 --- a/internal/rendering/config.go +++ b/internal/rendering/config.go @@ -1,8 +1,10 @@ package rendering import ( + "maps" + "slices" + "gitea.elara.ws/Hazel/transfem-startpage/internal/diyhrt" - "fmt" ) type RenderingConfig struct { @@ -40,23 +42,18 @@ func DefaultRenderingConfig() RenderingConfig { StoreFilter: diyhrt.StoreFilter{ Limit: 4, + IncludeIds: []int{7}, }, } } func (rc *RenderingConfig) LoadDiyHrt(listings []diyhrt.Listing) { - existingStores := make(map[int]struct{}) - stores := make([]diyhrt.Store, 0) + existingStores := make(map[int]diyhrt.Store) for _, listing := range listings { - if _, ok := existingStores[listing.Store.Id]; ok { - continue - } - - fmt.Println(listing.Store.ShipsToCountry) - stores = append(stores, listing.Store) + existingStores[listing.Store.Id] = listing.Store } rc.Listings = listings - rc.Stores = rc.StoreFilter.Filter(stores) + rc.Stores = rc.StoreFilter.Filter(slices.Collect(maps.Values(existingStores))) } diff --git a/tmp/build-errors.log b/tmp/build-errors.log index 9bb8b56..f208b22 100644 --- a/tmp/build-errors.log +++ b/tmp/build-errors.log @@ -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 1 \ No newline at end of file +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 \ No newline at end of file