Add webhook submission script for cached curriculum data #3
+426
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implements tooling to submit cached semester and section data to webhook endpoints for integration with Life-USTC/server-nextjs.
Implementation
scripts/submit-via-webhook.py: Python CLI tool that:catalog/api/teach/semester/list.jsoncatalog/api/teach/lesson/list-for-teach/{semester_id}.jsonscripts/README.md: Usage documentation and GitHub Actions integration exampleUsage
Payload Format
Each semester submitted as:
{ "semester": {"id": 401, "nameZh": "2024秋季学期", ...}, "sections": [{"id": 12345, "code": "MATH101-01", ...}, ...] }Default cache root:
./build/cache(matches existing build process)Original prompt
Implement webhook submission tooling for the Life-USTC/static repository to integrate with the new webhook API described in Life-USTC/server-nextjs PR #1.
Goals:
Add a Python helper script (e.g., submit-via-webhook.py under a suitable scripts/tooling path) that:
• Semesters: catalog/api/teach/semester/list.json
• Sections: catalog/api/teach/lesson/list-for-teach/<semester_jw_id>.json
• Schedules: jw/api/schedule-table/datum/<section_jw_id>.json
Add/update Python dependency declarations (e.g., requirements.txt or the repo’s existing dependency file) to include requests (or an alternative HTTP client if you choose to switch). Use a modern pinned version (e.g., requests>=2.31.0) unless the repo has conventions you should follow.
Add brief documentation (e.g., README snippet or a new docs file) covering usage examples:
Notes and flexibility:
Definition of done:
Provided reference script (you may adapt):
#!/usr/bin/env python3
"""
Submit data from Life-USTC/static repository to the webhook API.
This script reads JSON files from the static cache and submits them via webhook.
"""
import json
import os
import sys
from pathlib import Path
from typing import Any, Dict, List, Optional
import requests
class WebhookSubmitter:
"""Submit course and schedule data via webhook API."""
This pull request was created as a result of the following prompt from Copilot chat.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.