From: cypromis Date: Mon, 7 Feb 2011 13:04:44 +0000 (+0100) Subject: FS-1742 - Make Voicemail use 1 SQL query instead of 4 to get the message count use... X-Git-Tag: v1.2-rc1~187^2~17^2~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=080c5ae98167e590bebf698439c550bdb656925e;p=thirdparty%2Ffreeswitch.git FS-1742 - Make Voicemail use 1 SQL query instead of 4 to get the message count use in MWI - Now also working on your more favourite and less favourite databases --- diff --git a/src/mod/applications/mod_voicemail/mod_voicemail.c b/src/mod/applications/mod_voicemail/mod_voicemail.c index 80b011e189..f868c3a284 100644 --- a/src/mod/applications/mod_voicemail/mod_voicemail.c +++ b/src/mod/applications/mod_voicemail/mod_voicemail.c @@ -1278,7 +1278,9 @@ static void message_count(vm_profile_t *profile, const char *id_in, const char * myid = resolve_id(id_in, domain_name, "message-count"); switch_snprintf(sql, sizeof(sql), - "select read_epoch=0, read_flags, count(read_epoch) from voicemail_msgs where username='%s' and domain='%s' and in_folder='%s' group by read_epoch=0,read_flags;", + "select 1, read_flags, count(read_epoch) from voicemail_msgs where username='%s' and domain='%s' and in_folder='%s' and read_epoch=0 group by read_flags + union + select 0, read_flags, count(read_epoch) from voicemail_msgs where username='%s' and domain='%s' and in_folder='%s' and read_epoch<>0 group by read_flags;", myid, domain_name, myfolder); vm_execute_sql_callback(profile, profile->mutex, sql, message_count_callback, &cbt);