mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-12 03:02:54 +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:
@@ -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)
|
||||
Reference in New Issue
Block a user