<commit_before><?php

class m120222_115209_new_general_anaesthetic_field_for_sessions_and_sequences extends CDbMigration
{
	public function up()
	{
		$this->addColumn('sequence','general_anaesthetic','tinyint(1) unsigned NOT NULL DEFAULT 0');
		$this->addColumn('session','general_anaesthetic','tinyint(1) unsigned NOT NULL DEFAULT 0');
		$this->update('sequence',array('general_anaesthetic' => 1), 'anaesthetist = 1');
		$this->update('session',array('general_anaesthetic' => 1), 'anaesthetist = 1');

		$sequences = array();

		// Anaesthetists at St Anns, Mile End and Potters Bar cannot do general anaesthetic
		foreach ($this->dbConnection->createCommand()
			->select('sequence.id')
			->from('sequence')
			->join('theatre','theatre.id = sequence.theatre_id')
			->join('site','site.id = theatre.site_id')
			->where("site.short_name in ('St Ann''s','Mile End','Potters Bar')")
			->queryAll() as $row) {
			$sequences[] = $row['id'];
		}

		$this->update('sequence',array('general_anaesthetic' => 0),'id in ('.implode(',',$sequences).')');
		$this->update('session',array('general_anaesthetic' => 0),'sequence_id in ('.implode(',',$sequences).')');
	}

	public function down()
	{
		$this->dropColumn('sequence','general_anaesthetic');
		$this->dropColumn('session','general_anaesthetic');
	}
}<commit_msg>fixed the migration that adds the new general_anaesthetic field to the session and sequence tables so that it doesn't try to update rows where there are 0 in the array.<commit_after><?php

class m120222_115209_new_general_anaesthetic_field_for_sessions_and_sequences extends CDbMigration
{
	public function up()
	{
		$this->addColumn('sequence','general_anaesthetic','tinyint(1) unsigned NOT NULL DEFAULT 0');
		$this->addColumn('session','general_anaesthetic','tinyint(1) unsigned NOT NULL DEFAULT 0');
		$this->update('sequence',array('general_anaesthetic' => 1), 'anaesthetist = 1');
		$this->update('session',array('general_anaesthetic' => 1), 'anaesthetist = 1');

		$sequences = array();

		// Anaesthetists at St Anns, Mile End and Potters Bar cannot do general anaesthetic
		foreach ($this->dbConnection->createCommand()
			->select('sequence.id')
			->from('sequence')
			->join('theatre','theatre.id = sequence.theatre_id')
			->join('site','site.id = theatre.site_id')
			->where("site.short_name in ('St Ann''s','Mile End','Potters Bar')")
			->queryAll() as $row) {
			$sequences[] = $row['id'];
		}

		if (!empty($sequences)) {
			$this->update('sequence',array('general_anaesthetic' => 0),'id in ('.implode(',',$sequences).')');
			$this->update('session',array('general_anaesthetic' => 0),'sequence_id in ('.implode(',',$sequences).')');
		}
	}

	public function down()
	{
		$this->dropColumn('sequence','general_anaesthetic');
		$this->dropColumn('session','general_anaesthetic');
	}
}
{'fraction_non_alphanumeric': 0.18756660746003553, 'fraction_numerical': 0.015985790408525755, 'mean_word_length': 6.129113924050633, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6351235', 'n_tokens_mistral': 1022, 'n_tokens_neox': 907, 'n_words': 183}