Skip to content

Instantly share code, notes, and snippets.

@takuma-saito
Last active September 22, 2023 00:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takuma-saito/0ae88ff0712003abcfcc57797ed8db98 to your computer and use it in GitHub Desktop.
Save takuma-saito/0ae88ff0712003abcfcc57797ed8db98 to your computer and use it in GitHub Desktop.
today_report.sh
#!/bin/bash -eu
cat <<EOF > main.rb
require 'json'
require 'date'
items = JSON.parse(\$stdin.read)
items
.group_by {|a| a['state']}
.map {|state, val| [
state,
val.sort_by {|x| x['updatedAt']}
.map {|x| "[_#{x.dig('repository', 'name')}_] #{x['title']} #{DateTime.parse(x['updatedAt']).new_offset('+09:00').strftime("%Y-%m-%dT%H:%M:%S")}\n#{x['url']}\n"}
.join("\n")
]
}
.map {|(state, comment)| "**#{state}**\n#{comment}"}
.join("\n\n").then {|v| puts v}
EOF
days_ago=${1:-1}
author=${2:-takuma-saito}
gh search prs --author "${author}" \
--sort updated "updated:>$(gdate --date "${days_ago} day ago" +%Y-%m-%d)" \
--json url,title,updatedAt,state,repository |
ruby main.rb
rm main.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment