rcos / Telescope

The RCOS website and Discord bot.
https://rcos.io
MIT License
18 stars 10 forks source link

128 add generate command #250

Closed ArberSephirotheca closed 2 years ago

ArberSephirotheca commented 2 years ago

Issue Number: close #128

Problem Summary: Add /generate slash command to Discord bot.

What is changed and how it works?

graphql/rcos/discord_assoications, src/discord_bot/commands, src/api/rcos/discord_assoications: "generate.rs",...

generate.rs:

Files under graphql/rcos/discord_assoications and src/api/rcos/discord_assoications:

Tests

Manual test:

  1. Create Discord Application.
  2. Create a new discord server.
  3. Create roles "Faculty Advisors" and "Coordinator", add yourself to these two roles.
  4. Start the docker image.
  5. Invite bots to discord server using the link generated by Telescope.
  6. Open Hasura console.
  7. Insert Row into Semesters table:
    • semester_id = 202201
    • title = Spring 2022
  8. Insert 3 Rows(arbitrary field data) into Projects table.
  9. Insert 1 Row into small group table.
    • semester_id = 202201
  10. Insert 2 Rows(arbitrary field data) into users table.
  11. Insert 2 Rows into enrollments table.
    • Project and user_id fields of two rows should be distinct.
    • So we got 2 projects being active in ongoing semester and 1 project being inactive in ongoing semester.
  12. Call /generate roles in discord server.
    • 2 project roles and 1 small group roles should be created at discord server.
    • The project_roles table and small_group_roles table should be updated.
  13. Call /generate categories in discord server.
    • 3 categories should be created at discord server.
    • The project_categories table and small_group_categories table should be updated.
    • Newly created categories should be visible to only project/small group members, Faculty Advisors and Coordinators.
  14. Call /generate channels in discord server.
    • 2 channels(1 voice channel and 1 text channel) should be created at each newly created category.
    • The project_channels table and small_group_channels table should be updated.
    • Newly created channels should be visible to only project/small group members, Faculty Advisors and Coordinators.
  15. Delete all the discord data in database.
  16. Remove all newly project/small group categories, channels and roles from discord server.
  17. Call /generate all to see if it produces the same result.
vcfxb commented 2 years ago

This PR checks in a .DS_Store file despite also adding it to the .gitignore. Consider running git rm .DS_Store and then pushing.

vcfxb commented 2 years ago

More generally there seem to be a bunch of queries and mutations in the discord_associations folder. In my opinion, these would be easier to find if they were structured according to what they act on. (i.e. any small group queries and mutations should be in a small group directory).

vcfxb commented 2 years ago

This PR also includes an empty file at src/discord_bot/commands/associate.rs and a few strange formatting items. Have you run cargo fmt?

vcfxb commented 2 years ago

I noticed that the RCOS API schema also changed, but I do not see any new migrations over on https://github.com/rcos/rcos-data to indicate new database structures to match. It's imperative that Telescope's API schema remain in sync with the database schema. This could be the result of updating Hasura's version in the docker-compose file without updating it to match on rcos-data. Worth checking for any breaking API changes before updating either.