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(storage): groups storage layer #349

Merged
merged 3 commits into from
Feb 9, 2024
Merged

feat(storage): groups storage layer #349

merged 3 commits into from
Feb 9, 2024

Conversation

Manason
Copy link
Member

@Manason Manason commented Feb 9, 2024

In This PR

  • Introduces a storage layer of predefined SQL queries for interacting with the groups and group_grades tables
  • Moved data model for groups into the storage layer
  • renamed existing storage layer to players.lua and moved into a newly created storage folder

Design for the dynamic groups system (future PRs):

Goal: Support changing attributes of groups at runtime. This supports features such as bosses adjusting employee pay, police departments adding/removing ranks, governments adding jobs, etc.

On Server Initialization (Getting data into the database from configs)

The database will become the source of truth for group data. On server load, all groups will be fetched. This is the only time the database is read from. This is merged with the jobs & gangs config to form the jobs and gangs tables that will be stored in core and returned by exports and the bridge core object. The merging logic will completely overwrite any groups that are in the config and also the database. It will not interleave or attempt to merge at the grade level. So if a group is in the database and in the config, only the databases data will be used. This is done on server init so that we can assume that all groups are in the database. Without this assumption, we would have to check on every modification for existence of groups.

After the merge, any groups in config and not in the database and inserted into the database.

Updating Data Dynamically

Updates to the data will update the core cache directly and do an immediate write to the database. A set of commands with an ace permission of 'qbx.group_manager' will allow for dynamic modification of the data by admins. Additionally it would be nice to provide a menu for easier editing. New exports will be added for other scripts to call to modify the data. Database functions will not be directly exposed to other resources, and it is expected that other resources will not directly modify or access the group tables owned by core.

@mafewtm mafewtm merged commit b6e0c1c into main Feb 9, 2024
3 of 4 checks passed
@Manason Manason deleted the groups-storage-layer branch February 10, 2024 05:29
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.

None yet

3 participants