Results 1 to 5 of 5

Thread: Search for matching phone - memory issue

  1. #1
    kir
    kir is offline Sugar Community Member
    Join Date
    Nov 2011
    Posts
    702

    Default Search for matching phone - memory issue

    hi
    i'm trying to use process_record logic hook to mark with color phone number in custom module if it has matches in accounts or contacts phone fields.
    i'm using bean function get_full_list() and then go foreach contact/account trying to find matches in phone fields
    but it takes all the memory and can't be processed (3000 accounts and 7500 contacts) as it go through every phone field in accounts?contacts for every record in custom module.

    what is the best way to solve such case?

    Thanks in advance!

  2. #2
    crmwa_Joel is offline Sugar Community Member
    Join Date
    Mar 2012
    Location
    PH
    Posts
    148

    Default Re: Search for matching phone - memory issue

    Hi Kir,

    if i get your question correctly you want to retrieve/get accounts/contacts that has the same mobile number as your record in your custom module?
    Your current process now is to get all accounts/contacts and loop through each of them and search for the phone number?

    the get_full_list() function accepts 2 parameters, first would be an order by next a where statement so you can further filter it to something like this

    PHP Code:
    class MyLogicHookHelper{

            
    /**
             * This is used for IDE auto complete
             *@var Leads
             */
            
    public $bean

            function 
    ClassInsideHook(&$bean,$event,$argument)
            {
                 
    $this->bean $bean;
                 
    $accounts BeanFactory::getBean('Accounts')->get_full_list('date_entered ASC ',"accounts.phone_work = '{$this->bean->phone_work}' ");
                 
    $contacts BeanFactory::getBean('Contacts')->get_full_list('date_entered ASC ',"contacts.phone_work = '{$this->bean->phone_work}' ");

                
    //you can now loop through your accounts,contacts
               //in addition you can put a limit to get_full_list : get_full_list('date_entered ASC LIMIT (your limit here)',"contacts.phone_work = '{$this->bean->phone_work}' ");
            
    }



  3. #3
    kir
    kir is offline Sugar Community Member
    Join Date
    Nov 2011
    Posts
    702

    Default Re: Search for matching phone - memory issue

    Quote Originally Posted by crmwa_Joel View Post
    Hi Kir,

    if i get your question correctly you want to retrieve/get accounts/contacts that has the same mobile number as your record in your custom module?
    Your current process now is to get all accounts/contacts and loop through each of them and search for the phone number?

    the get_full_list() function accepts 2 parameters, first would be an order by next a where statement so you can further filter it to something like this

    PHP Code:
    class MyLogicHookHelper{

            
    /**
             * This is used for IDE auto complete
             *@var Leads
             */
            
    public $bean

            function 
    ClassInsideHook(&$bean,$event,$argument)
            {
                 
    $this->bean $bean;
                 
    $accounts BeanFactory::getBean('Accounts')->get_full_list('date_entered ASC ',"accounts.phone_work = '{$this->bean->phone_work}' ");
                 
    $contacts BeanFactory::getBean('Contacts')->get_full_list('date_entered ASC ',"contacts.phone_work = '{$this->bean->phone_work}' ");

                
    //you can now loop through your accounts,contacts
               //in addition you can put a limit to get_full_list : get_full_list('date_entered ASC LIMIT (your limit here)',"contacts.phone_work = '{$this->bean->phone_work}' ");
            
    }


    Thanks for reply!

    The full task look as follow
    we got accounts and contacts. Both contain several phone fields - custom phone fields too.
    In these modules phone numbers stored with formatting like + () - and letters ...
    So i have to preprocess them after retrieve and then use their values
    In our country in different cities we have different number of figures in area code.
    And we have custom module, where we store phone numbers - it is actualy phone numbers managers called to (it is from ip-call long distance statistics).
    So i need to figure out - what is the account or contact the called number belongs to (if any) and mark it with color depends on.
    So i use logic hook process_record
    AND
    it takes too much memory to create been and retrieve and look for matches
    I think it would be nice to be able to retrieve all accounts and contacts fields once (not for every record) and then just do foreach() my match search.

    What is the best way to achive this?

    Thanks in advance

  4. #4
    crmwa_Joel is offline Sugar Community Member
    Join Date
    Mar 2012
    Location
    PH
    Posts
    148

    Default Re: Search for matching phone - memory issue

    Hi Kir,

    You could always use a wildcard or regexp in the where clause in order to further filter the records you want to get.
    Regarding your custom module you can always use a subquery for it. This is just my opinion but i think you should
    only process/get record which is relevant to your requirements in order to minimize process time.

    Regards

  5. #5
    kir
    kir is offline Sugar Community Member
    Join Date
    Nov 2011
    Posts
    702

    Default Re: Search for matching phone - memory issue

    Quote Originally Posted by crmwa_Joel View Post
    Hi Kir,

    You could always use a wildcard or regexp in the where clause in order to further filter the records you want to get.
    Regarding your custom module you can always use a subquery for it. This is just my opinion but i think you should
    only process/get record which is relevant to your requirements in order to minimize process time.

    Regards
    Thanks!
    I got fatal error with memory limit (can't allocate ...), not the process time. RAM is 2 Gb
    I thought i don't need to do query for every record every time since i will search them all anyway.
    The table size is only few MB and i don't want to create 2 bean variable end store it for every phone number in custom module.
    1. I thought that i could place these two tables (or queary result with just phone fields) in cache and then just do search and flag bool variable for match/nomatch...
    2. If use bean - Can i unset them in logic hook function just after i processed record - to save memory?

    Thanks in advance!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Memory/memory size issue
    By jeffdude in forum Help
    Replies: 0
    Last Post: 2009-12-28, 10:37 PM
  2. Listview Memory Hog Issue
    By cygnusceo in forum Help
    Replies: 1
    Last Post: 2009-11-24, 07:03 AM
  3. phone field format issue
    By yxiao in forum Feature Requests
    Replies: 0
    Last Post: 2009-06-23, 05:05 AM
  4. Issue with Phone Numbers
    By ktremblay in forum Developer Help
    Replies: 2
    Last Post: 2009-04-13, 06:53 PM
  5. matching anywhere in a text field (contains search)
    By mjstrand in forum Feature Requests
    Replies: 0
    Last Post: 2006-01-26, 09:13 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •