Too many project info

オープン
#945 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
68/100
issue の種類
リファクタリング
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
performance

調査の方向性

Mergin/projects_manager.py の MerginProjectsManager.project_status() から始め、戻り値の形を変更する前に、その19個の呼び出し箇所を調べてください。次に、プロジェクトステータスダイアログと、現在の権限およびロールの入力元を追跡してください。完了条件は、ダイアログが1つのレスポンスから両方の値を取得し、既存の3つの値を受け取る呼び出し元が引き続き動作することです。

索引モデルが issue の本文から書いたものです。

説明

Current situation

Opening the project status dialog makes three back-to-back requests for the same project info, each returning the project's full file list.

In MerginProjectsManager.project_status() (Mergin/projects_manager.py):

# call what it is after
1 self.mc.project_status(project_dir) → project_info(name, since=vN) files, version
2 self.mc.has_writing_permissions(project_name) → project_info(name) permissions.upload
3 self.mc.project_info(project_name)["role"] role

permissions and role are sibling fields of the same ProjectSchema, and the since= response is already ProjectSchema(exclude=["storage_params"]). So the first response carries everything the other two go back to the server for.

Beyond the wasted payload, has_write_permissions and project_permission reach the dialog from two different responses. They are two snapshots of the same state and can in principle disagree, and the dialog uses one to warn about read-only access and the other to drive MerginProjectValidator.

What we want

One request per status dialog, with the permission and the role coming from the same response.

Proposed approach

Step 1 — plugin only. Drop has_writing_permissions and read both values off a single project_info call. Takes it from three requests to two, no client release needed:

project_info = self.mc.project_info(project_name)
dlg = ProjectStatusDialog(
    pull_changes,
    push_changes,
    push_changes_summary,
    project_info["permissions"]["upload"],
    mp,
    project_info["role"],
)

Step 2 — needs python-api-client. project_status() cannot simply return the server info as a fourth element: 19 call sites (db-sync, cli.py, the plugin) unpack exactly three values. A non-breaking shape is a richer method with the existing one as a thin wrapper:

def project_status(self, directory):
    pull, push, summary, _ = self.project_status_with_info(directory)
    return pull, push, summary

The plugin then calls project_status_with_info() and takes role and permissions from the response it has already paid for, bringing it to one request.

主要言語
Python
スター
45
フォーク
21
平均マージ
3日 13時間
マージ済み PR(30日)
2

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

MerginMaps/qgis-plugin のほかの issue

MerginMaps/qgis-plugin の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。