How Project Star Counts Are Validated and Filtered in the HelloGitHub Data Pipeline

The HelloGitHub data pipeline validates star counts by querying the GitHub API for stargazers_count, filtering out repositories below a configurable 100-star threshold while preserving projects with unknown counts flagged as -1.

The 521xueweihan/HelloGitHub repository automates the curation of trending open-source projects through a Python-based bot that processes live GitHub Events API data. Understanding how project star counts are validated and filtered in the data pipeline reveals the quality controls that ensure only notable, organically popular repositories reach the weekly email reports.

Event Extraction and Initial Filtering

The pipeline begins by isolating relevant star activity from the firehose of GitHub events, applying temporal and ownership filters before any star counts are fetched.

Isolating Recent WatchEvent Actions

In script/github_bot/github_bot.py, the check_condition() function (lines 8-15) filters the raw GitHub Events stream to process only WatchEvent actions—GitHub's internal name for "star" events—that occurred within the last DAY (1 day). This ensures the newsletter reflects only recent trending activity rather than stale historical data.

Excluding Self-Promotion

The same check_condition() logic excludes stars cast on the bot author's own repositories. This validation step prevents self-promotion bias, ensuring the pipeline only tracks organic community interest in external projects.

Fetching and Validating Star Counts

Once initial filtering isolates valid star events, the pipeline queries live repository data to enforce minimum popularity standards.

GitHub API Integration

For each qualifying event, the get_stars() function (lines 47-55) constructs an HTTP request to the repository's GitHub API URL (fi_data['repo']['url']). It extracts the stargazers_count field to obtain the current, authoritative star count directly from GitHub's database.

Handling API Failures

If the request fails or returns no data, the function assigns a star count of -1 to flag the repository as having an unknown count. This failure-tolerant design prevents temporary network issues or API rate limits from silently dropping potentially valid projects.

Enforcing the Minimum Threshold

At lines 58-62, get_stars() implements the core validation logic: a project is accepted only if its star count meets or exceeds the STARS configuration threshold (defaulting to 100) or if the count equals -1. Projects with confirmed star counts below this threshold are discarded immediately and excluded from the email report.

Sorting and Final Output

After validation, lines 63-65 sort the accepted projects in descending order by star count. This prioritization ensures the most popular repositories appear first in the rendered email template, giving readers immediate access to the highest-impact projects.

Practical Implementation Example

The following code demonstrates the complete workflow from event extraction to filtered output:


# Example: Using the pipeline to fetch and filter starred projects

from script.github_bot.github_bot import get_all_data, analyze, get_stars

# 1️⃣ Pull the latest 300 events (max allowed by GitHub)

events = get_all_data()

# 2️⃣ Keep only recent star events (WatchEvent) that pass the date check

star_events = analyze(events)

# 3️⃣ Retrieve star counts and filter out low‑star projects

#    (Only projects with ≥100 stars or unknown star count are kept)

filtered_projects = get_stars(star_events)

# 4️⃣ Show the top 5 projects that will appear in the email

for proj in filtered_projects[:5]:
    print(f"{proj['repo_name']:30}{proj['repo_stars']}")

Running this snippet yields a list of repositories ordered by star count, with any repository having fewer than 100 stars removed from the output unless its count could not be determined.

Summary

  • The pipeline extracts only recent WatchEvent actions from the last 24 hours while excluding self-stars via check_condition() in script/github_bot/github_bot.py.
  • get_stars() fetches live star counts from the GitHub API and assigns -1 to failed requests to prevent data loss during network interruptions.
  • Projects must have ≥100 stars (or unknown counts flagged as -1) to pass validation; all others are filtered out before the sorting stage.
  • Final output is sorted descending by star count to prioritize the most popular repositories in the weekly email reports.

Frequently Asked Questions

What happens when the GitHub API fails to return a star count?

When the API request in get_stars() fails or returns empty data, the pipeline assigns a star count of -1 to that repository according to lines 47-55 of script/github_bot/github_bot.py. This unknown status allows the project to pass the validation filter at lines 58-62, ensuring temporary API issues do not exclude potentially valid repositories from the report.

Why does the pipeline exclude stars on the author's own repositories?

The check_condition() function filters out WatchEvent actions on the bot author's own repositories to prevent self-promotion bias. This validation ensures the HelloGitHub newsletter only features organically popular projects discovered by the broader community rather than the curator's own work.

Can the minimum star threshold be configured?

Yes, the STARS configuration variable (defaulting to 100) controls the minimum threshold in get_stars(). Repositories must meet or exceed this value to be included in the final report, though projects with unknown counts (-1) bypass this requirement to avoid data loss from API failures.

How does the pipeline determine which star events to process?

The pipeline processes only WatchEvent actions from the GitHub Events API that occurred within the last DAY (1 day). This temporal filtering logic in check_condition() (lines 8-15 of script/github_bot/github_bot.py) ensures the newsletter reflects recent trending activity rather than aggregating historical star data.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →