Logging + skipping blank accounts

This commit is contained in:
farhan 2020-11-01 01:30:20 -05:00
parent 79a27dbc4b
commit 3ae62454db

View File

@ -212,6 +212,11 @@ func StartInstancePoll(instancereport InstanceReport, reportPostChan chan Report
min_id := "" min_id := ""
numposts := 0 numposts := 0
for _, newpost := range newposts { for _, newpost := range newposts {
if newpost.Account.Acct == "" {
continue
}
posthash := sha1.New() posthash := sha1.New()
at_sign := strings.Index(newpost.Account.Acct, "@") at_sign := strings.Index(newpost.Account.Acct, "@")
@ -257,9 +262,9 @@ func StartInstancePoll(instancereport InstanceReport, reportPostChan chan Report
func DeferPollRun(instancereport InstanceReport, runninginstances *[]RunningInstance, instanceReportChan chan InstanceReport, reportPostChan chan ReportPost) { func DeferPollRun(instancereport InstanceReport, runninginstances *[]RunningInstance, instanceReportChan chan InstanceReport, reportPostChan chan ReportPost) {
delay := 10 delay := 10
if instancereport.status == 200 && instancereport.numposts <= 10 { if instancereport.status == RUNNING && instancereport.numposts <= 10 {
delay = 10 delay = 10
} else if instancereport.status == 200 && instancereport.numposts > 10 { } else if instancereport.status == RUNNING && instancereport.numposts > 10 {
delay = 15 delay = 15
} else if instancereport.status == 429 { } else if instancereport.status == 429 {
delay = 30 delay = 30
@ -331,7 +336,7 @@ func NewInstance(endpoint string, runninginstances *[]RunningInstance, instanceR
func writePost(pool *pgxpool.Pool, reportpost ReportPost) { func writePost(pool *pgxpool.Pool, reportpost ReportPost) {
conn, err := pool.Acquire(context.Background()) conn, err := pool.Acquire(context.Background())
if err != nil { if err != nil {
fmt.Println("Error acquiring connection:", err) log.Fatal("Error connecting to database:", err)
os.Exit(1) os.Exit(1)
} }
defer conn.Release() defer conn.Release()
@ -352,7 +357,7 @@ func writePost(pool *pgxpool.Pool, reportpost ReportPost) {
fmt.Println("Account URL: ", reportpost.Account.Url) fmt.Println("Account URL: ", reportpost.Account.Url)
fmt.Println(reportpost) fmt.Println(reportpost)
fmt.Println("--------------------------") fmt.Println("--------------------------")
// os.Exit(1) // For now I want this to die and learn why it failed os.Exit(1) // For now I want this to die and learn why it failed
return return
} }
@ -369,7 +374,7 @@ func writePost(pool *pgxpool.Pool, reportpost ReportPost) {
fmt.Println("account_id", accountid) fmt.Println("account_id", accountid)
fmt.Println("posthash: ", reportpost.posthash) fmt.Println("posthash: ", reportpost.posthash)
fmt.Println("--------------------------") fmt.Println("--------------------------")
// os.Exit(1) // For now I want this to die and learn why it failed os.Exit(1) // For now I want this to die and learn why it failed
return return
} }
} }