<commit_before>#/api/v1/needs.json
angular.module("iamin")
  .service "ApiCalendar", ($http) ->
    class ApiCalendar
      needs: -> $http.get("/api/v1/needs.json").then (res) =>
        @_parse_needs res.data.data

      addNeed: (need) ->
        niceNeed = {}
        niceNeed.attributes = {
          'start-time': need.start
          'end-time': need.end
        }
        niceNeed.type = "needs"
        # need['start-time'] = need.start
        # need['end-time'] = need.end#.format()
        $http({
          url: "/api/v1/needs.json",
          dataType: "json",
          method: "POST",
          headers: {
              "Content-Type": "application/vnd.api+json"
          }
          data: {'data': niceNeed}
        })

      updateNeed: (need) ->
        niceNeed =
          id: need.id
        niceNeed.attributes = {
          'start-time': need.start
          'end-time': need.end
        }
        niceNeed.type = "needs"
        # need['start-time'] = need.start
        # need['end-time'] = need.end#.format()
        $http({
          url: "/api/v1/needs/" + niceNeed.id + '.json'
          dataType: "json",
          method: "PUT",
          headers: {
              "Content-Type": "application/vnd.api+json"
          }
          data: {'data': niceNeed}
        })

      deleteNeed: (need) ->
        # niceNeed =
        #   id: need.id
        # niceNeed.attributes = {
        #   'start-time': need.start
        #   'end-time': need.end
        # }
        # niceNeed.type = "needs"
        # need['start-time'] = need.start
        # need['end-time'] = need.end#.format()
        $http({
          url: "/api/v1/needs/" + need.id + '.json'
          dataType: "json",
          method: "DELETE",
          headers: {
              "Content-Type": "application/vnd.api+json"
          }
          data: {'data': niceNeed}
        })

      _parse_needs:  (rawNeeds) ->
        (@_parse_need rawNeed for rawNeed in rawNeeds)

      # _toCalendarTime: (serverTime, serverDay) ->
      #   # for some reason, scheduleConfig is not imported, so break DRY for now
      #   serverTime = moment.utc serverTime
      #   defaultDate = moment.utc '1999-12-27'
      #   # mutable, so make a copy (for when we use a const)
      #   t = defaultDate.clone()
      #   # shift to the right moment relative to our defaultDate
      #   t.add serverDay - 1, 'd'
      #   t.add serverTime.hours(), 'h'
      #   t.add serverTime.minutes(), 'm'
      #   t

      _parse_need: (rawNeed) ->
        need =
          'id': rawNeed['id']
          category: rawNeed.attributes.category
          city: rawNeed.attributes.city
          start: moment.utc rawNeed.attributes['start-time']
          end: moment.utc rawNeed.attributes['end-time']
          location: rawNeed.attributes.location
          volunteersNeeded: rawNeed.attributes['volunteers-needed']

        #need.title = need.start.format("H:mm") + " – " + need.end.format("H:mm")
        need.title = "#{need.volunteersNeeded} #{need.category} volunteers at #{need.location}, #{need.city}"<commit_msg>don't print calendar event location if null<commit_after>#/api/v1/needs.json
angular.module("iamin")
  .service "ApiCalendar", ($http) ->
    class ApiCalendar
      needs: -> $http.get("/api/v1/needs.json").then (res) =>
        @_parse_needs res.data.data

      addNeed: (need) ->
        niceNeed = {}
        niceNeed.attributes = {
          'start-time': need.start
          'end-time': need.end
        }
        niceNeed.type = "needs"
        # need['start-time'] = need.start
        # need['end-time'] = need.end#.format()
        $http({
          url: "/api/v1/needs.json",
          dataType: "json",
          method: "POST",
          headers: {
              "Content-Type": "application/vnd.api+json"
          }
          data: {'data': niceNeed}
        })

      updateNeed: (need) ->
        niceNeed =
          id: need.id
        niceNeed.attributes = {
          'start-time': need.start
          'end-time': need.end
        }
        niceNeed.type = "needs"
        # need['start-time'] = need.start
        # need['end-time'] = need.end#.format()
        $http({
          url: "/api/v1/needs/" + niceNeed.id + '.json'
          dataType: "json",
          method: "PUT",
          headers: {
              "Content-Type": "application/vnd.api+json"
          }
          data: {'data': niceNeed}
        })

      deleteNeed: (need) ->
        # niceNeed =
        #   id: need.id
        # niceNeed.attributes = {
        #   'start-time': need.start
        #   'end-time': need.end
        # }
        # niceNeed.type = "needs"
        # need['start-time'] = need.start
        # need['end-time'] = need.end#.format()
        $http({
          url: "/api/v1/needs/" + need.id + '.json'
          dataType: "json",
          method: "DELETE",
          headers: {
              "Content-Type": "application/vnd.api+json"
          }
          data: {'data': niceNeed}
        })

      _parse_needs:  (rawNeeds) ->
        (@_parse_need rawNeed for rawNeed in rawNeeds)

      # _toCalendarTime: (serverTime, serverDay) ->
      #   # for some reason, scheduleConfig is not imported, so break DRY for now
      #   serverTime = moment.utc serverTime
      #   defaultDate = moment.utc '1999-12-27'
      #   # mutable, so make a copy (for when we use a const)
      #   t = defaultDate.clone()
      #   # shift to the right moment relative to our defaultDate
      #   t.add serverDay - 1, 'd'
      #   t.add serverTime.hours(), 'h'
      #   t.add serverTime.minutes(), 'm'
      #   t

      _parse_need: (rawNeed) ->
        need =
          'id': rawNeed['id']
          category: rawNeed.attributes.category
          city: rawNeed.attributes.city
          start: moment.utc rawNeed.attributes['start-time']
          end: moment.utc rawNeed.attributes['end-time']
          location: rawNeed.attributes.location
          volunteersNeeded: rawNeed.attributes['volunteers-needed']

        #need.title = need.start.format("H:mm") + " – " + need.end.format("H:mm")
        need.title = "#{need.volunteersNeeded} #{need.category}"
        if need.volunteersNeeded == 1
          need.title += " volunteer"
        else
          need.title += " volunteers"
        if need.location
          need.title += " at #{need.location}, #{need.city}."
        else
          need.title += ". (no location)"
{'fraction_non_alphanumeric': 0.14988326848249028, 'fraction_numerical': 0.004513618677042802, 'mean_word_length': 1.709106239460371, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 21, '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': '4740704', 'n_tokens_mistral': 2032, 'n_tokens_neox': 1977, 'n_words': 405}