Last active
September 22, 2023 00:20
-
-
Save tsaito-cyber/0ae88ff0712003abcfcc57797ed8db98 to your computer and use it in GitHub Desktop.
today_report.sh
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
#!/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