<commit_before><?php

class ConferenceController extends BaseController {
	/**
	 * List of conferences.
	 */
    public function getIndex() {
		return View::make('conference/conferences');
    }

    /**
	 * Details of the specified conference.
	 */
    public function getDetails($id) {
		$conference = Conference::with('editions', 'editions.event')->find($id);
		if (!is_null($conference)) {
			return View::make('conference/conference')->with('conference', $conference);
		} else {
			App::abort(404);
		}
    }

	/**
	 * Asynchronous loading of conference list.
	 */
    public function getData() {
        if(Request::ajax()) {
			$query = Conference::join('rankings', 'rankings.id', '=', 'conferences.ranking_id')
					->select(array('conferences.name', 'acronym', 'rankings.name AS ranking_name', 'field_of_research', 'conferences.id'));
			return Datatables::of($query)->make();
		} else {
			return null;
		}
	}

	/**
	 * Autocomplete for conferences.
	 */
    public function getAutocomplete($query) {
        if(Request::ajax()) {
			// order for consistent results
			$search = '%'.$query.'%';
			return Conference::select(array('id', 'name', 'acronym'))->where('name', 'LIKE', $search)->orWhere('acronym', 'LIKE', $search)->orderBy('id', 'ASC')->take(5)->get()->toJson();
		} else {
			return null;
		}
	}

	/**
	 * Check the given conference name for existence.
	 */
    public function anyCheck($name = null) {
        if(Request::ajax()) {
			if (is_null($name)) {
				$name = Input::get('name');
			}
			$exists = Conference::where('name', '=', $name)->first();
			return json_encode(array(
				'valid' => (bool) $exists,
			));
		} else {
			return null;
		}
	}

	/**
	 * Return the id of the conference with the given name or nothing if it doesn't exist.
	 */
    public function anyId($name = null) {
		if (Request::ajax()) {
			if (is_null($name)) {
				$name = Input::get('name');
			}
			$result = Conference::where('name', '=', $name)->first();
			if ($result) {
				return $result->id;
			} else {
				return '';
			}
		} else {
			return null;
		}
	}

	/**
	 * Return a JSON of conference editions (id and edition string) of the conference with the given name.
	 */
    public function anyEditions($name = null) {
		if (Request::ajax()) {
			if (is_null($name)) {
				$name = Input::get('name');
			}
			$result = Conference::where('name', '=', $name)->first();
			if ($result) {
				return $result->editions()->get(array('id', 'edition'))->toJson();
			} else {
				return '[]';
			}
		} else {
			return null;
		}
	}
}<commit_msg>order conference editions by creation date (desc)<commit_after><?php

class ConferenceController extends BaseController {
	/**
	 * List of conferences.
	 */
    public function getIndex() {
		return View::make('conference/conferences');
    }

    /**
	 * Details of the specified conference.
	 */
    public function getDetails($id) {
		$conference = Conference::with('editions', 'editions.event')->find($id);
		if (!is_null($conference)) {
			return View::make('conference/conference')->with('conference', $conference);
		} else {
			App::abort(404);
		}
    }

	/**
	 * Asynchronous loading of conference list.
	 */
    public function getData() {
        if(Request::ajax()) {
			$query = Conference::join('rankings', 'rankings.id', '=', 'conferences.ranking_id')
					->select(array('conferences.name', 'acronym', 'rankings.name AS ranking_name', 'field_of_research', 'conferences.id'));
			return Datatables::of($query)->make();
		} else {
			return null;
		}
	}

	/**
	 * Autocomplete for conferences.
	 */
    public function getAutocomplete($query) {
        if(Request::ajax()) {
			// order for consistent results
			$search = '%'.$query.'%';
			return Conference::select(array('id', 'name', 'acronym'))->where('name', 'LIKE', $search)->orWhere('acronym', 'LIKE', $search)->orderBy('id', 'ASC')->take(5)->get()->toJson();
		} else {
			return null;
		}
	}

	/**
	 * Check the given conference name for existence.
	 */
    public function anyCheck($name = null) {
        if(Request::ajax()) {
			if (is_null($name)) {
				$name = Input::get('name');
			}
			$exists = Conference::where('name', '=', $name)->first();
			return json_encode(array(
				'valid' => (bool) $exists,
			));
		} else {
			return null;
		}
	}

	/**
	 * Return the id of the conference with the given name or nothing if it doesn't exist.
	 */
    public function anyId($name = null) {
		if (Request::ajax()) {
			if (is_null($name)) {
				$name = Input::get('name');
			}
			$result = Conference::where('name', '=', $name)->first();
			if ($result) {
				return $result->id;
			} else {
				return '';
			}
		} else {
			return null;
		}
	}

	/**
	 * Return a JSON of conference editions (id and edition string) of the conference with the given name.
	 */
    public function anyEditions($name = null) {
		if (Request::ajax()) {
			if (is_null($name)) {
				$name = Input::get('name');
			}
			$result = Conference::where('name', '=', $name)->first();
			if ($result) {
				return $result->editions()->orderBy('created_at', 'DESC')->get(array('id', 'edition'))->toJson();
			} else {
				return '[]';
			}
		} else {
			return null;
		}
	}
}
{'fraction_non_alphanumeric': 0.19428902180204516, 'fraction_numerical': 0.001543507621068879, 'mean_word_length': 3.2949461474730737, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 40, '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': '5437257', 'n_tokens_mistral': 1922, 'n_tokens_neox': 1660, 'n_words': 379}