gitlytics 0.3.2__tar.gz → 0.4.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. {gitlytics-0.3.2 → gitlytics-0.4.1}/PKG-INFO +37 -5
  2. {gitlytics-0.3.2 → gitlytics-0.4.1}/README.md +35 -3
  3. {gitlytics-0.3.2 → gitlytics-0.4.1}/pyproject.toml +5 -3
  4. {gitlytics-0.3.2 → gitlytics-0.4.1}/src/gitlytics/__init__.py +18 -4
  5. {gitlytics-0.3.2 → gitlytics-0.4.1}/src/gitlytics/api.py +49 -4
  6. {gitlytics-0.3.2 → gitlytics-0.4.1}/src/gitlytics/cli.py +29 -0
  7. {gitlytics-0.3.2 → gitlytics-0.4.1}/src/gitlytics/core.py +220 -57
  8. gitlytics-0.4.1/src/gitlytics/static/_redirects +1 -0
  9. gitlytics-0.4.1/src/gitlytics/static/assets/CardModal-BMio-Yhe.js +1 -0
  10. gitlytics-0.4.1/src/gitlytics/static/assets/ExportModal-HdxhYxeV.js +1 -0
  11. gitlytics-0.4.1/src/gitlytics/static/assets/exports-CRz2A0EU.js +14 -0
  12. gitlytics-0.4.1/src/gitlytics/static/assets/index-CSjcErui.js +119 -0
  13. gitlytics-0.4.1/src/gitlytics/static/assets/index-D5qdeNvu.css +1 -0
  14. gitlytics-0.3.2/src/gitlytics/static/assets/index.es-BgNblKBK.js → gitlytics-0.4.1/src/gitlytics/static/assets/index.es-Dsx-ECMQ.js +1 -1
  15. gitlytics-0.3.2/src/gitlytics/static/assets/jspdf.es.min-D0gHkC9f.js → gitlytics-0.4.1/src/gitlytics/static/assets/jspdf.es.min-BPbddhZq.js +3 -3
  16. {gitlytics-0.3.2 → gitlytics-0.4.1}/src/gitlytics/static/index.html +25 -24
  17. {gitlytics-0.3.2 → gitlytics-0.4.1}/src/gitlytics.egg-info/PKG-INFO +37 -5
  18. {gitlytics-0.3.2 → gitlytics-0.4.1}/src/gitlytics.egg-info/SOURCES.txt +9 -4
  19. gitlytics-0.4.1/tests/test_star_history.py +154 -0
  20. gitlytics-0.3.2/src/gitlytics/static/assets/index-0jm8mzmF.js +0 -127
  21. gitlytics-0.3.2/src/gitlytics/static/assets/index-ClrHOmX2.css +0 -1
  22. {gitlytics-0.3.2 → gitlytics-0.4.1}/LICENSE +0 -0
  23. {gitlytics-0.3.2 → gitlytics-0.4.1}/setup.cfg +0 -0
  24. {gitlytics-0.3.2 → gitlytics-0.4.1}/src/gitlytics/__main__.py +0 -0
  25. {gitlytics-0.3.2 → gitlytics-0.4.1}/src/gitlytics/automation.py +0 -0
  26. {gitlytics-0.3.2 → gitlytics-0.4.1}/src/gitlytics/process.py +0 -0
  27. {gitlytics-0.3.2 → gitlytics-0.4.1}/src/gitlytics/static/android-chrome-192x192.png +0 -0
  28. {gitlytics-0.3.2 → gitlytics-0.4.1}/src/gitlytics/static/android-chrome-512x512.png +0 -0
  29. {gitlytics-0.3.2 → gitlytics-0.4.1}/src/gitlytics/static/apple-touch-icon.png +0 -0
  30. {gitlytics-0.3.2 → gitlytics-0.4.1}/src/gitlytics/static/assets/html2canvas-pro.esm-9xys3ejh.js +0 -0
  31. {gitlytics-0.3.2 → gitlytics-0.4.1}/src/gitlytics/static/assets/html2canvas.esm-DXEQVQnt.js +0 -0
  32. {gitlytics-0.3.2 → gitlytics-0.4.1}/src/gitlytics/static/assets/purify.es-CC4Brkr_.js +0 -0
  33. {gitlytics-0.3.2 → gitlytics-0.4.1}/src/gitlytics/static/favicon-16x16.png +0 -0
  34. {gitlytics-0.3.2 → gitlytics-0.4.1}/src/gitlytics/static/favicon-32x32.png +0 -0
  35. {gitlytics-0.3.2 → gitlytics-0.4.1}/src/gitlytics/static/favicon-48x48.png +0 -0
  36. {gitlytics-0.3.2 → gitlytics-0.4.1}/src/gitlytics/static/favicon.ico +0 -0
  37. {gitlytics-0.3.2 → gitlytics-0.4.1}/src/gitlytics/static/gitlytics-logo.png +0 -0
  38. {gitlytics-0.3.2 → gitlytics-0.4.1}/src/gitlytics/static/google-search-icon-48x48.png +0 -0
  39. {gitlytics-0.3.2 → gitlytics-0.4.1}/src/gitlytics/static/google-search-icon.png +0 -0
  40. {gitlytics-0.3.2 → gitlytics-0.4.1}/src/gitlytics/static/robots.txt +0 -0
  41. {gitlytics-0.3.2 → gitlytics-0.4.1}/src/gitlytics/static/sitemap.xml +0 -0
  42. {gitlytics-0.3.2 → gitlytics-0.4.1}/src/gitlytics.egg-info/dependency_links.txt +0 -0
  43. {gitlytics-0.3.2 → gitlytics-0.4.1}/src/gitlytics.egg-info/entry_points.txt +0 -0
  44. {gitlytics-0.3.2 → gitlytics-0.4.1}/src/gitlytics.egg-info/requires.txt +1 -1
  45. {gitlytics-0.3.2 → gitlytics-0.4.1}/src/gitlytics.egg-info/top_level.txt +0 -0
  46. {gitlytics-0.3.2 → gitlytics-0.4.1}/tests/test_api.py +0 -0
  47. {gitlytics-0.3.2 → gitlytics-0.4.1}/tests/test_automation.py +0 -0
  48. {gitlytics-0.3.2 → gitlytics-0.4.1}/tests/test_cli.py +0 -0
  49. {gitlytics-0.3.2 → gitlytics-0.4.1}/tests/test_core.py +0 -0
  50. {gitlytics-0.3.2 → gitlytics-0.4.1}/tests/test_process.py +0 -0
  51. {gitlytics-0.3.2 → gitlytics-0.4.1}/tests/test_username.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gitlytics
