<commit_before>// Includes
var shortPoll = require('../util/shortPoll.js').func;
var getWall = require('../getWall.js').func;

// Args
exports.required = ['group'];
exports.optional = ['jar'];

// Define
exports.func = function (args) {
  var group = args.group;
  var jar = args.jar;
  return shortPoll({
    getLatest: function (latest) {
      return getWall({group: group, jar: jar, page: 1})
      .then(function (wall) {
        var posts = wall.posts;
        var given = [];
        for (var i = posts.length - 1; i >= 0; i--) {
          var post = posts[i];
          var id = post.id;
          if (id > latest) {
            latest = id;
            given.push(post);
          }
        }
        return {
          latest: latest,
          data: given
        };
      });
    },
    delay: 'onWallPost'
  });<commit_msg>Add support for viewstates<commit_after>// Includes
var shortPoll = require('../util/shortPoll.js').func;
var getWall = require('../getWall.js').func;

// Args
exports.required = ['group'];
exports.optional = ['view', 'jar'];

// Define
exports.func = function (args) {
  var group = args.group;
  var jar = args.jar;
  var view = args.view;
  return shortPoll({
    getLatest: function (latest) {
      return getWall({group: group, jar: jar, view: view, page: 1})
      .then(function (wall) {
        var posts = wall.posts;
        var given = [];
        for (var i = posts.length - 1; i >= 0; i--) {
          var post = posts[i];
          var id = post.id;
          if (id > latest) {
            latest = id;
            if (view) {
              post.view = wall.views[post.parent.page];
            }
            given.push(post);
          }
        }
        return {
          latest: latest,
          data: given
        };
      });
    },
    delay: 'onWallPost'
  });
{'fraction_non_alphanumeric': 0.1557871640153593, 'fraction_numerical': 0.0032912781130005485, 'mean_word_length': 1.7428571428571429, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '6165172', 'n_tokens_mistral': 575, 'n_tokens_neox': 572, 'n_words': 151}