Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 1 addition & 24 deletions .github/workflows/update-indexes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,7 @@ jobs:
--schemafile firstdata/schemas/datasource-schema.json

- name: Check for duplicate IDs
run: |
uv run python - <<'EOF'
import json, sys
from pathlib import Path

seen = {}
errors = []

for path in sorted(Path("firstdata/sources").rglob("*.json")):
data = json.loads(path.read_text(encoding="utf-8"))
id_ = data.get("id")
if id_ in seen:
errors.append(f"Duplicate id '{id_}' in:\n {seen[id_]}\n {path}")
else:
seen[id_] = path

if errors:
print("❌ Duplicate IDs found:")
for e in errors:
print(e)
sys.exit(1)

print(f"✅ All {len(seen)} IDs are unique.")
EOF
run: uv run python scripts/check_ids.py

- name: Rebuild indexes
run: uv run python scripts/build_indexes.py
Expand Down
25 changes: 1 addition & 24 deletions .github/workflows/validate-sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,4 @@ jobs:
--schemafile firstdata/schemas/datasource-schema.json

- name: Check for duplicate IDs
run: |
uv run python - <<'EOF'
import json, sys
from pathlib import Path

seen = {}
errors = []

for path in sorted(Path("firstdata/sources").rglob("*.json")):
data = json.loads(path.read_text(encoding="utf-8"))
id_ = data.get("id")
if id_ in seen:
errors.append(f"Duplicate id '{id_}' in:\n {seen[id_]}\n {path}")
else:
seen[id_] = path

if errors:
print("❌ Duplicate IDs found:")
for e in errors:
print(e)
sys.exit(1)

print(f"✅ All {len(seen)} IDs are unique.")
EOF
run: uv run python scripts/check_ids.py
24 changes: 24 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.PHONY: validate check-ids check build-indexes help

help:
@echo "Usage:"
@echo " make validate Validate all source JSON files against the schema"
@echo " make check-ids Check for duplicate IDs across all source files"
@echo " make check Run all checks (validate + check-ids)"
@echo " make build-indexes Rebuild all index and badge files"

validate:
@echo "Validating source JSON files..."
@find firstdata/sources -name "*.json" | xargs uv run check-jsonschema \
--schemafile firstdata/schemas/datasource-schema.json
@echo "✅ All files are valid."

check-ids:
@echo "Checking for duplicate IDs..."
@uv run python scripts/check_ids.py

check: validate check-ids

build-indexes:
@echo "Building indexes and badges..."
@uv run python scripts/build_indexes.py
76 changes: 0 additions & 76 deletions firstdata/sources/academic/economics/bis-statistics.json

This file was deleted.

109 changes: 0 additions & 109 deletions firstdata/sources/sectors/education/arwu.json

This file was deleted.

32 changes: 32 additions & 0 deletions scripts/check_ids.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""Check for duplicate IDs across all source JSON files."""

import json
import sys
from pathlib import Path

SOURCES_DIR = Path(__file__).parent.parent / "firstdata" / "sources"


def main() -> None:
seen: dict[str, Path] = {}
errors: list[str] = []

for path in sorted(SOURCES_DIR.rglob("*.json")):
data = json.loads(path.read_text(encoding="utf-8"))
id_ = data.get("id")
if id_ in seen:
errors.append(f"Duplicate id '{id_}' in:\n {seen[id_]}\n {path}")
else:
seen[id_] = path

if errors:
print("❌ Duplicate IDs found:")
for e in errors:
print(e)
sys.exit(1)

print(f"✅ All {len(seen)} IDs are unique.")


if __name__ == "__main__":
main()