<commit_before>_ = require 'underscore'
request = require './request-cache'

class Craigslist

  constructor: (config) ->
    @request = new request.Request config

  ###
  # 60 second max age is good here, Coinbase exchange doesn't 
  # update any more freqently than that.
  # We could optimize this further by having a periodic job that performs 
  # 1 query/min, which would mean all user requests hit the cache.
  # Currently 1 user request every 60 seconds will have to wait for 
  # coinbase to return the result.
  ###
  search: (location, type, q, cb) ->
    _url = _fmt_craigslist_url location, type, q

    @request.get_cache_first _url, (data) ->
      #console.log data
      cb data?.data?.query?.results?.RDF?.item?.map _format


_fmt_craigslist_url = (loc,type,q) ->
  "http://query.yahooapis.com/v1/public/yql?\
   q=select%20*%20from%0Acraigslist.search%20where%20\
   location%3D%22#{escape(loc)}%22%20and%20\
   type%3D%22#{escape(type)}%22%20and%20\<commit_msg>null check on final object in tree<commit_after>_ = require 'underscore'
request = require './request-cache'

class Craigslist

  constructor: (config) ->
    @request = new request.Request config

  ###
  # 60 second max age is good here, Coinbase exchange doesn't 
  # update any more freqently than that.
  # We could optimize this further by having a periodic job that performs 
  # 1 query/min, which would mean all user requests hit the cache.
  # Currently 1 user request every 60 seconds will have to wait for 
  # coinbase to return the result.
  ###
  search: (location, type, q, cb) ->
    _url = _fmt_craigslist_url location, type, q

    @request.get_cache_first _url, (data) ->
      #console.log data
      cb data?.data?.query?.results?.RDF?.item?.map? _format


_fmt_craigslist_url = (loc,type,q) ->
  "http://query.yahooapis.com/v1/public/yql?\
   q=select%20*%20from%0Acraigslist.search%20where%20\
   location%3D%22#{escape(loc)}%22%20and%20\
   type%3D%22#{escape(type)}%22%20and%20\
{'fraction_non_alphanumeric': 0.12134944612286001, 'fraction_numerical': 0.03423967774420947, 'mean_word_length': 3.7422434367541766, 'pattern_counts': {'":': 0, '<': 3, '<?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': '880919', 'n_tokens_mistral': 716, 'n_tokens_neox': 660, 'n_words': 193}