[srvx-commits] CVS: services/patches helpserv-pgsql.diff,1.2,1.3
Brought to you by:
entrope
From: Entrope <en...@us...> - 2003-11-05 14:18:36
|
Update of /cvsroot/srvx/services/patches In directory sc8-pr-cvs1:/tmp/cvs-serv19388/patches Modified Files: helpserv-pgsql.diff Log Message: allocate a new query.list for each SQL log, since it's passed off to the queue Index: helpserv-pgsql.diff =================================================================== RCS file: /cvsroot/srvx/services/patches/helpserv-pgsql.diff,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** helpserv-pgsql.diff 26 Oct 2003 14:01:39 -0000 1.2 --- helpserv-pgsql.diff 5 Nov 2003 14:18:27 -0000 1.3 *************** *** 5,9 **** diff -u -r1.59 Makefile.am --- src/Makefile.am 9 Sep 2003 01:56:55 -0000 1.59 ! +++ src/Makefile.am 26 Oct 2003 13:15:45 -0000 @@ -9,7 +9,7 @@ ./expnhelp < $(srcdir)/nickserv.help.m4 > $@ --- 5,9 ---- diff -u -r1.59 Makefile.am --- src/Makefile.am 9 Sep 2003 01:56:55 -0000 1.59 ! +++ src/Makefile.am 5 Nov 2003 14:15:46 -0000 @@ -9,7 +9,7 @@ ./expnhelp < $(srcdir)/nickserv.help.m4 > $@ *************** *** 18,25 **** =================================================================== RCS file: /cvsroot/srvx/services/src/helpserv.c,v ! retrieving revision 1.83 ! diff -u -r1.83 helpserv.c ! --- src/helpserv.c 19 Oct 2003 04:16:10 -0000 1.83 ! +++ src/helpserv.c 26 Oct 2003 13:15:47 -0000 @@ -46,6 +46,8 @@ #include "opserv.h" --- 18,25 ---- =================================================================== RCS file: /cvsroot/srvx/services/src/helpserv.c,v ! retrieving revision 1.84 ! diff -u -r1.84 helpserv.c ! --- src/helpserv.c 5 Nov 2003 13:52:23 -0000 1.84 ! +++ src/helpserv.c 5 Nov 2003 14:15:48 -0000 @@ -46,6 +46,8 @@ #include "opserv.h" *************** *** 162,166 **** + dest->used += strftime(dest->list + dest->used, dest->size - dest->used, "'%Y-%m-%d %H:%M:%S', ", localtime_r(&when, &broken_out)); +} ! + +static void +pgsql_insert(char *query) { --- 162,167 ---- + dest->used += strftime(dest->list + dest->used, dest->size - dest->used, "'%Y-%m-%d %H:%M:%S', ", localtime_r(&when, &broken_out)); +} ! ! - fflush(reqlog_f); +static void +pgsql_insert(char *query) { *************** *** 169,174 **** + pgsql_send_next_query(); +} ! ! - fflush(reqlog_f); +static void helpserv_log_request(struct helpserv_request *req, const char *reason) { + char userhost[USERLEN+HOSTLEN+2]; --- 170,174 ---- + pgsql_send_next_query(); +} ! + +static void helpserv_log_request(struct helpserv_request *req, const char *reason) { + char userhost[USERLEN+HOSTLEN+2]; *************** *** 319,323 **** saxdb_close_context(reqlog_ctx); reqlog_ctx = NULL; ! @@ -4159,25 +4331,31 @@ return mktime(timeinfo); } --- 319,323 ---- saxdb_close_context(reqlog_ctx); reqlog_ctx = NULL; ! @@ -4159,16 +4331,20 @@ return mktime(timeinfo); } *************** *** 329,335 **** struct helpserv_bot *hs; struct helpserv_user *hs_user; ! - int i; dict_iterator_t it, it2; - + int i; + char timestamp[64]; --- 329,334 ---- struct helpserv_bot *hs; struct helpserv_user *hs_user; ! int i; dict_iterator_t it, it2; + char timestamp[64]; *************** *** 338,357 **** + strftime(timestamp, sizeof(timestamp), "'%Y-%m-%d %H:%M:%S', ", &when_s); + query.size = 512; ! + query.list = malloc(query.size); for (it=dict_first(helpserv_bots_dict); it; it=iter_next(it)) { hs = iter_data(it); ! for (it2=dict_first(hs->users); it2; it2=iter_next(it2)) { ! hs_user = iter_data(it2); ! ! + /* Skip the helper if it's not their week-start day. */ ! if (hs_user->week_start != when_s.tm_wday) ! continue; ! ! + /* Adjust their credit if they are in-channel at rollover. */ ! if (hs_user->join_time) { ! hs_user->time_per_week[0] += when - hs_user->join_time; ! hs_user->time_per_week[4] += when - hs_user->join_time; ! @@ -4193,10 +4371,22 @@ hs_user->reassigned_to[i] = hs_user->reassigned_to[i-1]; } --- 337,345 ---- + strftime(timestamp, sizeof(timestamp), "'%Y-%m-%d %H:%M:%S', ", &when_s); + query.size = 512; ! + for (it=dict_first(helpserv_bots_dict); it; it=iter_next(it)) { hs = iter_data(it); ! @@ -4195,6 +4371,18 @@ hs_user->reassigned_to[i] = hs_user->reassigned_to[i-1]; } *************** *** 359,362 **** --- 347,351 ---- + /* Log to SQL */ + if (helpserv_conf.sql_log && hs->log_sql) { + + query.list = malloc(query.size); + query.used = 0; + string_buffer_append_string(&query, "INSERT INTO srvx_helpserv_stats (c_bot, t_weekstart, c_helper, i_time, i_picked_up, i_closed, i_reassigned_from, i_reassigned_to) VALUES("); *************** *** 371,380 **** hs_user->time_per_week[0] = hs_user->picked_up[0] = hs_user->closed[0] = hs_user->reassigned_from[0] = hs_user->reassigned_to[0] = 0; } ! } ! + free(query.list); ! } ! ! static void helpserv_timed_run_stats(UNUSED_ARG(void *data)) { ! @@ -4226,6 +4416,10 @@ saxdb_close_context(reqlog_ctx); if (reqlog_f) --- 360,364 ---- hs_user->time_per_week[0] = hs_user->picked_up[0] = hs_user->closed[0] = hs_user->reassigned_from[0] = hs_user->reassigned_to[0] = 0; } ! @@ -4228,6 +4416,10 @@ saxdb_close_context(reqlog_ctx); if (reqlog_f) *************** *** 387,391 **** void init_helpserv() { ! @@ -4291,6 +4485,7 @@ helpserv_define_option("REQONJOIN", opt_req_on_join); helpserv_define_option("AUTOVOICE", opt_auto_voice); --- 371,375 ---- void init_helpserv() { ! @@ -4293,6 +4485,7 @@ helpserv_define_option("REQONJOIN", opt_req_on_join); helpserv_define_option("AUTOVOICE", opt_auto_voice); |