mirror of https://github.com/velour/catbase.git
webshit: fix URL matching to use query string
This commit is contained in:
parent
2103cfbca0
commit
705aa294d5
|
@ -70,3 +70,4 @@ util/*/files
|
||||||
run.sh
|
run.sh
|
||||||
.idea
|
.idea
|
||||||
logs
|
logs
|
||||||
|
util/files
|
||||||
|
|
|
@ -123,7 +123,13 @@ func (w *Webshit) Check() ([]WeeklyResult, error) {
|
||||||
|
|
||||||
storyMap := map[string]Story{}
|
storyMap := map[string]Story{}
|
||||||
for _, s := range stories {
|
for _, s := range stories {
|
||||||
storyMap[s.URL] = s
|
u, err := url.Parse(s.URL)
|
||||||
|
if err != nil {
|
||||||
|
log.Error().Err(err).Msg("couldn't parse URL")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
id := u.Query().Get("id")
|
||||||
|
storyMap[id] = s
|
||||||
}
|
}
|
||||||
|
|
||||||
wr := w.checkBids(bids, storyMap)
|
wr := w.checkBids(bids, storyMap)
|
||||||
|
@ -162,7 +168,14 @@ func (w *Webshit) checkBids(bids []Bid, storyMap map[string]Story) []WeeklyResul
|
||||||
}
|
}
|
||||||
rec := wr[b.User]
|
rec := wr[b.User]
|
||||||
|
|
||||||
if s, ok := storyMap[b.URL]; ok {
|
u, err := url.Parse(b.URL)
|
||||||
|
if err != nil {
|
||||||
|
log.Error().Err(err).Msg("couldn't parse URL")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
id := u.Query().Get("id")
|
||||||
|
|
||||||
|
if s, ok := storyMap[id]; ok {
|
||||||
log.Debug().Interface("story", s).Msg("won bid")
|
log.Debug().Interface("story", s).Msg("won bid")
|
||||||
rec.Won += b.Bid
|
rec.Won += b.Bid
|
||||||
rec.Score += b.Bid
|
rec.Score += b.Bid
|
||||||
|
|
Loading…
Reference in New Issue