Skip to content

Commit

Permalink
Only act on unlabelled discussions
Browse files Browse the repository at this point in the history
  • Loading branch information
mgriffin committed Mar 13, 2024
1 parent 32f0abb commit ee93d0f
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions .github/actions/comment
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ require_relative "../lib/github"
stale_label_id = "LA_kwDOEfmk4M8AAAABYVCU-g"
owner = "community"
repo = "community"
only_these_categories = ["Copilot"]

body =<<BODY
🕒 **Discussion Activity Reminder** 🕒
Expand All @@ -24,23 +23,19 @@ Note: This dormant notification will only apply to Discussions with the `Questio
Thank you for helping bring this Discussion to a resolution! 💬
BODY

categories = Category.all(owner:, repo:).select { |c| only_these_categories.include?(c.name) }

categories.map do |category|
category.discussions = Discussion.all(owner:, repo:, category:)
end

categories.each do |category|
category.discussions.each do |discussion|
puts "#{discussion.url},#{discussion.title}"
result = discussion.add_comment(body: body)
if errors = result.dig("errors")
puts "#{errors.dig(0, "type")}: #{errors.dig(0, "message")}"
sleep 1.2
next
end
#discussion.add_label(label_id: stale_label_id)

sleep 1.2
discussions = Discussion.all(owner:, repo:)
puts "All: #{discussions.count}"

unlabelled = discussions.reject { |d| d.labelled }
puts "Unlabelled: #{unlabelled.count}"
unlabelled.each do |discussion|
puts "#{discussion.url} - #{discussion.title}"
result = discussion.add_comment(body: body)
if errors = result.dig("errors")
puts "#{errors.dig(0, "type")}: #{errors.dig(0, "message")}"
exit
end
discussion.add_label(label_id: stale_label_id)

sleep 10
end

0 comments on commit ee93d0f

Please sign in to comment.