Add API for changes to dispatch sub changes
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 45/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- csharp
調査の方向性
IChangeContext.cs から始めて提案されている dispatch API を理解し、次に SnapshotWorker.cs と既存の MarkDeleted の処理を読みます。適用中に発行された変更が収集されて適用されるように dispatch フローを実装し、説明どおりに削除処理を変更側へ移行でき、MarkDeleted が不要になることを確認します。
索引モデルが issue の本文から書いたものです。
説明
What
We want changes to be able to dispatch other changes. For example deletes:
public class DeleteEntryChange(Guid entityId) : EditChange<Entry>(entityId), IPolyType
{
public static string TypeName => "delete:Entry";
public override async ValueTask ApplyChange(Entry entry, IChangeContext context)
{
entry.DeletedAt = context.Commit.DateTime;
await foreach (var obj in context.GetObjectsReferencing(EntityId, includeDeleted: false))
{
context.DispatchChange(new RemoveReferenceChange(obj));
}
}
}
or when we want to update objects which contain a copy of data
public class UpdateHeadwordChange(Guid entityId, string headword) : EditChange<Entry>(entityId), IPolyType
{
public static string TypeName => "update:Entry:Headword";
public override async ValueTask ApplyChange(Entry entry, IChangeContext context)
{
entry.Headword = headword;
await foreach(var complexForm in context.GetObjectsReferencing(entry.Id).OfType<ComplexForm>())
{
context.DispatchChange(new UpdateComplexFormChange(complexForm.Id, headword));
}
}
}
this would also be used for data migrations, maybe previously a field was owned by an object, but you want to move that field to a different object, however you have old changes which reference the old object, you can now dispatch a change to the correct object.
Why
- simplify delete handling code. Much of our current delete code could be moved into 2 dedicated types, one for a delete and one for removing a reference.
- allow updating derived data, eg writing system exemplars, or complex forms.
- data migrations, right now if you want to move a field from one object to another there's no way to write a change which allows that because a change can only modify the object it references in it's EntityId.
How
Add a new API to IChangeContext:
https://github.com/sillsdev/harmony/blob/5a660d125c4f1adc99c3384f275259b3d607d9a1/src/SIL.Harmony.Core/IChangeContext.cs#L3-L18
void DispatchChanges(params Span<IChange> changes);
this would require a lot of changes to SnapshotWorker, after a change was applied we need to gather the changes it dispatched and apply them. Much of the code in MarkDeleted will prove a useful model I suspect, however MarkDeleted itself should go away entirely as it will be handled via changes now instead.
- 主要言語
- C#
- スター
- 14
- フォーク
- 4
- 平均マージ
- 2日 18時間
- マージ済み PR(30日)
- 6
環境構築
このプロジェクトの環境構築ファイルはまだ確認していません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
sillsdev/harmony のほかの issue
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
-
Data bug
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
sillsdev/harmony#105 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 3/5 1〜2日 初心者へのやさしさ 58/100
メンテナーはふだん 1 日以内に返信
sillsdev/harmony の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
NethermindEth/nethermind#14012 ·
メンテナーはふだん 1 日以内に返信
-
dependencies Status: Triage
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
json-schema-org/website#2518 ·
メンテナーはふだん 1 日以内に返信
-
agentic-workflows
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
builtbybel/Flyoobe#498 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
builtbybel/CrapFixer#112 ·