<commit_before>var Events = require('../models/Events')

module.exports = {
  /**
   * GET /events
   * List of Event examples.
   */
  getEvents: function (req, res) {
  var meetupid = "www.meetup.com/Code-for-San-Francisco-Civic-Hack-Night/".split(".com/")[1].replace(/\//g, "") //need to replace with schema call
  var url = 'https://api.meetup.com/2/events?&sign=true&photo-host=public&group_urlname=' + meetupid + '&page=50'
  var aggregate = []
  Events.fetchMeetupEvents(url).then(function(result){
    result['events'].forEach(function(item){
      var event = {
        title: item.name,
        start: new Date(item.time+item.utc_offset),
        venue: item.venue.name,
        address: item.venue.address_1,
        city: item.venue.city,
        url_page: item.event_url
      }
      aggregate.push(event)
    })
    if(result['error']){
      req.flash('errors', {msg: result['error']})
    }
    res.render(res.locals.brigade.theme.slug + '/views/events/index', {
      events: aggregate,
      upcomingevents: aggregate.slice(0,10),
      title: 'Events',
      brigade: res.locals.brigade
    })
  })

  },
  /**
   * GET /events/manage
   * Manage Events.
   */
  getEventsManage: function (req, res) {
    res.render(res.locals.brigade.theme.slug + '/views/events/manage', {
      title: 'Manage Events',
      brigade: res.locals.brigade
    })
  },
  /**
   * POST /events/manage<commit_msg>fix event start time display on events index page.<commit_after>var Events = require('../models/Events')

module.exports = {
  /**
   * GET /events
   * List of Event examples.
   */
  getEvents: function (req, res) {
  var meetupid = "www.meetup.com/Code-for-San-Francisco-Civic-Hack-Night/".split(".com/")[1].replace(/\//g, "") //need to replace with schema call
  var url = 'https://api.meetup.com/2/events?&sign=true&photo-host=public&group_urlname=' + meetupid + '&page=50'
  var aggregate = []
  Events.fetchMeetupEvents(url).then(function(result){
    result['events'].forEach(function(item){
      var event = {
        title: item.name,
        start: new Date(item.time).toLocaleString(),
        venue: item.venue.name,
        address: item.venue.address_1,
        city: item.venue.city,
        url_page: item.event_url
      }
      aggregate.push(event)
    })
    if(result['error']){
      req.flash('errors', {msg: result['error']})
    }
    res.render(res.locals.brigade.theme.slug + '/views/events/index', {
      events: aggregate,
      upcomingevents: aggregate.slice(0,10),
      title: 'Events',
      brigade: res.locals.brigade
    })
  })

  },
  /**
   * GET /events/manage
   * Manage Events.
   */
  getEventsManage: function (req, res) {
    res.render(res.locals.brigade.theme.slug + '/views/events/manage', {
      title: 'Manage Events',
      brigade: res.locals.brigade
    })
  },
  /**
   * POST /events/manage
{'fraction_non_alphanumeric': 0.16899441340782123, 'fraction_numerical': 0.00558659217877095, 'mean_word_length': 2.711139896373057, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '1266240', 'n_tokens_mistral': 1000, 'n_tokens_neox': 985, 'n_words': 165}