Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(bn): migrate battle notifier to DB #1

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

PabloCorso
Copy link
Collaborator

@PabloCorso PabloCorso commented Jun 28, 2023

Battle Notifier migration discussion here.

What changes are proposed in this pull request?

Migrate current battle notifier user settings store with file system at bn.store.json file, to use the database instead.

  • bnStore.js manages user settings storage. Update to call to the server API instead to get and post user settings from the server.
    • Replaced JSON file handling for API calls with apisauce.
    • bnModelUtils.js is a new file to handle data between API and bot code, to parse incoming notification settings from server model to bot model and viceversa.
    • Updated methods from handling JSON storage to using API calls:
      • get: api/bn/:DiscordId - get user settings
      • set: api/bn/:DiscordId - set user notification rules
      • getAllActive: api/bn - gets all "active" settings with BnEnabled and at least one BnKuskiRule
      • toggleIsOn: api/bn/:DiscordId/toggle/:BnEnabled - turn notifications on/off
      • isUserLinked: api/bn/:DiscordId/linked - is there an elma online user connected with DiscordId
  • Migrated tests from jest to vitest and updated for the new logic.
Screenshot 2023-06-28 at 13 27 42
  • The usage of !bn bot remains the same, commands are unchanged. Added one new message for the first interaction with the bot. If you have not connected elma online user with your discord id you will now see the following intructions:
Screenshot 2023-06-28 at 15 02 22

@PabloCorso
Copy link
Collaborator Author

Added migration script to generate base SQL statements to migrate bn.store.json to the new DB structure

@@ -29,7 +29,8 @@ export default {
},
prefix: '!',
bn: {
storePath: '../bn/bn.store.json',
serverApiUrl: 'https://test.elma.online/api/player/bn/',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe it should use discord.url and just have "api/player/bn/" for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants