diff --git a/src/cljobs/core.clj b/src/cljobs/core.clj index 8e4f44e..21a2035 100644 --- a/src/cljobs/core.clj +++ b/src/cljobs/core.clj @@ -6,8 +6,8 @@ (defn -main [] - (println "Beginning program...") + (println "Beginning program...") ;; (prn ...) (pg/create-job-counts-table) - (let [jobs (scraper/master-scrape)] + (let [jobs (scraper/master-scrape)] (mailer/send-jobs-email jobs) (pg/write-count-to-db (flatten jobs)))) diff --git a/src/cljobs/mailer.clj b/src/cljobs/mailer.clj index 1c04c1c..80f743a 100644 --- a/src/cljobs/mailer.clj +++ b/src/cljobs/mailer.clj @@ -5,14 +5,16 @@ (def host-config {:host "smtp.gmail.com" - :user (:google-email env) + :user (:google-email env) ;; Great use of env here for creds :pass (:google-pw env) :ssl true}) (def msg-config {:from (:google-email env) :to (:recipient-email env) - :subject "Clojure Jobs"}) + :subject "Clojure Jobs"}) ;; Emails are actually consolidated based on subject, + ;; so would be good to add the date time to subject line here + ;; to add some sort of UUID (html/defsnippet listing-snippet "email-template.html" {[:h2] [[:div.post-body (html/nth-of-type 1)]]} @@ -25,7 +27,8 @@ (html/deftemplate email-template "email-template.html" [jobs] [:title] (html/content "Clojure Jobs") - [:body] (html/content (map listing-snippet jobs))) + [:body] (html/content (map listing-snippet jobs))) ;; Good clean use of formatting here, consider using string formatting though + ;; not all devs know html but all know strings (for interns) (defn build-jobs-email [jobs] diff --git a/src/cljobs/pg.clj b/src/cljobs/pg.clj index b8d4bfc..696331e 100644 --- a/src/cljobs/pg.clj +++ b/src/cljobs/pg.clj @@ -5,16 +5,18 @@ (def db-spec {:classname "org.postgresql.Driver" :subprotocol "postgresql" - :subname "//localhost:5432/cljobs"}) + :subname "//localhost:5432/cljobs"}) ;; Good to use env here too to adapt to the deployment + ;; ex. (or (env :database_url) "//localhost:5432/cljobs") (def tablename :job_counts) (defn uniq-count [jobs] (println "Tallying unique jobs...") - (let [dupes (->> (map #(select-keys % [:company :title]) jobs) - frequencies - (map second) + (let [dupes (->> (map #(select-keys % [:company :title]) jobs) ;; glad to see threading macro here, I used them often + frequencies ;; would be cleaner to write, so you know what your threading: + ;; (->> jobs + (map second) ;; (map #(select-keys % [:company :title])) ... (remove #{1}) (reduce +)) total (count jobs)]