3
- Version: 0.3.2
3
+ Version: 0.4.1
4
4
  Summary: Monitor and automate your GitHub repository traffic analytics.
5
5
  Author-email: Ameya Chopade <ameyaccod171@gmail.com>
6
6
  License: Apache-2.0
@@ -17,7 +17,6 @@ Description-Content-Type: text/markdown
17
17
  License-File: LICENSE
18
18
  Requires-Dist: requests>=2.32.0
19
19
  Requires-Dist: pandas>=2.2.0
20
- Requires-Dist: python-dotenv>=1.0.1
21
20
  Requires-Dist: croniter>=2.0.0
22
21
  Provides-Extra: dashboard
23
22
  Requires-Dist: fastapi>=0.111.0; extra == "dashboard"
@@ -28,6 +27,7 @@ Requires-Dist: pytest>=8.0.0; extra == "dev"
28
27
  Requires-Dist: pytest-cov>=5.0.0; extra == "dev"
29
28
  Requires-Dist: httpx>=0.27.0; extra == "dev"
30
29
  Requires-Dist: anyio[trio]>=4.0.0; extra == "dev"
30
+ Requires-Dist: python-dotenv>=1.0.1; extra == "dev"
31
31
  Dynamic: license-file
32
32
 
33
33
  <div align="center">
@@ -78,14 +78,16 @@ Dynamic: license-file
78
78
  - [🚨 The 14-Day Catch (And How We Fix It)](#-the-14-day-catch-and-how-we-fix-it)
79
79
  - [🛠️ Installation](#installation)
80
80
  - [🔑 Generating a GitHub Personal Access Token](#generating-a-github-personal-access-token)
81
- - [⌨️ The 3 Core CLI Commands](#the-3-core-cli-commands)
81
+ - [⌨️ The 4 Core CLI Commands](#the-4-core-cli-commands)
82
82
  - [1️⃣ `gitlytics fetch` (Live Terminal Data)](#1-gitlytics-fetch-live-terminal-data)
83
83
  - [2️⃣ `gitlytics sync` (Background Database Cron)](#2-gitlytics-sync-background-database-cron)
84
84
  - [3️⃣ `gitlytics dashboard` (React Web UI)](#3-gitlytics-dashboard-react-web-ui)
85
+ - [4️⃣ `gitlytics stars` (Stargazer History)](#4-gitlytics-stars-stargazer-history)
85
86
  - [🐍 Native Python API](#native-python-api)
86
87
  - [1️⃣ `gitlytics.fetch_traffic()`](#1-gitlyticsfetch_traffic)
87
88
  - [2️⃣ `gitlytics.sync()`](#2-gitlyticssync)
88
89
  - [3️⃣ `gitlytics.serve_dashboard()`](#3-gitlyticsserve_dashboard)
90
+ - [4️⃣ `gitlytics.fetch_star_history()`](#4-gitlyticsfetch_star_history)
89
91
  - [📊 CSV Output Columns](#csv-output-columns)
90
92
  - [🌟 Show Your Support](#show-your-support)
91
93
  - [📄 License](#license)
@@ -134,9 +136,9 @@ To use the tools, you'll need a GitHub token.
134
136
 
135
137
  ---
136
138
 
137
- ## ⌨️ The 3 Core CLI Commands
139
+ ## ⌨️ The 4 Core CLI Commands
138
140
 
139
- Gitlytics is powered by 3 massive command-line tools. You can run them anywhere in your terminal.
141
+ Gitlytics is powered by 4 massive command-line tools. You can run them anywhere in your terminal.
140
142
 
141
143
  ### 1️⃣ `gitlytics fetch` (Live Terminal Data)
142
144
  Fetch your live 14-day traffic and print a beautiful ASCII table directly in your console.
@@ -170,6 +172,13 @@ gitlytics dashboard
170
172
  > gitlytics dashboard --token "ghp_xxx" --data-dir "./data"
171
173
  > ```
172
174
 
175
+ ### 4️⃣ `gitlytics stars` (Stargazer History)
176
+ Fetch the historical cumulative stargazer growth trajectory for a repository.
177
+ ```bash
178
+ # Fetch and print star history table
179
+ gitlytics stars owner/repo --token ghp_your_token
180
+ ```
181
+
173
182
  ---
174
183
 
175
184
  ## 🐍 Native Python API
@@ -279,6 +288,29 @@ gitlytics.serve_dashboard(
279
288
 
280
289
  ---
281
290
 
291
+ ### 4️⃣ `gitlytics.fetch_star_history()`
292
+ Fetches a list of cumulative star counts per date for a given repository.
293
+
294
+ ```python
295
+ import gitlytics
296
+
297
+ # Fetch stargazer history timeline
298
+ points = gitlytics.fetch_star_history(
299
+ owner="ameyac11",
300
+ repo="gitlytics",
301
+ token="ghp_your_token" # Optional for public repos, recommended to avoid rate limits
302
+ )
303
+ ```
304
+
305
+ #### ⚙️ Parameters:
306
+ | Parameter | Type | Default | Description |
307
+ |---|---|---|---|
308
+ | `owner` | `str` | *Required* | Owner of the repository. |
309
+ | `repo` | `str` | *Required* | Repository name. |
310
+ | `token` | `str` | `None` | Optional GitHub Personal Access Token. |
311
+
312
+ ---
313
+
282
314
 
283
315
  ## 📊 CSV Output Columns
284
316
 
@@ -46,14 +46,16 @@
46
46
  - [🚨 The 14-Day Catch (And How We Fix It)](#-the-14-day-catch-and-how-we-fix-it)
47
47
  - [🛠️ Installation](#installation)
48
48
  - [🔑 Generating a GitHub Personal Access Token](#generating-a-github-personal-access-token)
49
- - [⌨️ The 3 Core CLI Commands](#the-3-core-cli-commands)
49
+ - [⌨️ The 4 Core CLI Commands](#the-4-core-cli-commands)
50
50
  - [1️⃣ `gitlytics fetch` (Live Terminal Data)](#1-gitlytics-fetch-live-terminal-data)
51
51
  - [2️⃣ `gitlytics sync` (Background Database Cron)](#2-gitlytics-sync-background-database-cron)
52
52
  - [3️⃣ `gitlytics dashboard` (React Web UI)](#3-gitlytics-dashboard-react-web-ui)
53
+ - [4️⃣ `gitlytics stars` (Stargazer History)](#4-gitlytics-stars-stargazer-history)
53
54
  - [🐍 Native Python API](#native-python-api)
54
55
  - [1️⃣ `gitlytics.fetch_traffic()`](#1-gitlyticsfetch_traffic)
55
56
  - [2️⃣ `gitlytics.sync()`](#2-gitlyticssync)
56
57
  - [3️⃣ `gitlytics.serve_dashboard()`](#3-gitlyticsserve_dashboard)
58
+ - [4️⃣ `gitlytics.fetch_star_history()`](#4-gitlyticsfetch_star_history)
57
59
  - [📊 CSV Output Columns](#csv-output-columns)
58
60
  - [🌟 Show Your Support](#show-your-support)
59
61
  - [📄 License](#license)
@@ -102,9 +104,9 @@ To use the tools, you'll need a GitHub token.
102
104
 
103
105
  ---
104
106
 
105
- ## ⌨️ The 3 Core CLI Commands
107
+ ## ⌨️ The 4 Core CLI Commands
106
108
 
107
- Gitlytics is powered by 3 massive command-line tools. You can run them anywhere in your terminal.
109
+ Gitlytics is powered by 4 massive command-line tools. You can run them anywhere in your terminal.
108
110
 
109
111
  ### 1️⃣ `gitlytics fetch` (Live Terminal Data)
110
112
  Fetch your live 14-day traffic and print a beautiful ASCII table directly in your console.
@@ -138,6 +140,13 @@ gitlytics dashboard
138
140
  > gitlytics dashboard --token "ghp_xxx" --data-dir "./data"
139
141
  > ```
140
142
 
143
+ ### 4️⃣ `gitlytics stars` (Stargazer History)
144
+ Fetch the historical cumulative stargazer growth trajectory for a repository.
145
+ ```bash
146
+ # Fetch and print star history table
147
+ gitlytics stars owner/repo --token ghp_your_token
148
+ ```
149
+
141
150
  ---
142
151
 
143
152
  ## 🐍 Native Python API
@@ -247,6 +256,29 @@ gitlytics.serve_dashboard(
247
256
 
248
257
  ---
249
258
 
259
+ ### 4️⃣ `gitlytics.fetch_star_history()`
260
+ Fetches a list of cumulative star counts per date for a given repository.
261
+
262
+ ```python
263
+ import gitlytics
264
+
265
+ # Fetch stargazer history timeline
266
+ points = gitlytics.fetch_star_history(
267
+ owner="ameyac11",
268
+ repo="gitlytics",
269
+ token="ghp_your_token" # Optional for public repos, recommended to avoid rate limits
270
+ )
271
+ ```
272
+
273
+ #### ⚙️ Parameters:
274
+ | Parameter | Type | Default | Description |
275
+ |---|---|---|---|
276
+ | `owner` | `str` | *Required* | Owner of the repository. |
277
+ | `repo` | `str` | *Required* | Repository name. |
278
+ | `token` | `str` | `None` | Optional GitHub Personal Access Token. |
279
+
280
+ ---
281
+
250
282
 
251
283
  ## 📊 CSV Output Columns
252
284
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "gitlytics"
7
- version = "0.3.2"
7
+ version = "0.4.1"
8
8
  description = "Monitor and automate your GitHub repository traffic analytics."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -14,10 +14,11 @@ authors = [
14
14
  ]
15
15
  # Fix #20: Add version lower-bounds to prevent silent breakage on old environments.
16
16
  # These match the constraints already documented in requirements.txt.
17
+ # python-dotenv was removed from runtime deps — the library never reads .env;
18
+ # only tests use it, so it lives in the [dev] extra below.
17
19
  dependencies = [
18
20
  "requests>=2.32.0",
19
21
  "pandas>=2.2.0",
20
- "python-dotenv>=1.0.1",
21
22
  "croniter>=2.0.0"
22
23
  ]
23
24
  keywords = [
@@ -51,7 +52,8 @@ dev = [
51
52
  "pytest>=8.0.0",
52
53
  "pytest-cov>=5.0.0",
53
54
  "httpx>=0.27.0", # required by FastAPI TestClient (used in test_api.py)
54
- "anyio[trio]>=4.0.0" # async test support
55
+ "anyio[trio]>=4.0.0", # async test support
56
+ "python-dotenv>=1.0.1" # only tests load .env — runtime package doesn't
55
57
  ]
56
58
 
57
59
 
@@ -9,12 +9,26 @@ from pathlib import Path
9
9
 
10
10
  # Single source of truth for the package version.
11
11
  # Mirrors the version in pyproject.toml — keep them in sync.
12
- __version__ = "0.3.2"
13
-
14
- __all__ = ["fetch_traffic", "sync", "serve_dashboard", "__version__"]
12
+ __version__ = "0.4.1"
13
+
14
+ __all__ = [
15
+ "fetch_traffic",
16
+ "fetch_star_history",
17
+ "sync",
18
+ "serve_dashboard",
19
+ "__version__",
20
+ "GitHubRateLimitError",
21
+ "StarHistoryFetchError",
22
+ ]
15
23
 
16
24
  # Import the internal building blocks — users never call these directly
17
- from .core import fetch_traffic_data, print_repo_table
25
+ from .core import (
26
+ fetch_traffic_data,
27
+ fetch_star_history,
28
+ print_repo_table,
29
+ GitHubRateLimitError,
30
+ StarHistoryFetchError,
31
+ )
18
32
  from .automation import run_sync
19
33
  from .process import build_json_payload
20
34
 
@@ -8,10 +8,11 @@ import os
8
8
  import shutil
9
9
  import time as _time
10
10
  import uuid
11
+ from collections import OrderedDict
11
12
  from pathlib import Path
12
13
 
13
14
  import pandas as pd
14
- from fastapi import FastAPI, HTTPException, Body, File, UploadFile
15
+ from fastapi import FastAPI, HTTPException, Body, File, Header, Response, UploadFile
15
16
  from fastapi.responses import FileResponse, JSONResponse
16
17
  from fastapi.middleware.cors import CORSMiddleware
17
18
  from fastapi.staticfiles import StaticFiles
@@ -23,6 +24,9 @@ from gitlytics.core import (
23
24
  get_public_repos,
24
25
  fetch_traffic_data,
25
26
  fetch_deep_stats_for_top,
27
+ fetch_star_history,
28
+ GitHubRateLimitError,
29
+ StarHistoryFetchError,
26
30
  )
27
31
  from gitlytics.process import process_uploaded_csv, build_react_payload
28
32
 
@@ -52,8 +56,13 @@ app.add_middleware(
52
56
  )
53
57
 
54
58
 
55
- _auth_cache: dict = {} # sha256_prefix -> (valid, username, expires_at)
59
+ # In-process short-term cache for token validation. Cleared when the
60
+ # Python process exits — same lifetime as the CLI / FastAPI worker.
61
+ # OrderedDict + insert-order eviction gives us a bounded LRU without
62
+ # pulling in functools.lru_cache (which can't be cleared on TTL).
63
+ _auth_cache: "OrderedDict[str, tuple]" = OrderedDict()
56
64
  _AUTH_CACHE_TTL = 300 # 5 minutes
65
+ _AUTH_CACHE_MAX = 256 # cap entries so a long-running worker can't grow unbounded
57
66
 
58
67
  # Hard cap on CSV upload size — prevents DoS via /api/upload-csv.
59
68
  _MAX_UPLOAD_BYTES = 25 * 1024 * 1024
@@ -71,12 +80,18 @@ def _validate_token_cached(token: str):
71
80
  from gitlytics.core import validate_token as _validate_token
72
81
  key = hashlib.sha256(token.encode()).hexdigest()[:16]
73
82
  now = _time.time()
74
- if key in _auth_cache:
75
- valid, username, expires = _auth_cache[key]
83
+ cached = _auth_cache.get(key)
84
+ if cached is not None:
85
+ valid, username, expires = cached
76
86
  if now < expires:
87
+ # Refresh insertion order so an active key isn't evicted FIFO-style.
88
+ _auth_cache.move_to_end(key)
77
89
  return valid, username
78
90
  valid, username = _validate_token(token)
79
91
  _auth_cache[key] = (valid, username, now + _AUTH_CACHE_TTL)
92
+ _auth_cache.move_to_end(key)
93
+ while len(_auth_cache) > _AUTH_CACHE_MAX:
94
+ _auth_cache.popitem(last=False)
80
95
  return valid, username
81
96
 
82
97
 
@@ -208,6 +223,36 @@ def get_traffic(token: str = Body("", embed=True)):
208
223
  return payload
209
224
 
210
225
 
226
+ # Star history endpoint — sampled star timeline for the SPA chart.
227
+ # Accepts the token via Authorization: Bearer header (PAT) so the chart
228
+ # can hit its own backend without exposing the token to the cloud.
229
+ # Falls back to GITLYTICS_TOKEN env so the local widget still works
230
+ # for users who stored their PAT in env instead of the LoginView.
231
+ @app.get("/api/star-history")
232
+ def get_star_history_endpoint(
233
+ owner: str,
234
+ repo: str,
235
+ response: Response,
236
+ authorization: str | None = Header(default=None),
237
+ ):
238
+ bearer = ""
239
+ if authorization and authorization.lower().startswith("bearer "):
240
+ bearer = authorization.split(" ", 1)[1].strip()
241
+ token = bearer or os.environ.get("GITLYTICS_TOKEN")
242
+ try:
243
+ points = fetch_star_history(owner, repo, token)
244
+ except GitHubRateLimitError as exc:
245
+ # Surface rate-limit hits as 429 so the SPA shows the chart's rate-limit UI.
246
+ raise HTTPException(status_code=429, detail=str(exc))
247
+ except StarHistoryFetchError as exc:
248
+ # Validation / metadata / network failures are caller errors — 400 makes more
249
+ # sense than 429 here so the SPA can distinguish "GitHub is throttling us"
250
+ # from "your request was malformed".
251
+ raise HTTPException(status_code=400, detail=str(exc))
252
+ response.headers["Cache-Control"] = "public, max-age=86400"
253
+ return {"owner": owner, "repo": repo, "points": points}
254
+
255
+
211
256
  @app.post("/api/upload-csv")
212
257
  def upload_csv(file: UploadFile = File(...)):
213
258
  try:
@@ -9,6 +9,7 @@ import os
9
9
 
10
10
  # Import the three public functions that power every subcommand
11
11
  from gitlytics import fetch_traffic, sync, serve_dashboard
12
+ from gitlytics.core import fetch_star_history
12
13
 
13
14
 
14
15
  def parse_repo_names(repo_arg: str):
@@ -76,6 +77,11 @@ def main():
76
77
  dash_parser.add_argument("-t", "--token", help="GitHub token for headless TV display.")
77
78
  dash_parser.add_argument("--data-dir", help="Inject historical CSV database.")
78
79
 
80
+ # ── STARS subcommand ───────────────────────────────────────────────────────
81
+ stars_parser = subparsers.add_parser("stars", help="Fetch sampled star history for a repo.")
82
+ stars_parser.add_argument("repo", help="Repository in 'owner/repo' form (e.g. ameyac11/gitlytics).")
83
+ stars_parser.add_argument("-t", "--token", help="GitHub Personal Access Token.")
84
+
79
85
  args = parser.parse_args()
80
86
 
81
87
  # Print help and exit cleanly (code 0) if the user didn't give a subcommand.
@@ -153,6 +159,29 @@ def main():
153
159
  data_dir=args.data_dir
154
160
  )
155
161
 
162
+ elif args.command == "stars":
163
+ owner, _, repo = args.repo.partition("/")
164
+ if not owner or not repo:
165
+ print("❌ Error: repo must be in 'owner/repo' form.")
166
+ sys.exit(2)
167
+ try:
168
+ points = fetch_star_history(owner, repo, token)
169
+ except ValueError as exc:
170
+ # Bad input — non-zero exit so scripts can branch on it.
171
+ print(f"❌ Error: {exc}")
172
+ sys.exit(2)
173
+ except Exception as exc:
174
+ # Anything else (rate limit, network, etc.) — exit 1 so CI knows it failed.
175
+ print(f"❌ Error: {exc}")
176
+ sys.exit(1)
177
+ # Tabulate date + total stars.
178
+ print(f"{'DATE':<12} {'TOTAL STARS':>12}")
179
+ print("-" * 24)
180
+ for p in points:
181
+ print(f"{p['date']:<12} {p['total']:>12,}")
182
+ print("-" * 24)
183
+ print(f"{len(points)} sampled point(s)")
184
+
156
185
 
157
186
  if __name__ == "__main__":
158
187
  main()