Retire duplicate statistics display helper through the pinned coursework API

Đang mở
#453 6 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
backend, ci-cd, testing-qa

Hướng nghiên cứu

Read the listed course, security, verification, architecture and CI specifications, then inspect courses/models/stat_display.py, the imports and calls in courses/models/homework.py and project.py, and the project_statistics view. Review the released community_base coursework helper and add courses/tests/test_statistics_display_contract.py with the specified gate enrollment. Done means the duplicate module is deleted, callers use the public helper, existing behavior tests pass, and the required verification evidence is complete.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

courses enhancement P1

Retire duplicate statistics display through the pinned coursework API

Status: groomed; ready for isolated local implementation
Area: courses
Priority: P1
Type: enhancement
Depends on: no new package capability or release; the current immutable pin supplies the public helper.

Goal and normative references

Remove the 158-line site statistics-display helper without changing learner or staff behavior, visible pages, or the current database and course model contracts.

Read first:

  • _docs/specs/04-courses-and-cohorts.md: preserve homework/project statistics and characterize before structural changes.
  • _docs/specs/07-security-privacy-operations.md, _docs/specs/10-verification-strategy.md, and _docs/architecture/app-boundaries.md at the implementation base.
  • _docs/PROCESS.md and _docs/ci/change-selective-ci.md: role separation, versioned verification, browser impact and delivery.
  • Current protected coding authority /home/alexey/git/dtc-website/coding-standard.md, read-only even when absent from the isolated implementation base.
  • Released public community_base.coursework.stat_display, already installed through v0.5.10 at commit 4c692db461f4c7cbbc2f60afaa05162987a640f6.

The audit establishes source-derived equivalence and caller reachability, not runtime parity. No dependency bump, package edit, tag, or local/path/branch install is needed. D5.1/#414 model adoption, C5.3 and package PR402 are not dependencies of this object-taking pure helper.

Exact scope and ownership

Use an isolated issue worktree based on committed 106c777d2cd39666afb5f0990c7301fe5ad418c3. Root assigned this new concern only; shared main and foreign work remain protected.

Production writes are limited to:

  1. Delete courses/models/stat_display.py.
  2. In courses/models/homework.py, replace its helper import and qualify the existing calls in HomeworkStatistics.get_stat_fields.
  3. In courses/models/project.py, replace its helper import and qualify the existing calls in ProjectStatistics.get_stat_fields.
  4. In courses/views/project_statistics.py, retarget the direct import to from community_base.coursework.stat_display import project_stat_sections, preserving the entire project_statistics_sections function byte-for-byte. It is already 33 lines; this import-only seam avoids materially changing or growing that oversized function.

In the two model files use the package public module directly, for example from community_base.coursework import stat_display as display, after checking alias collisions. The view uses the direct public symbol import above; no forwarding wrapper is added. No facade, forwarding function, second section builder or copied helper remains. Preserve the existing site get_value, view loop and all other methods.

Test writes are limited to a new cohesive courses/tests/test_statistics_display_contract.py for missing authoritative coverage. Existing model/view tests are read and executed; editing them requires a separate exact allocation. Ignored issue evidence belongs under .tmp/.

Required gate enrollment (narrow scope amendment)

At the committed base, the new test and the existing relevant statistics test modules are excluded from the adoption lint/format/type opt-ins. Moving coverage into an unrelated opted-in test is not an alternative to enrolling its actual owner. Root approved these additional metadata slices before any source edits:

  • scripts/ci.py: add only courses/tests/test_statistics_display_contract.py as one literal entry in the existing ADOPTION_INTEGRATION_PYTHON catalog.
  • pyproject.toml: add only courses.tests.test_statistics_display_contract to the existing strict module override. Dependency, package source and every other setting remain unchanged.
  • core/tests/test_deployment_workflow.py: update only STUDIO_COURSES_PYPROJECT_SHA256 to the actual final pyproject bytes and add the issue #453 configuration-only history annotation, following the existing reviewed seal procedure. SECURITY_REMEDIATED_UV_LOCK_SHA256 and all other Gate B inputs and assertions remain unchanged.

No pin, lock, other seal, assertion, regex, exclusion, baseline, command or workflow change is allocated. These owners must recognize and enforce the new cohesive test; no ignored or skipped new coverage is acceptable.

Coding-standard tool/cohesion exception, only if physical file growth occurs: the canonical CI registry's one required literal entry and the existing seal metadata/history annotation may grow their oversized tool-owned files by those exact entries. Keeping enrollment in the canonical registry and recording the actual reviewed seal in its established owner is necessary to enforce the test without creating a parallel catalog or weakening the gates. This permits no function-body growth, business-code growth, unrelated entries or broad oversized-file waiver. Registry extraction is separate work. The two model files still must not grow after actual Ruff formatting; the existing 33-line view function stays byte-identical. The new test remains at most 300 lines with new/materially changed handwritten functions at most 30.

The engineer recomputes the final native verification plan after these final configuration bytes, runs the selected coverage and strict new-test gates, and retains the owning Gate B checks and negative synthetic-unreviewed-drift proof. No prior success is borrowed across changed inputs without a valid exact evidence envelope.

The three imports and whole named methods are byte-identical across the committed base and protected coding commits b92d674, 1056d506 and shared e9d0cdd. Foreign Question.clean, unrelated view redirect/render changes, coding guidance, advisory configuration, and #425 template WIP remain untouched, unintegrated and unreleased. Same-file presence is not ownership of those unrelated slices. Preserve this boundary during eventual integration; never replace whole files with donor copies or reset shared main.

Preserved contract

The public package owner exports StatRow, StatSection, STAT_ROWS, section builders and build_stat_fields; the selected functions construct display values using the supplied site's stats.get_value(field_name, stats_type). They require no package model or manager query.

  • Homework sections remain questions score, total score, lecture time, homework time, and learning-in-public score, in that order.
  • Project sections remain project score, project learning-in-public score, peer-review score, peer-review learning-in-public score, total score, and time spent, in that order.
  • Model display rows remain min, max, avg, q1, median, q3, with exact current labels and icons. The result remains a list of (section_label, rows, section_icon) tuples containing (value, row_label, row_icon) tuples.
  • Preserve all None, zero, positive and nonintegral values without filtering, normalization, rounding or type changes. The current site's get_value remains authoritative.
  • Preserve the project view's distinct range-card shape and ordering, including has_data, positions, equal-range behavior, empty data, and time-field handling. Do not replace that view shaping loop with the model tuple builder.
  • Preserve existing access, cohort isolation, incomplete-project response, errors, routes, templates, assets and visible controls.

Non-goals

No model, field, ORM query, schema, migration, data rewrite, history, calculation, score, cache, transaction, permission, route, API or template change. No package pin, lock, source-policy, lock seal, other Gate B contracts, graph, workflow, coding guidance or advisory-policy change. The precisely reviewed test enrollment and configuration-only pyproject seal update below are the sole metadata changes. No production data or provider access.

#439 remains frozen under its existing #438/#440 operational hold. Homework scoring/#55, FAQ and learning-in-public persistence, batch scoring, statistics calculation, review, enrollment, Wrapped and rubric-validator adoption remain outside this issue. Do not weaken those holds or count their deletion estimates here.

Acceptance criteria

  • Before and after deletion, inventory direct, relative, parent/dotted and aliased imports, scripts, tests, attributes, patch targets and dynamic strings. No reference to the deleted site module remains; callers use the released public owner directly.
  • Add any materially missing behavior coverage first and prove it passes on unchanged source. On actual DTC HomeworkStatistics and ProjectStatistics instances, assert complete ordered output, every section/row label and icon, tuple/list shape, and None, zero, positive and nonintegral values. Independent expected values must not be obtained from the replacement helper itself.
  • The same owning tests pass after deletion. Existing project-model, homework-dashboard/question-statistics and rendered project-statistics tests pass. Public context retains range-card behavior and the existing incomplete/denial/cohort boundaries.
  • A narrow output mutation, such as reordered sections/rows or omitted zero/null data, fails the owning behavior assertion rather than setup. Restore exact final bytes and retain the red control evidence; no broad mutation matrix is required.
  • The module is deleted with no facade or parallel implementation. Report actual gross and net production lines separately from test lines; target 158 net production lines using replacements within existing line allocations. No unrelated removal is used to reach the target.
  • After actual Ruff formatting, neither oversized model file nor its changed function grows; materially changed handwritten functions are at most 30 lines and new cohesive files at most 300. A collision-checked direct module alias is acceptable when it avoids wrapping. No fragment or growth waiver.
  • All excluded source, model/schema, routes/templates, package pin/lock/source-policy, lock seal, other Gate B contracts, foreign coding changes and stored history remain unchanged. Only the exact new-test opt-in/strict entry and final pyproject seal/history annotation change; gate coverage synchronizes the entries and still rejects unreviewed pyproject drift.
  • The engineer generates and passes the exact versioned verification plan, run, evidence-check and report-check, recording base/candidate, graph/plan/environment/input digests, actual commands/counts and all four component dispositions. Required quality/lint/advisory/type/migration-drift and browser tiers follow the current graph without overrides or baseline exemptions.
  • A distinct Tester independently recomputes the frozen plan, validates any reuse, executes required components and checks each criterion. Required desktop/mobile screenshots are independently captured and inspected when the graph selects render impact; otherwise use its backend browser tier and explicit not-applicable screenshot disposition. PM accepts only afterward.
  • After both reviews, the engineer makes a focused commit; root integrates and pushes through the native DTC process, and sole OnCall proves all required CI and development gates green. Local capability parity does not waive actual operational gates or close the issue early.

Verification scenarios

Complete display before and after

Given actual site statistics instances contain distinct values for every section/distribution field, including missing and zero values, their display methods return exactly the current complete tuples, labels, icons and order before and after the import change. A deliberately broken ordering or omission must fail this assertion.

Learner statistics and safe denial

A synthetic permitted learner visits the current completed-project statistics destination and sees unchanged range cards and values. An incomplete project retains its current response. Existing unauthorized and cross-cohort cases retain their current denial; this issue adds no new access rule or page.

Verification and delivery

Use synthetic isolated SQLite/provider-free fixtures. Relevant existing tests include test_project_statistics_model.py, test_dashboard_homework_stats.py, test_homework_question_stats.py, and project-statistics view/integration tests. Select exact final commands from the actual impact graph rather than promising counts in advance.

Generate with uv run --frozen python scripts/ci.py verification-plan, execute verification-run, then verification-evidence-check and verification-report-check. Blocking lint is uv run --frozen python scripts/ci.py lint; apply current coding advisory guidance read-only. The separate Tester uses the role-specific plan/run contract. Backend smoke is the minimum; a view import edit does not authorize a manual screenshot waiver. Unknown impact follows the graph's full fallback.

The dedicated engineer leaves the candidate uncommitted and frozen with its own issue report. Tester and PM reports remain independent. DTC uses local no-ff integration and no pull request. Sole OnCall observes post-push CI/development; no agent uses package comparison exceptions as native site green.

Ngôn ngữ chính
Python
Star
0
Fork
0
Merge trung bình
1 phút
Pull request đã merge (30 ngày)
2

Chuẩn bị môi trường

  • Có Dockerfile hoặc tệp Docker Compose
  • Không có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của DataTalksClub/website

Tất cả issue của DataTalksClub/website

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.