Skip to content

Instantly share code, notes, and snippets.

@ossareh
Created December 12, 2010 21:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ossareh/738352 to your computer and use it in GitHub Desktop.
Save ossareh/738352 to your computer and use it in GitHub Desktop.
without the issues
(ns company-count
(:require [work.core :as work])
(:use [clojure.contrib.json])
(:use [clojure.contrib.io :only (read-lines)]))
(defonce companies (read-json (slurp "http://api.crunchbase.com/v/1/companies.js")))
(def emp-ranges (agent {}))
(defn which-range [n]
(cond (nil? n) :unknown
(< n 15) :under15
(< n 50) :15to49
(< n 100) :50to99
(< n 501) :100to500
:else :over500))
(defn api-url [company]
(str "http://api.crunchbase.com/v/1/company/" (:permalink company) ".js"))
(defn update-emp-range! [name emp-cnt]
(send emp-ranges
(fn [m k] (let [v (get m k {})
v (assoc v name emp-cnt)]
(println (str "handled " name))
(assoc m k v)))
(which-range emp-cnt)))
(defn process-company [co]
(let [res (slurp (api-url co))
data (read-json res)
emps (:number_of_employees data)
name (String. ^String (:name co))]
(update-emp-range! name emps))
nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment