Add playtime tracking to notes (#55800)

* Added playertime tracking to player notes

* Updated sql change log with revision

* Fixed typo in db_query

* And fixed another typo with query_get...

* Add recomended changes from Jordie0608

* Added missing DEFAULT NULL to sql

Co-authored-by: MissFox <github@aesir.org.uk>
This commit is contained in:
MissFox0810
2021-01-01 11:10:27 +01:00
committed by GitHub
parent ae3a64f00e
commit c0a4df5efb
5 changed files with 20 additions and 8 deletions

View File

@@ -1,15 +1,22 @@
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.11; The query to update the schema revision table is:
The latest database version is 5.12; The query to update the schema revision table is:
INSERT INTO `schema_revision` (`major`, `minor`) VALUES (5, 11);
INSERT INTO `schema_revision` (`major`, `minor`) VALUES (5, 12);
or
INSERT INTO `SS13_schema_revision` (`major`, `minor`) VALUES (5, 11);
INSERT INTO `SS13_schema_revision` (`major`, `minor`) VALUES (5, 12);
In any query remember to add a prefix to the table names if you use one.
-----------------------------------------------------
Version 5.12, 29 December 2020, by Missfox
Modified table `messages`, adding column `playtime` to show the user's playtime when the note was created.
ALTER TABLE `messages` ADD `playtime` INT(11) NULL DEFAULT(NULL) AFTER `severity`
-----------------------------------------------------
Version 5.11, 7 September 2020, by bobbahbrown, MrStonedOne, and Jordie0608
Adds indices to support search operations on the adminhelp ticket tables. This is to support improved performance on Atlanta Ned's Statbus.

View File

@@ -255,6 +255,7 @@ CREATE TABLE `messages` (
`secret` tinyint(1) unsigned NOT NULL,
`expire_timestamp` datetime DEFAULT NULL,
`severity` enum('high','medium','minor','none') DEFAULT NULL,
`playtime` int(11) unsigned NULL DEFAULT NULL,
`lasteditor` varchar(32) DEFAULT NULL,
`edits` text,
`deleted` tinyint(1) unsigned NOT NULL DEFAULT '0',

View File

@@ -255,6 +255,7 @@ CREATE TABLE `SS13_messages` (
`secret` tinyint(1) unsigned NOT NULL,
`expire_timestamp` datetime DEFAULT NULL,
`severity` enum('high','medium','minor','none') DEFAULT NULL,
`playtime` int(11) unsigned NULL DEFAULT NULL,
`lasteditor` varchar(32) DEFAULT NULL,
`edits` text,
`deleted` tinyint(1) unsigned NOT NULL DEFAULT '0',

View File

@@ -20,7 +20,7 @@
*
* make sure you add an update to the schema_version stable in the db changelog
*/
#define DB_MINOR_VERSION 11
#define DB_MINOR_VERSION 12
//! ## Timing subsystem

View File

@@ -77,8 +77,8 @@
if(!note_severity)
return
var/datum/db_query/query_create_message = SSdbcore.NewQuery({"
INSERT INTO [format_table_name("messages")] (type, targetckey, adminckey, text, timestamp, server, server_ip, server_port, round_id, secret, expire_timestamp, severity)
VALUES (:type, :target_ckey, :admin_ckey, :text, :timestamp, :server, INET_ATON(:internet_address), :port, :round_id, :secret, :expiry, :note_severity)
INSERT INTO [format_table_name("messages")] (type, targetckey, adminckey, text, timestamp, server, server_ip, server_port, round_id, secret, expire_timestamp, severity, playtime)
VALUES (:type, :target_ckey, :admin_ckey, :text, :timestamp, :server, INET_ATON(:internet_address), :port, :round_id, :secret, :expiry, :note_severity, :playtime)
"}, list(
"type" = type,
"target_ckey" = target_ckey,
@@ -92,6 +92,7 @@
"secret" = secret,
"expiry" = expiry || null,
"note_severity" = note_severity,
"playtime" = "(SELECT minutes FROM [format_table_name("role_time")] WHERE ckey = '[target_ckey]' AND job = 'Living')",
))
var/pm = "[key_name(usr)] has created a [type][(type == "note" || type == "message" || type == "watchlist entry") ? " for [target_key]" : ""]: [text]"
var/header = "[key_name_admin(usr)] has created a [type][(type == "note" || type == "message" || type == "watchlist entry") ? " for [target_key]" : ""]"
@@ -407,7 +408,8 @@
timestamp,
server,
IFNULL((SELECT byond_key FROM [format_table_name("player")] WHERE ckey = lasteditor), lasteditor),
expire_timestamp
expire_timestamp,
playtime
FROM [format_table_name("messages")]
WHERE type = :type AND deleted = 0 AND (expire_timestamp > NOW() OR expire_timestamp IS NULL)
"}, list("type" = type))
@@ -428,10 +430,11 @@
var/server = query_get_type_messages.item[7]
var/editor_key = query_get_type_messages.item[8]
var/expire_timestamp = query_get_type_messages.item[9]
var/playtime = query_get_type_messages.item[10]
output += "<b>"
if(type == "watchlist entry")
output += "[t_key] | "
output += "[timestamp] | [server] | [admin_key]"
output += "[timestamp] | [server] | [admin_key] | [get_exp_format(text2num(playtime))] Living Playtime"
if(expire_timestamp)
output += " | Expires [expire_timestamp]"
output += "</b>"