<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.

=========================================================================*/
// It is assumed that appropriate headers should be included before including this file

/** Main subproject class */
class SubProject
{
  var $Name;
  var $Id; 
  var $ProjectId;
  
  function __construct()
    {
    }
  
  /** Function to set the project id */
  function SetProjectId($projectid)
    {
    if(is_numeric($projectid))
      {
      $this->ProjectId = $projectid;
      return true;
      }
    return false;  
    }  
  
  /** Delete a project */
  function Delete($keephistory=true)
    {
    if(!$this->Id)
      {
      return false;    
      }
    
    if(!$keephistory)
      { 
      pdo_query("DELETE FROM subproject2build WHERE subprojectid=".qnum($this->Id));
      pdo_query("DELETE FROM subproject2subproject WHERE subprojectid=".qnum($this->Id));
      pdo_query("DELETE FROM subproject2subproject WHERE dependsonid=".qnum($this->Id));
      pdo_query("DELETE FROM subproject WHERE id=".qnum($this->Id));
      }
    else
      {
      $endtime = gmdate(FMT_DATETIME);
      $query = "UPDATE subproject SET ";
      $query .= "endtime='".$endtime."'";
      $query .= " WHERE id=".qnum($this->Id)."";
      if(!pdo_query($query))
        {
        add_last_sql_error("SubProject Delete");
        return false;
        }
      }  
    }
      
  /** Return if a project exists */
  function Exists()
    {
    // If no id specify return false<commit_msg>ENH: Removing subproject if no build in it<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.

=========================================================================*/
// It is assumed that appropriate headers should be included before including this file

/** Main subproject class */
class SubProject
{
  var $Name;
  var $Id; 
  var $ProjectId;
  
  function __construct()
    {
    }
  
  /** Function to set the project id */
  function SetProjectId($projectid)
    {
    if(is_numeric($projectid))
      {
      $this->ProjectId = $projectid;
      return true;
      }
    return false;  
    }  
  
  /** Delete a project */
  function Delete($keephistory=true)
    {
    if(!$this->Id)
      {
      return false;    
      }
    
    // If there is no build in the subproject we remove
    $query = pdo_query("SELECT count(*) FROM subproject2build WHERE subprojectid=".qnum($this->Id));
    if(!$query)
      {
      add_last_sql_error("SubProject Delete");
      return false;
      }
    $query_array = pdo_fetch_array($query);
    if($query_array[0]==0)
      {
      $keephistory = false;
      }
    
    if(!$keephistory)
      { 
      pdo_query("DELETE FROM subproject2build WHERE subprojectid=".qnum($this->Id));
      pdo_query("DELETE FROM subproject2subproject WHERE subprojectid=".qnum($this->Id));
      pdo_query("DELETE FROM subproject2subproject WHERE dependsonid=".qnum($this->Id));
      pdo_query("DELETE FROM subproject WHERE id=".qnum($this->Id));
      }
    else
      {
      $endtime = gmdate(FMT_DATETIME);
      $query = "UPDATE subproject SET ";
      $query .= "endtime='".$endtime."'";
      $query .= " WHERE id=".qnum($this->Id)."";
      if(!pdo_query($query))
        {
        add_last_sql_error("SubProject Delete");
        return false;
        }
      }  
    }
      
  /** Return if a project exists */
  function Exists()
    {
    // If no id specify return false
{'fraction_non_alphanumeric': 0.1757751505688155, 'fraction_numerical': 0.0037921035021191165, 'mean_word_length': 2.7242524916943522, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 18, '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': '6500294', 'n_tokens_mistral': 1317, 'n_tokens_neox': 1280, 'n_words': 345}