<commit_before>/**
* @Author: <NAME> <ikismail7>
* @Author: Saleemah <Saleemahmh>
* @Date:   2017-08-30T16:05:45+05:30
 * @Last modified by:   <NAME>
 * @Last modified time: 2017-09-06T16:21:15+05:30
*/
app.controller('newsController', ['$scope','appService',function(
  $scope,appService) {

    $scope.category;
    $scope.sourceData = [];
    $scope.image ;
    var topStoriesSource = ['bbc-news', 'cnbc','cnn','daily-mail',
    'engadget', 'mtv-news', 'espn-cric-info', 'time',
    'techradar', 'google-news', 'the-times-of-india'];

    var latestSource=['al-jazeera-english','breitbart-news', 'business-insider', 'business-insider-uk', 'buzzfeed',
    'daily-mail', 'engadget', 'espn-cric-info', 'fox-sports', 'ign',
    'metro', 'mirror', 'mtv-news', 'newsweek', 'new-york-magazine','reuters', 'techcrunch', 'techradar',
    'the-hindu', 'the-next-web', 'the-telegraph', 'the-times-of-india'];
    $scope.topStories = [];
    $scope.latest=[];

    $scope.getNewsBySource = function(category){
      $scope.category = category;
      appService.getNewsBySource(category).then(function(data){
        $scope.sourceData = data;
      },function(error){
        // $.toaster({ priority : 'error', title : 'Error', message : 'error while fetching resources'});
      })
    };
    $scope.getTopStories = function(){
      $scope.topStories = [];
      console.log('topStories');
      for (var i = 0; i < topStoriesSource.length; i++) {
        appService.getStories(topStoriesSource[i], 'top').then(function(data){
          $scope.topStories.push(data);
          console.log($scope.topStories);
        },function(error){
          // $.toaster({ priority : 'error', title : 'Error', message : 'error while fetching resources'});
        })
      }
    };
    $scope.getLatest = function(){
      $scope.latest = [];
      console.log('Latest');
      for (var i = 0; i < latestSource.length; i++) {
        appService.getStories(latestSource[i], 'latest').then(function(data){
          $scope.latest.push(data);
          console.log($scope.latest);
        },function(error){
          // $.toaster({ priority : 'error', title : 'Error', message : 'error while fetching resources'});
        })
      }
    };
    $scope.getAllSources = function(){
      appService.getAllSources().then(function(data){
        $scope.sources = data;
      },function(errorResponse){
        // $.toaster({ priority : 'error', title : 'Error', message : 'error while fetching resources'});
      })
    }

    $scope.getStories = function(source,sortBy){
      appService.getStories(source,sortBy).then(function(data){
        $scope.sourceData = data;
      },function(errorResponse){
        // $.toaster({ priority : 'error', title : 'Error', message : 'error while fetching resources'});
      })
    }

    $scope.getAllSources();

//Pagination
    //show more functionality

    var pagesShown = 1;

    var pageSize = 1;
//categorySize denotes number of category shown
var categorySize=5;
    $scope.paginationLimit = function() {
      return pageSize * pagesShown;
    };
    $scope.paginationCategoryLimit = function() {
      return categorySize * pagesShown;
    };
    $scope.hasMoreLatestToShow = function() {
      return pagesShown < ($scope.latest.length / pageSize);
    };
    $scope.hasMoreStoriesToShow = function() {
      return pagesShown < ($scope.topStories.length / pageSize);
    };
    $scope.hasMoreCategoryToShow = function() {
      return pagesShown < ($scope.sourceData.length / categorySize);
    };
    $scope.showMoreItems = function() {
      pagesShown = pagesShown + 1;
    };
    $scope.dateConversion=function(data) {
        $scope.date = data;
        $scope.formattedDate = moment($scope.date).format('YYYY-MM-DD');
      return moment($scope.formattedDate).fromNow();
    }
  }])<commit_msg>changes<commit_after>/**
* @Author: <NAME> <ikismail7>
* @Author: Saleemah <Saleemahmh>
* @Date:   2017-08-30T16:05:45+05:30
 * @Last modified by:   <NAME>
 * @Last modified time: 2017-09-06T16:21:15+05:30
*/
app.controller('newsController', ['$scope','appService',function(
  $scope,appService) {

    $scope.category;
    $scope.sourceData = [];
    $scope.image ;
    var topStoriesSource = ['bbc-news', 'cnbc','cnn','daily-mail',
    'engadget', 'mtv-news', 'espn-cric-info', 'time',
    'techradar', 'google-news', 'the-times-of-india'];

    var latestSource=['al-jazeera-english','breitbart-news', 'business-insider', 'business-insider-uk', 'buzzfeed',
    'daily-mail', 'engadget', 'espn-cric-info', 'fox-sports', 'ign',
    'metro', 'mirror', 'mtv-news', 'newsweek', 'new-york-magazine','reuters', 'techcrunch', 'techradar',
    'the-hindu', 'the-next-web', 'the-telegraph', 'the-times-of-india'];
    $scope.topStories = [];
    $scope.latest=[];

    $scope.getNewsBySource = function(category){
      $scope.category = category;
      appService.getNewsBySource(category).then(function(data){
        $scope.sourceData = data;
      },function(error){
        // $.toaster({ priority : 'error', title : 'Error', message : 'error while fetching resources'});
      })
    };
    $scope.getTopStories = function(){
      $scope.topStories = [];
      console.log('topStories');
      for (var i = 0; i < topStoriesSource.length; i++) {
        appService.getStories(topStoriesSource[i], 'top').then(function(data){
          $scope.topStories.push(data);
          console.log($scope.topStories);
        },function(error){
          // $.toaster({ priority : 'error', title : 'Error', message : 'error while fetching resources'});
        })
      }
    };
    $scope.getLatest = function(){
      $scope.latest = [];
      console.log('Latest');
      for (var i = 0; i < latestSource.length; i++) {
        appService.getStories(latestSource[i], 'latest').then(function(data){
          $scope.latest.push(data);
          console.log($scope.latest);
        },function(error){
          // $.toaster({ priority : 'error', title : 'Error', message : 'error while fetching resources'});
        })
      }
    };
    $scope.getAllSources = function(){
      appService.getAllSources().then(function(data){
        $scope.sources = data;
      },function(errorResponse){
        // $.toaster({ priority : 'error', title : 'Error', message : 'error while fetching resources'});
      })
    }

    $scope.getStories = function(source,sortBy){
      appService.getStories(source,sortBy).then(function(data){
        $scope.sourceData = data;
      },function(errorResponse){
        // $.toaster({ priority : 'error', title : 'Error', message : 'error while fetching resources'});
      })
    }

    $scope.getAllSources();

//Pagination
    //show more functionality

    var pagesShown = 1;

    var pageSize = 1;
//categorySize denotes number of category shown
var categorySize =5;
    $scope.paginationLimit = function() {
      return pageSize * pagesShown;
    };
    $scope.paginationCategoryLimit = function() {
      return categorySize * pagesShown;
    };
    $scope.hasMoreLatestToShow = function() {
      return pagesShown < ($scope.latest.length / pageSize);
    };
    $scope.hasMoreStoriesToShow = function() {
      return pagesShown < ($scope.topStories.length / pageSize);
    };
    $scope.hasMoreCategoryToShow = function() {
      return pagesShown < ($scope.sourceData.length / categorySize);
    };
    $scope.showMoreItems = function() {
      pagesShown = pagesShown + 1;
    };

  }])
{'fraction_non_alphanumeric': 0.17339954368541136, 'fraction_numerical': 0.011542074889276607, 'mean_word_length': 3.0832876712328767, 'pattern_counts': {'":': 0, '<': 21, '<?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': '5252824', 'n_tokens_mistral': 2446, 'n_tokens_neox': 2374, 'n_words': 430}