Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Receiver helpers work against a chosen database

未关闭
#367 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
52/100
Issue 类型
重构
描述清晰度
描述清楚
活跃度
活跃
技术栈
django, python
领域
backend, databases

调研方向

Start with morango/sync/utils.py:72 and morango/models/core.py at update_fsics and calculate_filter_specific_instance_counters, then review the SyncDatabase pattern from #365. Run the characterization suites from #363 and #364 while checking the queries identified at core.py:690-705, 735, and 775. Done means the listed helpers honor an optional handle, pinned default2 tests avoid default, and existing callers and validation errors retain their behavior.

由索引模型根据 Issue 内容生成。

描述

DEV: backend P0 - critical TAG: tech update / debt

Overview

This task (milestone M2) lets the public receiver helpers run against a database that the caller names. The helpers are buffer validation and the two counter (FSIC) functions.

Background & Motivation

The archive receives records the same way that a network server does. It validates incoming buffers, computes its counters, and updates its counters after dequeue. These helpers are public, and hosts call some of them. Thus each helper needs an optional database parameter. If a caller gives no database, the helper keeps the current behavior.

Design: spec. Plan: implementation plan, Task 6.

Description & Expected Outcomes

Each helper takes db=None. If the caller gives no handle, the helper uses the routed default handle, so existing callers see no change. If the caller gives a handle, all queries and writes in the helper go to that database.

The dequeue function from #366 passes its handle to the counter update.

Deliverables & Contracts

The task delivers an optional db parameter on these helpers:

  • validate_and_create_buffer_data.
  • DatabaseMaxCounter.update_fsics.
  • DatabaseMaxCounter.calculate_filter_specific_instance_counters.
Acceptance Criteria
  • With a handle pinned to default2, buffer validation creates Buffer and RecordMaxCounterBuffer rows in default2 and updates records_transferred.
  • With a handle pinned to default2, the counter update writes DatabaseMaxCounter rows in default2.
  • On an empty default2, the counter calculation for a receiver in v2 format returns an empty result with sub and super keys.
  • No test above makes a query to default. The tests run with override_settings(DATABASE_ROUTERS=[]).
  • Callers that give no handle see today's behavior.
  • The characterization suite passes without edits.

Technical Pointers & Architecture

  • Target Components: morango/sync/utils.py:72 (validate_and_create_buffer_data; it reads transfer_session.sync_session.profile at :97 and calls transfer_session.save(...) at :147, and both must use the handle), morango/models/core.py:655 (update_fsics), :727 (calculate_filter_specific_instance_counters), and the queries at :690-705, :735, and :775.
  • Related Patterns: SyncDatabase from #365.
  • Data Model & Schema Considerations: None.
  • Resilience & Failure Modes: Validation errors keep their current types.

Notes & Tradeoffs

  • Dependencies: Blocked by: #366 (Dequeue transferred records into a chosen database). Blocks: #384.
  • Testing Requirements: The test app's TestingRouter sends instance saves and foreign-key reads to default, so tests with a pinned handle clear the routers (#362). This is a refactor. The characterization suite from #363 and #364 must pass without edits.
  • Tradeoffs & Alternatives Considered: Private functions take a required handle. Public helpers take an optional handle, so that host code keeps working.

Metadata

  • Complexity: Medium
  • Target Branch: release-v0.9.x

AI Usage

Drafted with Claude (Claude Code) from the approved design spec and implementation plan. The author reviewed the requirements, and the code references were checked against the release-v0.9.x codebase.

主要语言
Python
星标
15
派生
23
平均合并
4 天 2 小时
30 天内合并 PR
5

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

learningequality/morango 的其他 Issue

查看 learningequality/morango 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。