mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-12 11:13:16 +00:00
- Feedback gathering thing updated. Now it finally supports actual SQL data storage.
Use the global procs to gather feedback: feedback_set(var_name, num) feedback_inc(var_name, num) feedback_dec(var_name, num) feedback_set_details(var_name, text) The values are saved to the database at the end of the round, if it ends properly. Currently the following information is stored: - Time when round starts - Mode - Time when round ends git-svn-id: http://tgstation13.googlecode.com/svn/trunk@2450 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
@@ -288,6 +288,12 @@
|
|||||||
sqllogin = value
|
sqllogin = value
|
||||||
if ("password")
|
if ("password")
|
||||||
sqlpass = value
|
sqlpass = value
|
||||||
|
if ("feedback_database")
|
||||||
|
sqlfdbkdb = value
|
||||||
|
if ("feedback_login")
|
||||||
|
sqlfdbklogin = value
|
||||||
|
if ("feedback_password")
|
||||||
|
sqlfdbkpass = value
|
||||||
if ("enable_stat_tracking")
|
if ("enable_stat_tracking")
|
||||||
sqllogging = 1
|
sqllogging = 1
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -177,6 +177,12 @@ var
|
|||||||
sqllogin = "root"
|
sqllogin = "root"
|
||||||
sqlpass = ""
|
sqlpass = ""
|
||||||
|
|
||||||
|
// Feedback gathering sql connection
|
||||||
|
|
||||||
|
sqlfdbkdb = "test"
|
||||||
|
sqlfdbklogin = "root"
|
||||||
|
sqlfdbkpass = ""
|
||||||
|
|
||||||
sqllogging = 0 // Should we log deaths, population stats, etc?
|
sqllogging = 0 // Should we log deaths, population stats, etc?
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,9 @@
|
|||||||
///post_setup()
|
///post_setup()
|
||||||
///Everyone should now be on the station and have their normal gear. This is the place to give the special roles extra things
|
///Everyone should now be on the station and have their normal gear. This is the place to give the special roles extra things
|
||||||
/datum/game_mode/proc/post_setup()
|
/datum/game_mode/proc/post_setup()
|
||||||
|
feedback_set_details("round_start","[time2text(world.realtime)]")
|
||||||
|
if(ticker && ticker.mode)
|
||||||
|
feedback_set_details("game_mode","[ticker.mode]")
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -207,4 +207,8 @@ var/global/datum/controller/gameticker/ticker
|
|||||||
if (findtext("[handler]","auto_declare_completion_"))
|
if (findtext("[handler]","auto_declare_completion_"))
|
||||||
call(mode, handler)()
|
call(mode, handler)()
|
||||||
|
|
||||||
|
feedback_set_details("round_end","[time2text(world.realtime)]")
|
||||||
|
if(blackbox)
|
||||||
|
blackbox.save_all_data_to_sql()
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|||||||
@@ -68,6 +68,7 @@
|
|||||||
/datum/feedback_variable
|
/datum/feedback_variable
|
||||||
var/variable
|
var/variable
|
||||||
var/value
|
var/value
|
||||||
|
var/details
|
||||||
|
|
||||||
New(var/param_variable,var/param_value = 0)
|
New(var/param_variable,var/param_value = 0)
|
||||||
variable = param_variable
|
variable = param_variable
|
||||||
@@ -103,8 +104,15 @@
|
|||||||
proc/get_variable()
|
proc/get_variable()
|
||||||
return variable
|
return variable
|
||||||
|
|
||||||
|
proc/set_details(var/text)
|
||||||
|
if(istext(text))
|
||||||
|
details = text
|
||||||
|
|
||||||
|
proc/get_details()
|
||||||
|
return details
|
||||||
|
|
||||||
proc/get_parsed()
|
proc/get_parsed()
|
||||||
return list(variable,value)
|
return list(variable,value,details)
|
||||||
|
|
||||||
var/obj/machinery/blackbox_recorder/blackbox
|
var/obj/machinery/blackbox_recorder/blackbox
|
||||||
|
|
||||||
@@ -135,8 +143,8 @@ var/obj/machinery/blackbox_recorder/blackbox
|
|||||||
|
|
||||||
//Only one can exsist in the world!
|
//Only one can exsist in the world!
|
||||||
New()
|
New()
|
||||||
for(var/obj/machinery/blackbox_recorder/BR in world)
|
if(blackbox)
|
||||||
if(BR != src)
|
if(istype(blackbox,/obj/machinery/blackbox_recorder))
|
||||||
del(src)
|
del(src)
|
||||||
blackbox = src
|
blackbox = src
|
||||||
|
|
||||||
@@ -151,6 +159,31 @@ var/obj/machinery/blackbox_recorder/blackbox
|
|||||||
proc/get_round_feedback()
|
proc/get_round_feedback()
|
||||||
return feedback
|
return feedback
|
||||||
|
|
||||||
|
//This proc is only to be called at round end.
|
||||||
|
proc/save_all_data_to_sql()
|
||||||
|
if(!feedback) return
|
||||||
|
|
||||||
|
var/DBConnection/dbcon = new()
|
||||||
|
dbcon.Connect("dbi:mysql:test:fornoreason.servehttp.com:3306","erro","3rr0HatesGlov3s")
|
||||||
|
if(!dbcon.IsConnected()) return
|
||||||
|
var/round_id
|
||||||
|
|
||||||
|
var/DBQuery/query = dbcon.NewQuery("SELECT MAX(round_id) AS round_id FROM erro_feedback")
|
||||||
|
query.Execute()
|
||||||
|
while(query.NextRow())
|
||||||
|
round_id = query.item[1]
|
||||||
|
|
||||||
|
if(!isnum(round_id))
|
||||||
|
round_id = text2num(round_id)
|
||||||
|
round_id++
|
||||||
|
|
||||||
|
for(var/datum/feedback_variable/FV in feedback)
|
||||||
|
var/sql = "INSERT INTO erro_feedback VALUES (null, Now(), [round_id], \"[FV.get_variable()]\", [FV.get_value()], \"[FV.get_details()]\")"
|
||||||
|
var/DBQuery/query_insert = dbcon.NewQuery(sql)
|
||||||
|
query_insert.Execute()
|
||||||
|
|
||||||
|
dbcon.Disconnect()
|
||||||
|
|
||||||
proc/feedback_set(var/variable,var/value)
|
proc/feedback_set(var/variable,var/value)
|
||||||
if(!blackbox) return
|
if(!blackbox) return
|
||||||
|
|
||||||
@@ -176,4 +209,13 @@ proc/feedback_dec(var/variable,var/value)
|
|||||||
|
|
||||||
if(!FV) return
|
if(!FV) return
|
||||||
|
|
||||||
FV.dec(value)
|
FV.dec(value)
|
||||||
|
|
||||||
|
proc/feedback_set_details(var/variable,var/details)
|
||||||
|
if(!blackbox) return
|
||||||
|
|
||||||
|
var/datum/feedback_variable/FV = blackbox.find_feedback_datum(variable)
|
||||||
|
|
||||||
|
if(!FV) return
|
||||||
|
|
||||||
|
FV.set_details(details)
|
||||||
@@ -16,6 +16,11 @@ LOGIN mylogin
|
|||||||
# Password used to access the database
|
# Password used to access the database
|
||||||
PASSWORD mypassword
|
PASSWORD mypassword
|
||||||
|
|
||||||
|
# The following information is for feedback tracking via the blackbox server
|
||||||
|
FEEDBACK_DATABASE test
|
||||||
|
FEEDBACK_LOGIN mylogin
|
||||||
|
FEEDBACK_PASSWORD mypassword
|
||||||
|
|
||||||
# Track population and death statistics
|
# Track population and death statistics
|
||||||
# Comment this out to disable
|
# Comment this out to disable
|
||||||
ENABLE_STAT_TRACKING
|
ENABLE_STAT_TRACKING
|
||||||
Reference in New Issue
Block a user