<commit_before>import '../dart_todo_server.dart';

class TodoController extends HTTPController
{
  @httpGet
  getAllTodos() async
  {
    var todoQuery = new Query<Todo>();
    var todos = await todoQuery.fetch();
    return new Response.ok(todos);
  }

  @httpPost
  createTodo() async 
  {
    request.decodeBody();
    var requestBody = request.requestBodyObject;
    var insertQuery = new Query<Todo>()
      ..valueMap = requestBody;
    var newTodo = await insertQuery.insert();
    return new Response.ok(newTodo);
  }

  @httpPut
  updateTodo(int id, String text)
  {

  }
}<commit_msg>add sorting to data and put endpoint<commit_after>import '../dart_todo_server.dart';

class TodoController extends HTTPController
{
  @httpGet
  getAllTodos() async
  {
    var todoQuery = new Query<Todo>();
    var todos = await todoQuery.fetch()
      ..sort((a,b) => a.id.compareTo(b.id));
    return new Response.ok(todos);
  }

  @httpPost
  createTodo() async 
  {
    request.decodeBody();
    var requestBody = request.requestBodyObject;
    var insertQuery = new Query<Todo>()
      ..valueMap = requestBody;
    var newTodo = await insertQuery.insert();
    return new Response.ok(newTodo);
  }

  @httpPut
  updateTodo(@HTTPPath("id")int id) async
  {
    request.decodeBody();
    var requestBody = request.requestBodyObject;
    print(requestBody);
    var updateQuery = new Query<Todo>()
      ..valueMap = requestBody
      ..matchOn.id = id;
    var updatedTodo = await updateQuery.updateOne();
    
    if(updatedTodo != null)
    {
      return new Response.ok(updatedTodo);
    }
    return new Response.notFound();
  }
}
{'fraction_non_alphanumeric': 0.11995104039167687, 'fraction_numerical': 0.0, 'mean_word_length': 3.1392405063291138, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 9, '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': '5926222', 'n_tokens_mistral': 538, 'n_tokens_neox': 530, 'n_words': 122}