Created
December 27, 2018 06:23
-
-
Save fujimura/025fc7bab4537ba3fb3a823adb70de40 to your computer and use it in GitHub Desktop.
一年分の日報から「本日の作業内容」を抜き出してまとめて出力
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
i = 1 | |
entries = [] | |
name = 'fujimura' | |
until entries.length > 0 && entries.last['full_name'] =~ %r{2017/12} | |
r = HTTPClient.get( | |
'https://api.esa.io/v1/teams/proper-inc/posts', | |
access_token: ENV['ESA_TOKEN'], | |
q: "in:日報 user:#{name}", | |
page: i | |
) | |
json_response = JSON.parse(r.body) | |
entries.push *json_response['posts'] | |
puts json_response['posts'].last['full_name'] | |
i += 1 | |
end | |
File.write( | |
"nippou-#{Time.now.to_i}.ndjson", | |
entries.map(&:to_json).join("\n") | |
) | |
File.write( | |
"nippou-#{Time.now.to_i}.md", | |
entries.map { |e| | |
t = e['full_name'].gsub('日報/', '').gsub('/fujimura', '') | |
b = e['body_md'].scan(/本日の作業内容(.*)#\s+明日の作業/m).first.first | |
"# #{t}#{b}" | |
}.reverse.join | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment