andygrunwald / andygrunwald/go-trending

Project.Stars returns total stargazers instead of trending stars

Offen
#67 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Go
Sterne
147
Forks
21
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

### Bug
`Project.Stars` is documented as "the number of GitHub stars this project received in the given timeframe", but the parser currently extracts the **total** stargazer count from the repository link instead of the "stars today/week/month" value shown on the trending page.

### Where it happens
In `GetProjects`, the code uses:
```go
starsString := s.Find("div a[href$=\"/stargazers\"]").Text()
```
This selects the total stargazer link (e.g. `5,096` in `testdata/github.com_trending.html`). The trending delta is in the trailing span (e.g. `1,582 stars today`).

### Repro (using bundled testdata)
1. Parse `testdata/github.com_trending.html`.
2. For `smol-ai/developer`, the HTML shows `5,096` total stars but `1,582 stars today`.
3. `Project.Stars` becomes `5096`, not `1582`, which contradicts the doc comment and expected timeframe semantics.

### Expected
`Project.Stars` should reflect the timeframe stars (e.g. `1,582`), matching the docstring and GitHub’s trending UI.

### Suggested fix
Parse the trailing "stars today/week/month" span (e.g. `span.d-inline-block.float-sm-right`) and extract the numeric portion (strip commas). If you prefer to keep total stars, please update the docstring to avoid the mismatch.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.