• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kimata / server-list / 20822662028

08 Jan 2026 03:47PM UTC coverage: 90.426% (-0.5%) from 90.885%
20822662028

push

github

kimata
CLAUDE.md を作成

Claude Code 向けのプロジェクトガイダンスを追加:
- 概要とアーキテクチャ説明
- ディレクトリ構成とコアコンポーネント解説
- API エンドポイント一覧
- 設定ファイル(config.yaml, secret.yaml)の説明
- 開発コマンド(テスト、ビルド、実行)
- コーディング規約(インポートスタイル、型チェック)
- my-lib 共通ライブラリの修正手順
- py-project テンプレートの扱いについて

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

680 of 752 relevant lines covered (90.43%)

0.9 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.89
/src/server_list/spec/webapi/cpu.py
1
#!/usr/bin/env python3
2
"""
3
Web API for CPU benchmark data.
4
Endpoint: /server-list/api/cpu/benchmark
5
"""
6

7
from flask import Blueprint, jsonify, request
1✔
8

9
from server_list.spec.cpu_benchmark import (
1✔
10
    get_benchmark,
11
    fetch_and_save_benchmark,
12
    init_db,
13
)
14

15
cpu_api = Blueprint("cpu_api", __name__)
1✔
16

17
# Initialize database once at module load
18
init_db()
1✔
19

20

21
@cpu_api.route("/cpu/benchmark", methods=["GET"])
1✔
22
def get_cpu_benchmark():
1✔
23
    """
24
    Get CPU benchmark score.
25

26
    Query parameters:
27
        cpu: CPU name to look up (required)
28
        fetch: If "true", fetch from web if not in cache (optional)
29

30
    Returns:
31
        JSON with cpu_name, multi_thread_score, single_thread_score
32
    """
33
    cpu_name = request.args.get("cpu")
1✔
34

35
    if not cpu_name:
1✔
36
        return jsonify({"error": "CPU name is required"}), 400
1✔
37

38
    # Check database first
39
    result = get_benchmark(cpu_name)
1✔
40

41
    if result:
1✔
42
        return jsonify({
1✔
43
            "success": True,
44
            "data": result,
45
            "source": "cache"
46
        })
47

48
    # Optionally fetch from web
49
    if request.args.get("fetch", "").lower() == "true":
1✔
50
        result = fetch_and_save_benchmark(cpu_name)
1✔
51
        if result:
1✔
52
            return jsonify({
1✔
53
                "success": True,
54
                "data": result,
55
                "source": "web"
56
            })
57

58
    return jsonify({
1✔
59
        "success": False,
60
        "error": f"Benchmark data not found for: {cpu_name}"
61
    }), 404
62

63

64
@cpu_api.route("/cpu/benchmark/batch", methods=["POST"])
1✔
65
def get_cpu_benchmarks_batch():
1✔
66
    """
67
    Get CPU benchmark scores for multiple CPUs.
68

69
    Request body (JSON):
70
        cpus: List of CPU names to look up
71
        fetch: If true, fetch from web if not in cache (optional)
72

73
    Returns:
74
        JSON with results for each CPU
75
    """
76
    data = request.get_json()
1✔
77

78
    if not data or "cpus" not in data:
1✔
79
        return jsonify({"error": "CPU list is required"}), 400
1✔
80

81
    cpu_list = data["cpus"]
1✔
82
    should_fetch = data.get("fetch", False)
1✔
83
    results = {}
1✔
84

85
    for cpu_name in cpu_list:
1✔
86
        result = get_benchmark(cpu_name)
1✔
87
        if result:
1✔
88
            results[cpu_name] = {
1✔
89
                "success": True,
90
                "data": result,
91
                "source": "cache"
92
            }
93
        elif should_fetch:
1✔
94
            # Fetch from web if not in cache
95
            result = fetch_and_save_benchmark(cpu_name)
×
96
            if result:
×
97
                results[cpu_name] = {
×
98
                    "success": True,
99
                    "data": result,
100
                    "source": "web"
101
                }
102
            else:
103
                results[cpu_name] = {
×
104
                    "success": False,
105
                    "data": None
106
                }
107
        else:
108
            results[cpu_name] = {
1✔
109
                "success": False,
110
                "data": None
111
            }
112

113
    return jsonify({
1✔
114
        "success": True,
115
        "results": results
116
    })
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc