Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in PublisherQueryLanguageContextError.UNEXECUTABLE #795

Open
divyeshgajja opened this issue May 8, 2024 · 0 comments
Open

Error in PublisherQueryLanguageContextError.UNEXECUTABLE #795

divyeshgajja opened this issue May 8, 2024 · 0 comments

Comments

@divyeshgajja
Copy link

Hello everyone i am getting this error how to solve this?
[PublisherQueryLanguageContextError.UNEXECUTABLE @ Only constant values and bound values are allowed in the haystack of IN.].

i am using this code :

$statementBuilder = (new StatementBuilder())
->where('AD_UNIT_ID IN ('.$excluded.')');

$reportQuery->setStatement($statementBuilder->toStatement());
$reportQuery->setAdUnitView(ReportQueryAdUnitView::HIERARCHICAL);

$reportQuery->setDateRangeType(DateRangeType::TODAY);

$reportJob = new ReportJob();
$reportJob->setReportQuery($reportQuery);

        $reportJob = $reportService->runReportJob($reportJob);
        $exportFormat = 'CSV_DUMP';
        $reportJobId = $reportJob->getId();
        $reportDownloader = new ReportDownloader($reportService, $reportJobId);

if ($reportDownloader->waitForReportToFinish()) {
// set download option
$options = new ReportDownloadOptions();
$options->setExportFormat($exportFormat);
$options->setUseGzipCompression(FALSE);

        $downloadUrl = $reportService->getReportDownloadUrlWithOptions($reportJobId, $options);


        $filePath = dirname(dirname(__DIR__)).'/webroot/adxreports/'.rand().'-admanager-Native-report.csv';

        file_put_contents($filePath, fopen($downloadUrl, 'rb'));
        $file = fopen($filePath, 'r');
         $admanagerRecords = array();
         $row = 1;
        while (($line = fgetcsv($file)) !== FALSE) {


          if($row == 1){ $row++; continue; }
          $ad_unit_id = $line[0];
          $ad_unit_name = $line[1];
          $COUNTRY_NAME = $line[2];
          $criteria_id = $line[3];
          $click = $line[4];
          $impression = $line[5];
          $revenue = $line[6];
          $request = $line[7];
          $unmatch = $line[8];
          // $request = 0;
          // $unmatch = 0;

              $key  = array_search($line[0],$adunits);
              $ckey  = array_search($criteria_id,$cids);
              $appID = $records[$key]['application_id'];
              $countryId = $countryList[$ckey]['id'];

              $ctr = (($click > 0 && $impression > 0)?($click / $impression)*100 : 0);
              $revenueINR = ($revenue / 1000000);
              $cpc = ($revenueINR>0 && $click>0)?($revenueINR/$click):0;
              $ctrvalue =  number_format($ctr,2);
              $cpcvalue =  number_format($cpc,2);

              if($impression > 0 && $revenueINR > 0 && $criteria_id > 0){

                if(isset($dateRange) && $dateRange=='LASTWEEK'){
                  $admanagerRecords[] = array('report_flag'=>$hour,'application_id'=>$appID,'adunit_id'=>$ad_unit_id,'adunit_name'=>$ad_unit_name,'campaign_type'=>'Native',
                  'country_id'=>$countryId,'revenue'=>$revenueINR,'impressions'=>$impression,'clicks'=>$click,'ctr'=>$ctrvalue,'cpc'=>$cpcvalue,'created'=>$insertDate);
                }elseif(isset($dateRange) && $dateRange!='TODAY'){
                $admanagerRecords[] = array('report_flag'=>$YDflag,'application_id'=>$appID,'adunit_id'=>$ad_unit_id,'adunit_name'=>$ad_unit_name,'campaign_type'=>'Native',
                'country_id'=>$countryId,'clicks'=>$click,'impressions'=>$impression,'revenue'=>$revenueINR,'ctr'=>$ctrvalue,'cpc'=>$cpcvalue,'created'=>$insertDate,'total_requests'=>$request,'unmatched_requests'=>$unmatch);
              }elseif(isset($dateRange) && $dateRange=='CUSTOM'){
                $admanagerRecords[] = array('application_id'=>$appID,'adunit_id'=>$ad_unit_id,'adunit_name'=>$ad_unit_name,'campaign_type'=>'Native',
                'country_id'=>$countryId,'clicks'=>$click,'impressions'=>$impression,'revenue'=>$revenueINR,'ctr'=>$ctrvalue,'cpc'=>$cpcvalue,'created'=>$insertDate,'total_requests'=>$request,'unmatched_requests'=>$unmatch);
              }else{
               $admanagerRecords[] = array('report_flag'=>$hour,'application_id'=>$appID,'adunit_id'=>$ad_unit_id,'adunit_name'=>$ad_unit_name,'campaign_type'=>'Native',
               'country_id'=>$countryId,'clicks'=>$click,'impressions'=>$impression,'revenue'=>$revenueINR,'ctr'=>$ctrvalue,'cpc'=>$cpcvalue,'created'=>$insertDate,'total_requests'=>$request,'unmatched_requests'=>$unmatch);
             }

           }

         }

         if(isset($dateRange) && $dateRange=='LASTWEEK'){
           $reports  = TableRegistry::getTableLocator()->get('WeeklyAdxReport');
           $entities = $reports->newEntities($admanagerRecords);
           $result   = $reports->saveMany($entities);
           unlink($filePath);
         }elseif(isset($dateRange) && $dateRange=='CUSTOM'){
            $reports  = TableRegistry::getTableLocator()->get('AdxReport');
            $entities = $reports->newEntities($admanagerRecords);
            $result   = $reports->saveMany($entities);
            unlink($filePath);
          }else{
            $reports  = TableRegistry::getTableLocator()->get('TodayAdxReport');
            $entities = $reports->newEntities($admanagerRecords);
            $result   = $reports->saveMany($entities);
            unlink($filePath);

          }

    }else {
      echo 'failed';
      exit;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant