why are closer logs updated this way?

Discussions about development of VICIDIAL and astGUIclient

Moderators: gerski, enjay, williamconley, Op3r, Staydog, gardo, mflorell, MJCoate, mcargile, Kumba, Michael_N

why are closer logs updated this way?

Postby bobbymc » Mon Aug 26, 2013 8:48 pm

how come in many areas we search from 4 hours ago or 1 hour ago? why not jsut order by call_date desc?

this is from the svn trunk but also all other versions:

Code: Select all
                $four_hours_ago = date("Y-m-d H:i:s", mktime(date("H")-4,date("i"),date("s"),date("m"),date("d"),date("Y")));

                if ($VLA_inOUT == 'INBOUND')
                        {
                        $vcl_statusSQL='';
                        if ($VDstatus == 'INCALL') {$vcl_statusSQL = ",status='$status_dispo'";}
                        $stmt = "UPDATE vicidial_closer_log set end_epoch='$StarTtime', length_in_sec='$length_in_sec' $vcl_statusSQL where lead_id='$lead_id' and user='$user' and call_date > \"$four_hours_ago\" order by call_date desc limit 1;";
                        if ($DB) {echo "$stmt\n";}
                        $rslt=mysql_query($stmt, $link);
                        if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00062',$user,$server_ip,$session_name,$one_mysql_log);}
                        $affected_rows = mysql_affected_rows($link);
                        if ($affected_rows > 0)
                                {
                                echo "$uniqueid\n$channel\n";

                        #       $fp = fopen ("./vicidial_debug.txt", "a");
                        #       fwrite ($fp, "$NOW_TIME|INBND_LOG_4|$VDstatus|$uniqueid|$lead_id|$user|$inOUT|$length_in_sec|$VDterm_reason|$VDvicidial_id|$start_epoch|$stmt|\n");
                        #       fclose($fp);
                                }
                        else
                                {
                                $fp = fopen ("./vicidial_debug.txt", "a");
                                fwrite ($fp, "$NOW_TIME|INBND_LOG_2|$uniqueid|$lead_id|$user|$inOUT|$length_in_sec|$VDterm_reason|$VDvicidial_id|$start_epoch|\n");
                                fclose($fp);
                                }
                        }
bobbymc
 
Posts: 425
Joined: Fri Jan 05, 2007 12:26 am

Re: why are closer logs updated this way?

Postby mflorell » Tue Aug 27, 2013 5:41 am

Because we had instances where something went wrong and a call from several days ago being updated. This prevents that from happening, and it shouldn't have much of an effect on the time it takes to run the query.
mflorell
Site Admin
 
Posts: 18338
Joined: Wed Jun 07, 2006 2:45 pm
Location: Florida

Re: why are closer logs updated this way?

Postby bobbymc » Wed Aug 28, 2013 2:22 am

but at this point would there already be a new record existing since you order by call_date desc limit 1? this would already give you the latest log that was generated when the call came in or was placed? why the need to also check the time?
bobbymc
 
Posts: 425
Joined: Fri Jan 05, 2007 12:26 am

Re: why are closer logs updated this way?

Postby bobbymc » Thu Nov 13, 2014 7:26 pm

ummmmm.. this is client code....
bobbymc
 
Posts: 425
Joined: Fri Jan 05, 2007 12:26 am

Re: why are closer logs updated this way?

Postby DomeDan » Fri Nov 14, 2014 3:00 am

bobbymc: that post from angel1092 is a copy of an other post on an other thread, its because its a bot that want to write spam, they know they have to wait a few days and do a normal post first etc.

and matt told you the reason, even though it should work with "order by call_date desc limit 1" and we dont know any reason why it shouldnt work, there has been instances where a query updates the wrong record.
the 4-hour part is just a extra safety to prevent that bug from appearing,
even tough the bug might not happen to you ever, the extra statement in the query does not slow down the query so its better to leave it there to prevent that rare bug
Vicidial Partner. Region: Sweden/Norway.
Does Vicidial installation, configuration, customization, add-ons, CRM implementation, support, upgrading, network-related, pentesting etc. Remote and onsite assistance.
Email: domedan (at) gmail.com
DomeDan
 
Posts: 1226
Joined: Tue Jan 04, 2011 9:17 am
Location: Sweden

Re: why are closer logs updated this way?

Postby bobbymc » Wed Nov 19, 2014 8:30 am

Thank you for the explanation
bobbymc
 
Posts: 425
Joined: Fri Jan 05, 2007 12:26 am


Return to Development

Who is online

Users browsing this forum: No registered users and 16 guests