The RC API client has enough complexity in it that I think it's worth putting it in its own package. Most of the code isn't specific to Pairing Bot, so I tried to leave most of that in the main package for now.
This is very similar to the Zulip client from #69, which I cleaned up a bit as I copy-pasted it into the new client.
Test Plan
Deploy this to the dev environment and check all the RC interactions:
[x] subscribe will check whether the user is currently at RC
[x] /welcome will iterate through current batches (patch in a second-Tuesday date for testing)
[x] /endofbatch will iterate through active recursers (edit my user to have been in-batch first)
Patch for pretending it's the second Tuesday of F1'24 (current batch)
```diff
diff --git a/pairing_bot.go b/pairing_bot.go
index 750a000..52bfeef 100644
--- a/pairing_bot.go
+++ b/pairing_bot.go
@@ -367,7 +367,7 @@ func (pl *PairingLogic) welcome(w http.ResponseWriter, r *http.Request) {
break
}
- if currentBatch.IsSecondWeek(time.Now()) {
+ if currentBatch.IsSecondWeek( /*time.Now()*/ time.Date(2024, 8, 20, 18, 00, 00, 0, time.UTC)) {
if err := pl.zulip.PostToTopic(ctx, "397 Bridge", "🍐🤖", getWelcomeMessage()); err != nil {
log.Printf("Error when trying to send welcome message about Pairing Bot %s\n", err)
}
```
The RC API client has enough complexity in it that I think it's worth putting it in its own package. Most of the code isn't specific to Pairing Bot, so I tried to leave most of that in the
main
package for now.This is very similar to the Zulip client from #69, which I cleaned up a bit as I copy-pasted it into the new client.
Test Plan
Deploy this to the dev environment and check all the RC interactions:
subscribe
will check whether the user is currently at RC/welcome
will iterate through current batches (patch in a second-Tuesday date for testing)/endofbatch
will iterate through active recursers (edit my user to have been in-batch first)Patch for pretending it's the second Tuesday of F1'24 (current batch)
```diff diff --git a/pairing_bot.go b/pairing_bot.go index 750a000..52bfeef 100644 --- a/pairing_bot.go +++ b/pairing_bot.go @@ -367,7 +367,7 @@ func (pl *PairingLogic) welcome(w http.ResponseWriter, r *http.Request) { break } - if currentBatch.IsSecondWeek(time.Now()) { + if currentBatch.IsSecondWeek( /*time.Now()*/ time.Date(2024, 8, 20, 18, 00, 00, 0, time.UTC)) { if err := pl.zulip.PostToTopic(ctx, "397 Bridge", "🍐🤖", getWelcomeMessage()); err != nil { log.Printf("Error when trying to send welcome message about Pairing Bot %s\n", err) } ```