<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
include_once('models/buildupdatefile.php');

class BuildUpdate
{
  private $Files;
  var $StartTime;
  var $EndTime;
  var $Command;
  var $Type;
  var $Status;
  var $Revision;
  var $PriorRevision;
  var $Path;
  var $BuildId;

  public function __construct()
    {
    $this->Files = array();
    $this->Command = "";
    }

  function AddFile($file)
    {
    $this->Files[] = $file;
    }

  // Insert the update
  function Insert()
    {
    if(strlen($this->BuildId)==0 || !is_numeric($this->BuildId))
      {
      echo "BuildUpdate:Insert BuildId not set";
      return false;
      }

    // Remove any previous updates if not shared
    $query = pdo_query("SELECT updateid FROM build2update WHERE buildid=".qnum($this->BuildId));
    if(pdo_num_rows($query)==1)
      {
      $query_array = pdo_fetch_array($query);
      $updateid = $query_array['updateid'];

      // Check if this is shared
      $query = pdo_query("SELECT buildid FROM build2update WHERE updateid=".qnum($updateid));
      if(pdo_num_rows($query)==1)
        {
        $query = "DELETE FROM buildupdate WHERE id=".qnum($updateid);
        if(!pdo_query($query))
          {
          add_last_sql_error("BuildUpdate Insert",0,$this->BuildId);
          return false;
          }

        $query = "DELETE FROM updatefile WHERE updateid=".qnum($updateid);
        if(!pdo_query($query))
          {
          add_last_sql_error("BuildUpdate Insert",0,$this->BuildId);
          return false;
          }
        }
      $query = "DELETE FROM build2update WHERE buildid=".qnum($this->BuildId);
      if(!pdo_query($query))
        {
        add_last_sql_error("BuildUpdate Insert",0,$this->BuildId);
        return false;
        }
      }

    $this->StartTime = pdo_real_escape_string($this->StartTime);
    $this->EndTime = pdo_real_escape_string($this->EndTime);
    $this->Command = pdo_real_escape_string($this->Command);<commit_msg>STYLE: Wrong comment (thanks Dave)<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
include_once('models/buildupdatefile.php');

class BuildUpdate
{
  private $Files;
  var $StartTime;
  var $EndTime;
  var $Command;
  var $Type;
  var $Status;
  var $Revision;
  var $PriorRevision;
  var $Path;
  var $BuildId;

  public function __construct()
    {
    $this->Files = array();
    $this->Command = "";
    }

  function AddFile($file)
    {
    $this->Files[] = $file;
    }

  // Insert the update
  function Insert()
    {
    if(strlen($this->BuildId)==0 || !is_numeric($this->BuildId))
      {
      echo "BuildUpdate:Insert BuildId not set";
      return false;
      }

    // Remove previous updates
    $query = pdo_query("SELECT updateid FROM build2update WHERE buildid=".qnum($this->BuildId));
    if(pdo_num_rows($query)==1)
      {
      $query_array = pdo_fetch_array($query);
      $updateid = $query_array['updateid'];

      // If the buildupdate and updatefile are not shared we delete them as well
      $query = pdo_query("SELECT buildid FROM build2update WHERE updateid=".qnum($updateid));
      if(pdo_num_rows($query)==1)
        {
        $query = "DELETE FROM buildupdate WHERE id=".qnum($updateid);
        if(!pdo_query($query))
          {
          add_last_sql_error("BuildUpdate Insert",0,$this->BuildId);
          return false;
          }

        $query = "DELETE FROM updatefile WHERE updateid=".qnum($updateid);
        if(!pdo_query($query))
          {
          add_last_sql_error("BuildUpdate Insert",0,$this->BuildId);
          return false;
          }
        }
      $query = "DELETE FROM build2update WHERE buildid=".qnum($this->BuildId);
      if(!pdo_query($query))
        {
        add_last_sql_error("BuildUpdate Insert",0,$this->BuildId);
        return false;
        }
      }

    $this->StartTime = pdo_real_escape_string($this->StartTime);
    $this->EndTime = pdo_real_escape_string($this->EndTime);
    $this->Command = pdo_real_escape_string($this->Command);
{'fraction_non_alphanumeric': 0.1706681555927787, 'fraction_numerical': 0.004839009864135492, 'mean_word_length': 3.0681302043906133, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, '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': '1965320', 'n_tokens_mistral': 1600, 'n_tokens_neox': 1541, 'n_words': 381}