- 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:
baloh.matevz
2011-10-30 04:31:49 +00:00
parent 313d99d003
commit 830b28dc7f
6 changed files with 70 additions and 4 deletions

View File

@@ -288,6 +288,12 @@
sqllogin = value
if ("password")
sqlpass = value
if ("feedback_database")
sqlfdbkdb = value
if ("feedback_login")
sqlfdbklogin = value
if ("feedback_password")
sqlfdbkpass = value
if ("enable_stat_tracking")
sqllogging = 1
else

View File

@@ -177,6 +177,12 @@ var
sqllogin = "root"
sqlpass = ""
// Feedback gathering sql connection
sqlfdbkdb = "test"
sqlfdbklogin = "root"
sqlfdbkpass = ""
sqllogging = 0 // Should we log deaths, population stats, etc?

View File

@@ -49,6 +49,9 @@
///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
/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

View File

@@ -207,4 +207,8 @@ var/global/datum/controller/gameticker/ticker
if (findtext("[handler]","auto_declare_completion_"))
call(mode, handler)()
feedback_set_details("round_end","[time2text(world.realtime)]")
if(blackbox)
blackbox.save_all_data_to_sql()
return 1

View File

@@ -68,6 +68,7 @@
/datum/feedback_variable
var/variable
var/value
var/details
New(var/param_variable,var/param_value = 0)
variable = param_variable
@@ -103,8 +104,15 @@
proc/get_variable()
return variable
proc/set_details(var/text)
if(istext(text))
details = text
proc/get_details()
return details
proc/get_parsed()
return list(variable,value)
return list(variable,value,details)
var/obj/machinery/blackbox_recorder/blackbox
@@ -135,8 +143,8 @@ var/obj/machinery/blackbox_recorder/blackbox
//Only one can exsist in the world!
New()
for(var/obj/machinery/blackbox_recorder/BR in world)
if(BR != src)
if(blackbox)
if(istype(blackbox,/obj/machinery/blackbox_recorder))
del(src)
blackbox = src
@@ -151,6 +159,31 @@ var/obj/machinery/blackbox_recorder/blackbox
proc/get_round_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)
if(!blackbox) return
@@ -176,4 +209,13 @@ proc/feedback_dec(var/variable,var/value)
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)

View File

@@ -16,6 +16,11 @@ LOGIN mylogin
# Password used to access the database
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
# Comment this out to disable
ENABLE_STAT_TRACKING