Update README.md, Add comments

This commit is contained in:
Daniel Mason 2021-09-02 11:08:26 +12:00
parent a884ed7f46
commit c79f5e7e7e
Signed by: idanoo
GPG key ID: 387387CDBC02F132
3 changed files with 10 additions and 0 deletions

View file

@ -1,6 +1,10 @@
# NZCovidBot
Pull data from Github and parse new locations and fire them off to any configured endpoints
### About
After the twitterbot @nzcovidlocs shut down, I decided to try a different approach, instead of scraping MoH's website, lets parse the raw data!
https://github.com/minhealthnz/nz-covid-data/tree/main/locations-of-interest/august-2021
## Config
Copy .env.example to .env and fill in the blanks.

View file

@ -20,6 +20,7 @@ var commitHash string
// Location to store tmp data
var tmpDirectory = "./tmp"
// loadRepo Load repo into gitRepo var
func loadRepo(repository string) {
r, err := git.PlainOpen(tmpDirectory + "/repo")
if err != nil {
@ -35,6 +36,7 @@ func loadRepo(repository string) {
gitRepo = r
}
// cloneRepo Clone git repo
func cloneRepo(repository string) *git.Repository {
if _, err := os.Stat(tmpDirectory); os.IsNotExist(err) {
err = os.Mkdir(tmpDirectory, 0755)
@ -160,6 +162,9 @@ func checkForUpdates() {
}
}
// Store current hash for future comparisons
setCommitHash(head.Hash().String())
// SEND IT o/---->
postTheUpdates()
}

View file

@ -34,6 +34,7 @@ func Lesgoooo() {
}
func postTheUpdates() {
// Lets reshuffle our structured data a bit (Exposure Date ASC)
orderRowDataByDate()
// Twitter