diff options
author | Dmitry Ilvokhin <d@ilvokhin.com> | 2025-03-18 22:08:34 +0000 |
---|---|---|
committer | Dmitry Ilvokhin <d@ilvokhin.com> | 2025-03-18 22:08:34 +0000 |
commit | 3a5909f9779ff2978a7e12ff23bf934aa55c1dc6 (patch) | |
tree | 68c9a3558939d8f849ef2eacbc777a6075b2aaeb /parse.go | |
parent | bbf5d9d99aa6131dccada8908b770ac10f52be59 (diff) | |
download | flatbot-3a5909f9779ff2978a7e12ff23bf934aa55c1dc6.tar.gz flatbot-3a5909f9779ff2978a7e12ff23bf934aa55c1dc6.tar.bz2 flatbot-3a5909f9779ff2978a7e12ff23bf934aa55c1dc6.zip |
Sort and unique fetched flats
There are cases (premium listings is one example), when there are
duplicates in the fetched flats, unique them to avoid multiple
notifications for the same property.
Diffstat (limited to 'parse.go')
-rw-r--r-- | parse.go | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -4,6 +4,7 @@ import ( "bytes" "errors" "fmt" + "slices" "strconv" "strings" @@ -23,6 +24,10 @@ func parse(body []byte) ([]flat, error) { } flats = append(flats, flat) } + slices.SortFunc(flats, compareID) + flats = slices.CompactFunc(flats, func(a, b flat) bool { + return compareID(a, b) == 0 + }) return flats, nil } |