<commit_before>import { Template } from 'meteor/templating';
import './main.html';

// Collection with the images
Images = new Mongo.Collection('images');

// Configuration of the registration form
Accounts.ui.config({
  passwordSignupFields: 'USERNAME_AND_EMAIL',
});

// ****** Helpers

/**
 * We send the Images collection to the template with the aid of a helper
 * We can choose the attribute to order the objects
 */
Template.images.helpers({
  images: () => {
    if (Session.get('userFilter')) {
      return Images.find(
        { createdBy: Session.get('userFilter') },
        { sort: { createdOn: -1, rating: -1 } }
      );
    }
    return Images.find({}, { sort: { createdOn: -1, rating: -1 } });
  },
  getUser: userId => {
    // We need to get from the collection the user
    const user = Meteor.users.findOne({ _id: userId });
    // If user !== undefined returns the username
    if (user) {
      return user.username;
    }
    // If you can`t find in the collection return the default value
    return 'No One';
  },
  getFilterUser: () => {<commit_msg>C_Meteor - Agregado scroll infinito<commit_after>import { Template } from 'meteor/templating';
import './main.html';

// Collection with the images
Images = new Mongo.Collection('images');

// Infinite Scroll
Session.set('imageLimit', 8);
let lastScrollTop = 0;
$(window).scroll(function(event) {
  console.log('Scroll');
  // test if we are near the bottom of the window
  if ($(window).scrollTop() + $(window).height() > $(document).height() - 100) {
    // where are we in the page? 
    let scrollTop = $(this).scrollTop();
    // test if we are going down
    if (scrollTop > lastScrollTop) {
      // yes we are heading down...
      Session.set('imageLimit', Session.get('imageLimit') + 4);
    }
    lastScrollTop = scrollTop;
  }
});

// Configuration of the registration form
Accounts.ui.config({
  passwordSignupFields: 'USERNAME_AND_EMAIL',
});

// ****** Helpers

/**
 * We send the Images collection to the template with the aid of a helper
 * We can choose the attribute to order the objects
 */
Template.images.helpers({
  images: () => {
    if (Session.get('userFilter')) {
      return Images.find(
        { createdBy: Session.get('userFilter') },
        { sort: { createdOn: -1, rating: -1 } }
      );
    }
    return Images.find({}, {
      sort: { createdOn: -1, rating: -1 },
      limit: Session.get('imageLimit'),
    });
  },
  getUser: userId => {
    // We need to get from the collection the user
    const user = Meteor.users.findOne({ _id: userId });
    // If user !== undefined returns the username
    if (user) {
      return user.username;
    }
    // If you can`t find in the collection return the default value
    return 'No One';
  },
  getFilterUser: () => {
{'fraction_non_alphanumeric': 0.14670981661272922, 'fraction_numerical': 0.005034160373966199, 'mean_word_length': 2.890909090909091, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '5010918', 'n_tokens_mistral': 844, 'n_tokens_neox': 833, 'n_words': 269}