Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support: add migration file #7266

Merged
merged 9 commits into from
Jan 25, 2023

Conversation

yukendev
Copy link
Contributor

@yukendev yukendev commented Jan 19, 2023

https://redmine.weseek.co.jp/issues/112439

GROWIv6へのリリースガイド

  • drawio
  • plantuml
  • tsv, csvによるテーブル

v6へのアップグレードに際する上記の3つの記法変更に対応するためのマイグレーションのmongoshellのスクリプトを書きました

動作確認

  • drawio
  • plantuml
  • tsv, csvのテーブル

上記のすべてにおいてマイグレーション後、v6で正常に表示できることを確認しました。

@yukendev yukendev requested a review from yuki-takei January 20, 2023 05:17
@yukendev yukendev self-assigned this Jan 20, 2023
const tsvReplaced = plantUmlReplaced.replace(oldTsvTableRegExp, '``` tsv$1\n$2\n```');
const csvReplaced = tsvReplaced.replace(oldCsvTableRegExp, '``` csv$1\n$2\n```');
return csvReplaced;
}
Copy link
Member

@yuki-takei yuki-takei Jan 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

こういうことではないなあ

理想

TypeScript 風に書くと、

replaceLatestRevisions(processor: Processor[]) {

   // replacer の数だけ body.replace する

}

Processor は (markdown: string) => string

利点

  • グループ別に「これは差し替えたい」「これはスキップしたい」といったユーザー要望があるはず
    • グループ1: drawio, plantuml 等
    • グループ2: GROWI 独自 syntax の linker
    • 将来的に、ユーザーが入れられると一番強い

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

修正済み

var oldCsvTableRegExp = /::: csv(-h)?\n([\s\S]*?)\n:::/g; // CSVによるテーブル描画の旧記法

function replaceBody(body) {
const drawioReplaced = body.replace(oldDrawioRegExp, '```drawio\n$1\n```');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

細かいけど drawio の前にスペース一つ入れよう

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

修正済み

var pagesCollection = db.getCollection("pages");
var revisionIds = [];

// 各ページの最新のrevisionを取得(最新revisionしか記法のマイグレーションをしない)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

最終的には日本語禁止

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

修正済み

if (doc.revision != undefined) {
revisionIds.push(doc.revision);
}
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

パフォーマンス的に NG。ページが10万とかあったらどうするのだ。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

100ページごと、最新のrevisionを置き換える形にしました

@yuki-takei yuki-takei merged commit 1115aeb into support/112436-migration-to-v6 Jan 25, 2023
@yuki-takei yuki-takei deleted the imprv/112439-migration branch January 25, 2023 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants