public function actionPullFrecuentMenteeSubdomains()
 {
     $associationFilter = new AssociationFilter();
     if (isset($_POST['AssociationFilter'])) {
         $associationFilter->attributes = $_POST['AssociationFilter'];
         if (!is_numeric($associationFilter->lowerBoundMinSupport)) {
             $associationFilter->lowerBoundMinSupport = 0.1;
         }
         if (!is_numeric($associationFilter->numRulesToFind)) {
             $associationFilter->numRulesToFind = 10;
         }
         if (!is_numeric($associationFilter->uppperBoundMinSupport)) {
             $associationFilter->uppperBoundMinSupport = 1.0;
         }
     } else {
         $associationFilter->setDefaultValues();
     }
     //  echo $associationFilter->lowerBoundMinSupport;
     //1 pull all the attributes (Dinstinct SubDomains used)
     $subdomainsUsedCol = Subdomain::getAllSubdomainsInUse();
     //2 build the attributes collection
     $attributeCol = array();
     $attributeMap = array();
     $lastAttribIndex = count($subdomainsUsedCol) - 1;
     for ($i = 0; $i <= $lastAttribIndex; $i++) {
         $attribKey = $subdomainsUsedCol[$i]->name;
         $attribute = new Attribute($attribKey, $i);
         $attributeCol[] = $attribute;
         $attributeMap[$attribKey] = $attribute;
     }
     //3 pull all the item sets (relation of Subdomains with mentee)
     $subdomainsPerMenteeCol = AssociationFilter::retrieveSubDomainsUsedPerMentee();
     //4 build the instances
     $instancesCol = array();
     $currentCreatorID = NULL;
     $currentInstance = NULL;
     foreach ($subdomainsPerMenteeCol as $data) {
         if ($currentInstance == NULL || $currentCreatorID != ArrayUtils::getValueOrDefault($data, "MenteeUserID", 0)) {
             $currentCreatorID = ArrayUtils::getValueOrDefault($data, "MenteeUserID", 0);
             $currentInstance = new Instance($lastAttribIndex + 1);
             $instancesCol[] = $currentInstance;
         }
         $attribKey = ArrayUtils::getValueOrDefault($data, "SubDomainName", 0);
         $currentInstance->setValue($attributeMap[$attribKey], 1);
     }
     $instances = new Instances($attributeCol, $instancesCol);
     //5 calculate the association rules
     $fpGrowth = new FPGrowth();
     $fpGrowth->m_numRulesToFind = $associationFilter->numRulesToFind;
     $fpGrowth->m_upperBoundMinSupport = $associationFilter->uppperBoundMinSupport;
     $fpGrowth->lowerBoundMinSupport = $associationFilter->lowerBoundMinSupport;
     $fpGrowth->buildAssociations($instances);
     //6 render the association rules
     $rules = $fpGrowth->getRules();
     $associations = array();
     $id = 0;
     foreach ($rules as $rule) {
         $associations[] = array("id" => $id, "Operator" => " ==> ", "Premise" => $this->renderBinaryItemsCommaSeparated($rule->getPremise()), "Consequence" => $this->renderBinaryItemsCommaSeparated($rule->getConsequence()));
         //echo $this->renderBinaryItemsCommaSeparated($rule->getPremise()). " ==> ".$this->renderBinaryItemsCommaSeparated($rule->getConsequence()). "</br>";
         $id++;
     }
     $dataProvider = new CArrayDataProvider($associations, array('pagination' => false));
     $this->render("frecuentMenteeSubdomains", array('dataprovider' => $dataProvider, 'filter' => $associationFilter));
 }
 public function retrieveUnansweredTicketsDashboardData()
 {
     //retrieve tha data
     $ticketsCreatedData = $this->retrieveUnansweredTicketsData();
     $chartData = "";
     foreach ($ticketsCreatedData as $data) {
         $countPart = ArrayUtils::getValueOrDefault($data, "EventCount", 0);
         if (DimensionType::isTimeDimension($this->dim2ID)) {
             $currentReadingYear = ArrayUtils::getValueOrDefault($data, "Year", 1);
             $currentReadingMonth = ArrayUtils::getValueOrDefault($data, "Month", 1);
             $currentReadingDay = ArrayUtils::getValueOrDefault($data, "Day", 1);
             $chartData = $chartData . sprintf('[new Date(%s, %s, %s), %s],', $currentReadingYear, $currentReadingMonth - 1, $currentReadingDay, $countPart);
         } else {
             switch ($this->dim2ID) {
                 case DimensionType::TicketAssignedMentor:
                     $mentorName = ArrayUtils::getValueOrDefault($data, "MentorName", 0);
                     $chartData = $chartData . sprintf("['%s', %s],", $mentorName, $countPart);
                     break;
                 case DimensionType::Mentee:
                     $menteeName = ArrayUtils::getValueOrDefault($data, "MenteeName", 0);
                     $chartData = $chartData . sprintf("['%s', %s],", $menteeName, $countPart);
                     break;
                 case DimensionType::DomainExclusive:
                     $domainExclusive = ArrayUtils::getValueOrDefault($data, "Domain", 0);
                     $chartData = $chartData . sprintf("['%s', %s],", $domainExclusive, $countPart);
                     break;
                 case DimensionType::DomainAggregated:
                     $domainAggregated = ArrayUtils::getValueOrDefault($data, "Domain", 0);
                     $chartData = $chartData . sprintf("['%s', %s],", $domainAggregated, $countPart);
                     break;
                 case DimensionType::SubDomain:
                     $subDomain = ArrayUtils::getValueOrDefault($data, "SubDomain", 0);
                     $chartData = $chartData . sprintf("['%s', %s],", $subDomain, $countPart);
                     break;
                 case DimensionType::Project:
                     $project = ArrayUtils::getValueOrDefault($data, "Project", 0);
                     $chartData = $chartData . sprintf("['%s', %s],", $project, $countPart);
                     break;
             }
         }
     }
     //format the data
     $chartFormatedData = "[" . $chartData . "]";
     // "[[new Date(2015, 2, 1),1],[new Date(2015, 3, 1),1]]";// json_encode($monthData);
     return $chartFormatedData;
 }