diff --git a/misc_test.go b/misc_test.go index 456dff07..2ae5947c 100644 --- a/misc_test.go +++ b/misc_test.go @@ -2315,8 +2315,9 @@ func TestForumActions(t *testing.T) { count = s.CountInForum(fid) exf(count == 0, "count in %d should be %d not %d", fid, 0, count) exf(!s.Exists(faid), "faid %d should not exist", faid) - _, e = s.Get(faid) + _, e := s.Get(faid) recordMustNotExist(t, e, "faid "+sfaid+" should not exist") + //exf(fa == nil, "fa should be nil not %+v", fa) fas, e := s.GetInForum(fid) //recordMustNotExist(t, e, "fid "+sfid+" should not have any actions") expectNilErr(t, e) // TODO: Why does this not return ErrNoRows? @@ -2366,6 +2367,7 @@ func TestForumActions(t *testing.T) { expectNilErr(t, e) topic, e := c.Topics.Get(tid) expectNilErr(t, e) + ex(!topic.IsClosed, "topic.IsClosed should be false") dayAgo := time.Now().AddDate(0, 0, -5) expectNilErr(t, topic.TestSetCreatedAt(dayAgo)) expectNilErr(t, fa.Run()) @@ -2375,6 +2377,16 @@ func TestForumActions(t *testing.T) { /*_, e = c.Rstore.Create(topic, "Forum Action Reply", "", 1) expectNilErr(t, e)*/ + tid, e = c.Topics.Create(fid, "Forum Action Topic 2", "Forum Action Topic 2", 1, "") + expectNilErr(t, e) + topic, e = c.Topics.Get(tid) + expectNilErr(t, e) + ex(!topic.IsClosed, "topic.IsClosed should be false") + expectNilErr(t, fa.Run()) + topic, e = c.Topics.Get(tid) + expectNilErr(t, e) + ex(!topic.IsClosed, "topic.IsClosed should be false") + _ = tid expectNilErr(t, s.Delete(faid)) diff --git a/tickloop.go b/tickloop.go index 3857b560..35e6ac27 100644 --- a/tickloop.go +++ b/tickloop.go @@ -249,24 +249,29 @@ func dailies() { } } - err := router.DailyTick() - if err != nil { - c.LogError(err) + e := router.DailyTick() + if e != nil { + c.LogError(e) + } + e = c.ForumActionStore.DailyTick() + if e != nil { + c.LogError(e) } { - err := c.Meta.Set("lastDaily", strconv.FormatInt(time.Now().Unix(), 10)) - if err != nil { - c.LogError(err) + e := c.Meta.Set("lastDaily", strconv.FormatInt(time.Now().Unix(), 10)) + if e != nil { + c.LogError(e) } } } func sched() error { + ws := errors.WithStack schedStr, err := c.Meta.Get("sched") // TODO: Report this error back correctly... if err != nil && err != sql.ErrNoRows { - return errors.WithStack(err) + return ws(err) } if schedStr == "recalc" { @@ -274,37 +279,37 @@ func sched() error { count, err := c.Recalc.Replies() if err != nil { - return errors.WithStack(err) + return ws(err) } log.Printf("Deleted %d orphaned replies.", count) count, err = c.Recalc.Forums() if err != nil { - return errors.WithStack(err) + return ws(err) } log.Printf("Recalculated %d forum topic counts.", count) count, err = c.Recalc.Subscriptions() if err != nil { - return errors.WithStack(err) + return ws(err) } log.Printf("Deleted %d orphaned subscriptions.", count) count, err = c.Recalc.ActivityStream() if err != nil { - return errors.WithStack(err) + return ws(err) } log.Printf("Deleted %d orphaned activity stream items.", count) err = c.Recalc.Users() if err != nil { - return errors.WithStack(err) + return ws(err) } log.Print("Recalculated user post stats.") count, err = c.Recalc.Attachments() if err != nil { - return errors.WithStack(err) + return ws(err) } log.Printf("Deleted %d orphaned attachments.", count) }