<commit_before><?php
/*=========================================================================

  Program:   CDash - Cross-Platform Dashboard System
  Module:    $Id$
  Language:  PHP
  Date:      $Date$
  Version:   $Revision$

  Copyright (c) 2002 Kitware, Inc.  All rights reserved.
  See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
include_once('models/buildconfigureerror.php');
include_once('models/buildconfigureerrordiff.php');

/** BuildConfigure class */
class BuildConfigure
{
  var $StartTime;
  var $EndTime;
  var $Command;
  var $Log;
  var $Status;
  var $BuildId;
  
  function AddError($error)
    {
    $error->BuildId = $this->BuildId;
    $error->Save();
    }
  
  function AddErrorDifference($diff)
    {
    $diff->BuildId = $this->BuildId;
    $diff->Save();
    }
    
  function SetValue($tag,$value)  
    {
    switch($tag)
      {
      case "STARTTIME": $this->StartTime = $value;break;
      case "ENDTIME": $this->EndTime = $value;break;
      case "COMMAND": $this->Command = $value;break;
      case "LOG": $this->Log = $value;break;
      case "STATUS": $this->Status = $value;break;
      }
    }
      
  // Save in the database
  function Insert()
    {
    if(!$this->BuildId)
      {
      echo "BuildConfigure::Insert(): BuildId not set";
      return false;    
      }
    
    $command = pdo_real_escape_string($this->Command);
    $log = pdo_real_escape_string($this->Log);
    $status = pdo_real_escape_string($this->Status);
    
    $query = "INSERT INTO configure (buildid,starttime,endtime,command,log,status)
              VALUES (".qnum($this->BuildId).",'$this->StartTime','$this->EndTime','$command','$log','$status')";                     
    if(!pdo_query($query))
      {
      add_last_sql_error("BuildConfigure Insert()");
      return false;
      }  
    return true;
    }  // end insert            
    
  /** Compute the errors from the log */
  function ComputeErrors()
    {
    // Add the warnings in the configurewarningtable
    $position = strpos($this->Log,'Warning:',0);
    while($position !== false)
      {
      $warning = "";
      $endline = strpos($this->Log,'\n',$position);
      if($endline !== false)
        {
        $warning = substr($this->Log,$position,$endline-$position);
        }
      else
        {
        $warning = substr($this->Log,$position);
        }
        <commit_msg>ENH: Added Exists() and Delete() functions<commit_after><?php
/*=========================================================================

  Program:   CDash - Cross-Platform Dashboard System
  Module:    $Id$
  Language:  PHP
  Date:      $Date$
  Version:   $Revision$

  Copyright (c) 2002 Kitware, Inc.  All rights reserved.
  See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
include_once('models/buildconfigureerror.php');
include_once('models/buildconfigureerrordiff.php');

/** BuildConfigure class */
class BuildConfigure
{
  var $StartTime;
  var $EndTime;
  var $Command;
  var $Log;
  var $Status;
  var $BuildId;
  
  function AddError($error)
    {
    $error->BuildId = $this->BuildId;
    $error->Save();
    }
  
  function AddErrorDifference($diff)
    {
    $diff->BuildId = $this->BuildId;
    $diff->Save();
    }
    
  function SetValue($tag,$value)  
    {
    switch($tag)
      {
      case "STARTTIME": $this->StartTime = $value;break;
      case "ENDTIME": $this->EndTime = $value;break;
      case "COMMAND": $this->Command = $value;break;
      case "LOG": $this->Log = $value;break;
      case "STATUS": $this->Status = $value;break;
      }
    }
   
  /** Check if the configure exists */ 
  function Exists()
    {
    if(!$this->BuildId)
      {
      echo "BuildConfigure::Exists(): BuildId not set";
      return false;    
      }
    
    if(!is_numeric($this->BuildId))
      {
      echo "BuildConfigure::Exists(): Buildid is not numeric";
      return false;
      }
    
    $query = pdo_query("SELECT COUNT(*) FROM configure WHERE buildid=".qnum($this->BuildId));                     
    if(!$query)
      {
      add_last_sql_error("BuildConfigure Exists()");
      return false;
      }
    
    $query_array = pdo_fetch_array($query);
    if($query_array[0] > 0)
      {
      return true;
      }
    return false;
    } 
  
  /** Delete a current configure given a buildid */ 
  function Delete()
    {
    if(!$this->BuildId)
      {
      echo "BuildConfigure::Delete(): BuildId not set";
      return false;    
      }
    
    $query = pdo_query("DELETE FROM configure WHERE buildid=".qnum($this->BuildId));                     
    if(!$query)
      {
      add_last_sql_error("BuildConfigure Delete()");
      return false;
      }
    return true;
    } 
      
  // Save in the database
  function Insert()
    {
    if(!$this->BuildId)
      {
      echo "BuildConfigure::Insert(): BuildId not set";
      return false;    
      }
     
     if($this->Exists())
      {
      echo "BuildConfigure::Exists(): Cannot insert new configure. Use Delete() first";
      return false;    
      }
    
    $command = pdo_real_escape_string($this->Command);
    $log = pdo_real_escape_string($this->Log);
    $status = pdo_real_escape_string($this->Status);


    $query = "INSERT INTO configure (buildid,starttime,endtime,command,log,status)
              VALUES (".qnum($this->BuildId).",'$this->StartTime','$this->EndTime','$command','$log','$status')";                     
    if(!pdo_query($query))
      {
      add_last_sql_error("BuildConfigure Insert()");
      return false;
      }  
    return true;
    }  // end insert            
    
  /** Compute the errors from the log */
  function ComputeErrors()
    {
    // Add the warnings in the configurewarningtable
    $position = strpos($this->Log,'Warning:',0);
    while($position !== false)
      {
      $warning = "";
      $endline = strpos($this->Log,'\n',$position);
      if($endline !== false)
        {
        $warning = substr($this->Log,$position,$endline-$position);
        }
      else
        {
        $warning = substr($this->Log,$position);
        }
        
{'fraction_non_alphanumeric': 0.17917350440101448, 'fraction_numerical': 0.0017902431746978965, 'mean_word_length': 2.5621679064824656, 'pattern_counts': {'":': 10, '<': 5, '<?xml version=': 0, '>': 54, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5492654', 'n_tokens_mistral': 2016, 'n_tokens_neox': 1970, 'n_words': 434}