<commit_before>angular.module('app.services').factory('announcements',function ($q, AnnouncementsResource, iStorage) {

  var announcements = [],
    LAST_VIEWED_ANNOUNCEMENTS_KEY = 'announcements_viewed_date',
    start = new Date(Date.now() - 86400000),
    lastViewedDate = new Date(Date.now() - 86400000),
    numberOfNew = 0
    ;

  var strDate = iStorage.get(LAST_VIEWED_ANNOUNCEMENTS_KEY);
  if (strDate) {
    lastViewedDate = new Date(strDate);
  }

  function prepare(data) {
    numberOfNew = 0;
    _(data).each(function (item) {
      item.published_at_date = new Date(item.published_at);
      if (item.published_at_date > lastViewedDate) {
        numberOfNew++;
      }
    });
  }

  return {
    get: function () {
      return announcements;
    },

    load: function () {
      var deferred = $q.defer();
      start.setTime(Date.now() - 7776000000 * 2);
      AnnouncementsResource.query({start: start.toUTCString()}, function (data) {
        prepare(data);
        announcements = data;
        deferred.resolve(announcements);
      }, function () {
        deferred.reject();
      });
      return deferred.promise;
    },

    getNumberOfNew: function () {
      return numberOfNew;
    },

    setViewed: function () {
      lastViewedDate = new Date(Date.now());
      iStorage.set(LAST_VIEWED_ANNOUNCEMENTS_KEY, lastViewedDate.toUTCString());
    },

    updateNumberOfNew: function () {
      numberOfNew = 0;
      _(announcements).each(function (item) {
        if (item.published_at_date > lastViewedDate) {
          numberOfNew++;
        }
      });
    }
  };

}).factory('AnnouncementsResource', function ($resource, serverConfig) {
  var strDate = new Date(Date.now() - 86400000);
  return $resource(serverConfig.url + '/api/announcements', {},{
    query: {
      method: 'GET',
      params: {start: strDate},
      isArray: false
    }<commit_msg>fix bug #65: #main page throws Error: [:badcfg]<commit_after>angular.module('app.services').factory('announcements',function ($q, AnnouncementsResource, iStorage) {

  var announcements = [],
    LAST_VIEWED_ANNOUNCEMENTS_KEY = 'announcements_viewed_date',
    start = new Date(Date.now() - 86400000),
    lastViewedDate = new Date(Date.now() - 86400000),
    numberOfNew = 0
    ;

  var strDate = iStorage.get(LAST_VIEWED_ANNOUNCEMENTS_KEY);
  if (strDate) {
    lastViewedDate = new Date(strDate);
  }

  function prepare(data) {
    numberOfNew = 0;
    _(data).each(function (item) {
      item.published_at_date = new Date(item.published_at);
      if (item.published_at_date > lastViewedDate) {
        numberOfNew++;
      }
    });
  }

  return {
    get: function () {
      return announcements;
    },

    load: function () {
      var deferred = $q.defer();
      start.setTime(Date.now() - 7776000000 * 2);
      AnnouncementsResource.query({start: start.toUTCString()}, function (data) {
        prepare(data);
        announcements = data;
        deferred.resolve(announcements);
      }, function () {
        deferred.reject();
      });
      return deferred.promise;
    },

    getNumberOfNew: function () {
      return numberOfNew;
    },

    setViewed: function () {
      lastViewedDate = new Date(Date.now());
      iStorage.set(LAST_VIEWED_ANNOUNCEMENTS_KEY, lastViewedDate.toUTCString());
    },

    updateNumberOfNew: function () {
      numberOfNew = 0;
      _(announcements).each(function (item) {
        if (item.published_at_date > lastViewedDate) {
          numberOfNew++;
        }
      });
    }
  };

}).factory('AnnouncementsResource', function ($resource, serverConfig) {
  var strDate = new Date(Date.now() - 86400000);
  return $resource(serverConfig.url + '/api/v2/announcements', {},{
    query: {
      method: 'GET',
      params: {start: strDate},
      isArray: false
    }
{'fraction_non_alphanumeric': 0.1360900287882753, 'fraction_numerical': 0.020675215912064903, 'mean_word_length': 2.8489425981873113, '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': '3930764', 'n_tokens_mistral': 1305, 'n_tokens_neox': 1212, 'n_words': 217}