<commit_before>// simple-todos.js

// TODO: Add tasks from console to populate collection
// On Server:
// db.tasks.insert({ text: "Hello world!", createdAt: new Date() });
// On Client:
// Tasks.insert({ text: "Hello world!", createdAt: new Date() });
Tasks = new Mongo.Collection("tasks");


if (Meteor.isClient) {
  // This code only runs on the client
  Template.body.helpers({
    tasks: function () {
      return Tasks.find({});
    }
  });

  // Inside the if (Meteor.isClient) block, right after Template.body.helpers:
  Template.body.events({
    "submit .new-task": function (event) {
      // This function is called when the new task form is submitted

      var text = event.target.text.value;

      Tasks.insert({
        text: text,
        createdAt: new Date() // current time
      });<commit_msg>WebApp-4b: Sort tasks by createdAt timestamp<commit_after>// simple-todos.js

// TODO: Add tasks from console to populate collection
// On Server:
// db.tasks.insert({ text: "Hello world!", createdAt: new Date() });
// On Client:
// Tasks.insert({ text: "Hello world!", createdAt: new Date() });
Tasks = new Mongo.Collection("tasks");


if (Meteor.isClient) {
  // This code only runs on the client
  Template.body.helpers({
    tasks: function () {
      // Show newest tasks first
      return Tasks.find({}, {sort: {createdAt: -1}});
    }
  });

  // Inside the if (Meteor.isClient) block, right after Template.body.helpers:
  Template.body.events({
    "submit .new-task": function (event) {
      // This function is called when the new task form is submitted

      var text = event.target.text.value;

      Tasks.insert({
        text: text,
        createdAt: new Date() // current time
      });
{'fraction_non_alphanumeric': 0.1474172954149739, 'fraction_numerical': 0.0011607661056297156, 'mean_word_length': 2.814159292035398, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, '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': '5300774', 'n_tokens_mistral': 528, 'n_tokens_neox': 513, 'n_words': 172}