-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Migrate database to clean up structure & rewrite database calls to match Edit the structure * CODE => NAME * TITLE * INFO * ~~ROLE_NAME~~ * ~~CHANNEL_NAME~~ * ROLE_ID * CHANNEL_ID * ~~UUID~~ * \+ DUPE * \+ ACTIVE This amounts to: * Removing `UUID`, `ROLE_NAME` and `CHANNEL_NAME`. * Cleaning up `CODE` and replacing it with `NAME`. * Adding the `DUPE` field to signify if a class is a duplicate. * Adding `ACTIVE` to specify if the course is being offered that semester. (Currently, all classes are considered active.) ### Steps to migrate database and discord server Run `migrateDb` command to migrate the database Run `CreateChannels` command to update channel names from the database Run `CreateRoles` command to update role names from the database # Link to github cards #33 #35 #49 #50 # Additions * Add a helper function to create embeds * Add `migrateDB` command to update the database to the new schema, update how duplicate codes are handled, and clean all strings. * Add modified JS Docs to function. (Types are not added since this is specified in function definitions with typescript) # Changes * Change db scheme * Change role and channel db calls to reflect changes * Change how duplicate classes are handled * Use course title and info in channel topics ## Bugfix * replace all contiguous whitespace with a dash instead of replacing spaces with a dash * Replace contiguous dashes with a dash in ROLE_NAME and CHANNEL_NAME * Trim leading and trailing whitespace from TITLE * Limit role name and channel name to 100 characters each * Limit channel topic to 1024 characters each * Only reply to role selection if role is actually assigned * Add bottleneck package to limit the bot to 50 API calls per second * Prefers matching on channel ID's rather than names
- Loading branch information
Showing
23 changed files
with
718 additions
and
152 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { expect, describe, it } from "@jest/globals"; | ||
import { cleanRoleString } from "../../src/utils/roles"; | ||
|
||
//cleanRoleString | ||
describe("cleanRoleString", () => { | ||
it("should lowercase the string", () => { | ||
expect(cleanRoleString("ABCD")).toEqual("abcd"); | ||
}); | ||
|
||
it("should remove special characters", () => { | ||
expect(cleanRoleString("a!b@c#d$")).toEqual("abcd"); | ||
}); | ||
|
||
it("should remove newlines", () => { | ||
expect(cleanRoleString("\na\n")).toEqual("a"); | ||
}); | ||
|
||
it("should replace whitespace with a hyphen", () => { | ||
expect(cleanRoleString("a b c")).toEqual("a-b-c"); | ||
}); | ||
|
||
it("should remove consecutive hyphens", () => { | ||
expect(cleanRoleString("a--b--c")).toBe("a-b-c"); | ||
}); | ||
|
||
it("should return an empty string for an empty input", () => { | ||
expect(cleanRoleString("")).toBe(""); | ||
}); | ||
|
||
it("cleanRoleString should return an empty string for a string with only special characters", () => { | ||
expect(cleanRoleString("!@#$%^&*")).toBe(""); | ||
}); | ||
|
||
it("should truncate the string to 100 characters", () => { | ||
expect(cleanRoleString("a".repeat(200))).toHaveLength(100); | ||
}); | ||
it("should be able to handle a comboination of everything", () => { | ||
expect(cleanRoleString("a! -- b@c\n#d$e%")).toEqual("a-bcde"); | ||
}); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Oops, something went wrong.