Saki
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# 8/11(水) メンターさんペアプロ メモ [toc] ## 生データを保存する理由 - 古いデータをとってこないので大変→アプリで使わないなら不要かも - 正規化できないデータ - 時期などは関係なしに、後で欲しいとおもったデータのスキーマを変えた時(どういうテーブルにどういうデータ型のカラムを作るか)に、 - 一発で綺麗に出せない? - - 一回とっておきたい - 生データ関係なく問題があるポイントがある - サインアップしてないユーザーに、issueがアサインされている - assigned_issueとPRにでーたがふえていって、userはない問題 - assigneeは指定できるけど、reviwerは指定してリクエストで取れない問題 - issueとPRのでーたをためていって、userがサインアップ - userのサインアップを起点にリクエストを飛ばしたくない - userのサインアップユーザーのサインアップした時にissueやPRを撮りにapiにリクエストしたくない。リクエストをこちらで制御できないのが嫌。 umemotosan - 問題2:PRはreviewer指定して取りに行けない - 1. サインアップした段階でuserが - PR何件取りに行く? - PRがcloseされたら、or レビュワーでなくなたtらアプリ上は消える - PRのレコードを削除するタイミング - ポーリング:APIに逐一状態を聴きに行かないと最新の状態が分からない - とってきたものが更新されてるか見に行かないといけない(ポーリングしないといけない) - サインアップしたら取りに行く方法 - 1回目のレコード作成のタイミングはユーザーサインアップした時 - 結局2回目以降はポーリング(バッチ処理)がやることになる - 結局定期的にみに行かないといけない - メンターさんの手法 - APIから取ってきたものをissueとPRテーブルに保存しておく - userサインアップした時だと余計なリクエストがとぶ - createした時とuddateした時でわかれてしまうと考えることが増える - 生データの話にもどる - どっちの作戦でもデータを地区地位とりにいかないといけない - https://user-images.githubusercontent.com/58052292/183830551-a471ed40-4648-490d-94d4-cc1d1d935563.png - このテーブルで足りないカラム - 私の方法を実現するのはとても複雑。むずかしい ## メンターさんの手法イメージ https://discord.com/channels/715806612824260640/888287515994386462/1006907408502759515 ### メンターさんメモ 梅コース: まじめにやらない。1回で取れる最大を取ってくる。リリース以降に取ってこられるものだけに限定する。 竹コース: 1000 件手動で取ってきて、スクリプトで API を叩いて 1000 件ぐらい詰めるコードを書く (初回のデータ投入とかシードみたいな感じ) 松コース: 最初の 1 件目から全件取得する ```ruby 10.times do |n| get_issues(offset: 100 * n) get_pull_requests(offset: 100 * n) # persist issues # persist pull requests end api_issues = GitHubApiClient.get_issues # JSON api_issues.each do |api_issue| raw_issue = RawIssue.create!(json: api_issue) issue = Issue.create!( number: 1234, raw_issue:, point: raw_issue['labels'][0].name, users: raw_issue['assignees'].map { |user| user['login_name']] } ) end api_pull_requests = GitHubApiClient.get_pull_requests # JSON api_pull_requests.each do |api_pull_request| raw_pull_request = Rawpull_request.create!(json: api_pull_request) pull_request = pull_request.create!( number: 1234, raw_pull_request:, point: raw_pull_request['labels'][0].name, users: raw_pull_request['assignees'].map { |user| user['login_name']] } ) end ``` ``` # スケジューラー管理のテーブル軍 - issues <- scheduler -> API - 1 (update), users: [hoge, fuga, piyo], point - 2 (update), users: [], point - 3 (create), users: [], point - pull requests <- scheduler -> API - 1 (update), users: [hoge, fuga, piyo], title, number - 2 (update), users: [], title, number - 3 (create), users: [], title, number # ユーザー起点?のなにか - users - 1 - 2 - 3 - users <-> issues - 1 - 2 - 3 - users <-> pull requests - 1 - 2 - 3 # 真面目にやりすぎな例 - api issues - api users - api issues <-> api users ``` ### 自分のメモ - スケジューラが管理するテーブル - issuesとPRテーブルへのデータ作成や更新は常にherokuスケジューラが行う - データをいじるのは常にスケジューラだけ - この人がアサインされてますというデータを持っていないといけない。そうしないとusersテーブルと紐つけられない - JSONデータは複数人配列で入ってる - が、DBでは配列をデータとして入れることができない - しかしこの配列の部分を正規化すると.... - user起点 - users - 中間テーブル -------- - しかしこの配列の部分を正規化やりすぎると... ![](https://i.imgur.com/Pq98rwh.png) ----- ![](https://i.imgur.com/92JqzuE.png) - なので配列でレコードを入れておく - 生データが必要な理由:あくまで保険 - なにかあった時のために撮りやすくする保険 - あってもなくてもいいとおもう - でも用意するコストはそんなに変わらない - データ量の懸念(多い) / このJSONをいつ消すか? を考えないといけない ## データ保存の流れ api→Rawissue→AssignedIssue ## 関連付けは必要か? - RawIssueからAssignedIssue - つける理由 - どのjsonから作成しているか明示するため - お互い絶対1個ずつしか存在しないはずなので、関係ないデータがまぎれこまないため - ユニーク制約をつければ1:1の保証ができる ## issueのAPIリクエストを、レビューリクエストされたPRを取得するためのAPIリクエストと揃えた方が良い理由 - cafedomancerさんの手法だとこんな感じのコードでDB保存することになる ![](https://i.imgur.com/5L0LEeq.png) - PRも↑のコードを使う。同じ方が見通しが立ちやすい。 - サインアップした時にuserを指定してとってくることがない。 ## リクエストの件数は何件が妥当か - issueとPRでリクエストのクエリは変わらない - ❌PRはopenなものだけ取りに行く→2回目以降の更新のタイミングがあるのでopenステ=タスは意味をなさなくなる - 何件が妥当か - 松竹梅3つの道 - 梅:リリースの直後に100 - 竹:リリース直後に一回だけ1000件撮りに行ってDB保存して取っておく - 松竹梅コース - issuesエンドポイントにPRが混ざってる問題 - 取ってきた時にissueとPRがどれくらいの割合で帰ってくるか分からない。単純に2倍ではない。 - 「取ってきたけど足りない」というのが問題 - データの詰め直しが必要かも - 最初はrakeタスクでデータをつめる処理が必要かも - issueは、sort=updated を使えばよさそう ## テーブルのデータが、create と update と delete されるタイミング - user - 1度ログインしてるけど、別PCでログインした時にupdateがされる - deleteは退会 - issueとPRの4つのテーブル - これは簡単 - deleteのタイミング - create と update はAPI叩いたタイミング - deleteはない(生データがない場合) - 生データのdeleteのタイミング - 懸念=データ量が多い - 最初は100件でも稼働していくとどんどん増えていく - 量もどんどん増えていくし、JSONデータ自体も重そう(これはやってみないと分からない!テストデータつ方t裏して検証) - 多くて消す必要がある場合は、削除のタイミングを考える必要がある - その場合、 - 外部キーを設定したissue/PRテーブルのデータをどうするか考えないといけない - 1. NULLを入れる - 2. 親と一緒に子も消す - issuesの - 中間テーブル2つがやっかい - createされるタイミングが2つある - userとissue/PR の作成のタイミングが違うので、createが厄介 - updateはこのテーブルはされることはない - deleteは、assigneeからuserが入らなくなった時、紐づいてない

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully