Adds mentor help database collection (#22266)

* Adds mentor help database collection

* fix

* string

* no string

* sql changes

* ; moment

* numbers

* remove
This commit is contained in:
Molti
2024-07-30 20:19:48 -05:00
committed by GitHub
parent e413baf3f8
commit 25b96d8a52
6 changed files with 52 additions and 4 deletions

View File

@@ -1,13 +1,30 @@
Any time you make a change to the schema files, remember to increment the database schema version. Generally increment the minor number, major should be reserved for significant changes to the schema. Both values go up to 255.
The latest database version is 5.13; The query to update the schema revision table is:
The latest database version is 5.14; The query to update the schema revision table is:
INSERT INTO `schema_revision` (`major`, `minor`) VALUES (5, 13);
INSERT INTO `schema_revision` (`major`, `minor`) VALUES (5, 14);
or
INSERT INTO `SS13_schema_revision` (`major`, `minor`) VALUES (5, 13);
INSERT INTO `SS13_schema_revision` (`major`, `minor`) VALUES (5, 14);
In any query remember to add a prefix to the table names if you use one.
Version 5.14 2024-07-01, molti Adds mentor help tracking
```sql
DROP TABLE IF EXISTS `mentor_interactions`;
CREATE TABLE IF NOT EXISTS `mentor_interactions` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`round_id` int(10) unsigned NOT NULL DEFAULT 0,
`when` datetime NOT NULL DEFAULT current_timestamp(),
`ckey` varchar(32) NOT NULL,
`target_ckey` varchar(32) DEFAULT NULL,
`ckey_mentor` tinyint(3) unsigned NOT NULL DEFAULT 0,
`target_mentor` tinyint(3) unsigned NOT NULL DEFAULT 0,
`message` text,
PRIMARY KEY (`id`),
KEY `idx_round` (`round_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
```
version 5.13 2023-05-10
Adds allow_vpn to bound credentials flags

View File

@@ -296,6 +296,19 @@ CREATE TABLE IF NOT EXISTS `mentor` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=130 DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `mentor_interactions`;
CREATE TABLE IF NOT EXISTS `mentor_interactions` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`round_id` int(10) unsigned NOT NULL DEFAULT 0,
`when` datetime NOT NULL DEFAULT current_timestamp(),
`ckey` varchar(32) NOT NULL,
`target_ckey` varchar(32) DEFAULT NULL,
`ckey_mentor` tinyint(3) unsigned NOT NULL DEFAULT 0,
`target_mentor` tinyint(3) unsigned NOT NULL DEFAULT 0,
`message` text,
PRIMARY KEY (`id`),
KEY `idx_round` (`round_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `mentor_memo`;
CREATE TABLE IF NOT EXISTS `mentor_memo` (

View File

@@ -21,7 +21,7 @@
* make sure you add an update to the schema_version stable in the db changelog
*/
#define DB_MINOR_VERSION 13
#define DB_MINOR_VERSION 14
#define DB_BOUND_CREDENTIALS_FLAG_BYPASS_BANS "bypass_bans"
#define DB_BOUND_CREDENTIALS_FLAG_ALLOW_PROXIES "allow_proxies"

View File

@@ -70,3 +70,4 @@
/client/proc/is_mentor() // admins are mentors too.
if(mentor_datum || check_rights_for(src, R_ADMIN,0))
return TRUE
return FALSE

View File

@@ -46,6 +46,14 @@
if(!mt)
mt = new(src)
mt.log += "<b>[src.key]:</b> [msg]"
var/datum/DBQuery/add_mhelp_query = SSdbcore.NewQuery(
"INSERT INTO `[format_table_name("mentor_interactions")]` (round_id, ckey, ckey_mentor, target_mentor, message) VALUES (:round, :send, :smentor, :rmentor, :msg);",
list("round" = GLOB.round_id, "send" = ckey, "smentor" = is_mentor(), "rmentor" = 1, "msg" = msg)
)
if(!add_mhelp_query.Execute())
message_admins("Failed insert mhelp into mhelp DB. Check the SQL error logs for more details.")
qdel(add_mhelp_query)
/proc/get_mentor_counts()
. = list("total" = 0, "afk" = 0, "present" = 0)

View File

@@ -87,6 +87,15 @@
message_admins(log_message)
log_mentor(log_message)
return
var/datum/DBQuery/add_mhelp_query = SSdbcore.NewQuery(
"INSERT INTO `[format_table_name("mentor_interactions")]` (round_id, ckey, ckey_mentor, target_ckey, target_mentor, message) VALUES (:round, :send, :smentor, :receive, :rmentor, :msg);",
list("round" = GLOB.round_id, "send" = ckey, "smentor" = is_mentor(), "receive" = C.ckey, "rmentor" = C.is_mentor(), "msg" = msg)
)
if(!add_mhelp_query.Execute())
message_admins("Failed insert mhelp into mhelp DB. Check the SQL error logs for more details.")
qdel(add_mhelp_query)
msg = emoji_parse(msg)
if(C)
send_mentor_sound(C)