Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/cljobs/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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))))
9 changes: 6 additions & 3 deletions src/cljobs/mailer.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)]]}
Expand All @@ -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]
Expand Down
10 changes: 6 additions & 4 deletions src/cljobs/pg.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down