Last active
March 21, 2018 22:00
-
-
Save jordanrobinson/d5383dde0b9c1be1fd0f9ac409965eb3 to your computer and use it in GitHub Desktop.
Some clj files for the blog post
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ((if (= updated (read-updated-date user)) | |
| (log-output user) | |
| (write-update user schedule)) | |
| (defn read-updated-date | |
| "reads in the last updated details from the filesystem for comparison" | |
| [user] | |
| (if (.exists (io/as-file (str user ".clj"))) | |
| (let [updated-date (get (read-string (slurp (str user ".clj"))) :updated_at)] | |
| (get (clojure.string/split updated-date #":") 0)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defn hit-api | |
| "calls our api, parses it and returns the result" | |
| [endpoint username password] | |
| (parse-string | |
| (get | |
| (client/get (str endpoint) | |
| {:basic-auth [username password]}) | |
| :body) | |
| true)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defn send-slack-message | |
| "sends a slack message detailing the changes to that endpoint" | |
| [username body slackurl] | |
| (println (str "sending message to " username "...")) | |
| (client/post slackurl | |
| {:form-params {:payload (json/write-str {:text body :channel (str "@" username)})}})) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defn write-update | |
| "writes out the latest details to file for later checking" | |
| [user slackuser message] | |
| (spit (str user ".clj") (prn-str data)) | |
| (println (str "updated user " user " at " (now))) | |
| (send-slack-message slackuser message)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment