recursecenter / pairing-bot

A Zulip bot that partners people for pair programming practice
MIT License
22 stars 15 forks source link

Use Firestore struct tags for field mapping #83

Closed jdkaplan closed 1 month ago

jdkaplan commented 2 months ago

The Firestore client can use a firestore struct tag to map between Firestore documents and Go structs. We should use it!

For example, this is (now) how we map the Recurser struct (just like the standard library's json tag):

type Recurser struct {
    ID                 int64           `firestore:"id"`
    Name               string          `firestore:"name"`
    Email              string          `firestore:"email"`
    IsSkippingTomorrow bool            `firestore:"isSkippingTomorrow"`
    Schedule           map[string]bool `firestore:"schedule"`
    CurrentlyAtRC      bool            `firestore:"currentlyAtRC"`

    // IsSubscribed really means "already had an entry in the database".
    // It is not written to or read from the Firestore document.
    IsSubscribed bool `firestore:"-"`
}

Relevant docs:

Tasks

These are the structs that form our interface to Firestore:

I think this refactor is a great first task for someone looking to get starting working on Pairing Bot. It should be possible to copy-paste from existing code and get quite far. And I would be also be glad to help out at any point (maybe even pair on it :wink:)!

Let me know (here or elsewhere) if you'd like to claim a struct :slightly_smiling_face:

pjg11 commented 1 month ago

Was this supposed to be closed? The PairingsDB refactor is still mentioned in the checklist, and I'd like to work on it

jdkaplan commented 1 month ago

Was this supposed to be closed? The PairingsDB refactor is still mentioned in the checklist, and I'd like to work on it

Good catch, thanks! And extra thanks for taking on PairingsDB!

jdkaplan commented 1 month ago

Thanks @pjg11 for finishing this up!