Skip to content

Instantly share code, notes, and snippets.

@fujimura
Created December 27, 2018 06:23
Show Gist options
  • Save fujimura/025fc7bab4537ba3fb3a823adb70de40 to your computer and use it in GitHub Desktop.
Save fujimura/025fc7bab4537ba3fb3a823adb70de40 to your computer and use it in GitHub Desktop.
一年分の日報から「本日の作業内容」を抜き出してまとめて出力
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