enable forum actions
add more forum action test cases shorten variable names
This commit is contained in:
parent
347308387f
commit
cbee05fd3e
14
misc_test.go
14
misc_test.go
|
@ -2315,8 +2315,9 @@ func TestForumActions(t *testing.T) {
|
||||||
count = s.CountInForum(fid)
|
count = s.CountInForum(fid)
|
||||||
exf(count == 0, "count in %d should be %d not %d", fid, 0, count)
|
exf(count == 0, "count in %d should be %d not %d", fid, 0, count)
|
||||||
exf(!s.Exists(faid), "faid %d should not exist", faid)
|
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")
|
recordMustNotExist(t, e, "faid "+sfaid+" should not exist")
|
||||||
|
//exf(fa == nil, "fa should be nil not %+v", fa)
|
||||||
fas, e := s.GetInForum(fid)
|
fas, e := s.GetInForum(fid)
|
||||||
//recordMustNotExist(t, e, "fid "+sfid+" should not have any actions")
|
//recordMustNotExist(t, e, "fid "+sfid+" should not have any actions")
|
||||||
expectNilErr(t, e) // TODO: Why does this not return ErrNoRows?
|
expectNilErr(t, e) // TODO: Why does this not return ErrNoRows?
|
||||||
|
@ -2366,6 +2367,7 @@ func TestForumActions(t *testing.T) {
|
||||||
expectNilErr(t, e)
|
expectNilErr(t, e)
|
||||||
topic, e := c.Topics.Get(tid)
|
topic, e := c.Topics.Get(tid)
|
||||||
expectNilErr(t, e)
|
expectNilErr(t, e)
|
||||||
|
ex(!topic.IsClosed, "topic.IsClosed should be false")
|
||||||
dayAgo := time.Now().AddDate(0, 0, -5)
|
dayAgo := time.Now().AddDate(0, 0, -5)
|
||||||
expectNilErr(t, topic.TestSetCreatedAt(dayAgo))
|
expectNilErr(t, topic.TestSetCreatedAt(dayAgo))
|
||||||
expectNilErr(t, fa.Run())
|
expectNilErr(t, fa.Run())
|
||||||
|
@ -2375,6 +2377,16 @@ func TestForumActions(t *testing.T) {
|
||||||
/*_, e = c.Rstore.Create(topic, "Forum Action Reply", "", 1)
|
/*_, e = c.Rstore.Create(topic, "Forum Action Reply", "", 1)
|
||||||
expectNilErr(t, e)*/
|
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
|
_ = tid
|
||||||
|
|
||||||
expectNilErr(t, s.Delete(faid))
|
expectNilErr(t, s.Delete(faid))
|
||||||
|
|
31
tickloop.go
31
tickloop.go
|
@ -249,24 +249,29 @@ func dailies() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err := router.DailyTick()
|
e := router.DailyTick()
|
||||||
if err != nil {
|
if e != nil {
|
||||||
c.LogError(err)
|
c.LogError(e)
|
||||||
|
}
|
||||||
|
e = c.ForumActionStore.DailyTick()
|
||||||
|
if e != nil {
|
||||||
|
c.LogError(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
err := c.Meta.Set("lastDaily", strconv.FormatInt(time.Now().Unix(), 10))
|
e := c.Meta.Set("lastDaily", strconv.FormatInt(time.Now().Unix(), 10))
|
||||||
if err != nil {
|
if e != nil {
|
||||||
c.LogError(err)
|
c.LogError(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func sched() error {
|
func sched() error {
|
||||||
|
ws := errors.WithStack
|
||||||
schedStr, err := c.Meta.Get("sched")
|
schedStr, err := c.Meta.Get("sched")
|
||||||
// TODO: Report this error back correctly...
|
// TODO: Report this error back correctly...
|
||||||
if err != nil && err != sql.ErrNoRows {
|
if err != nil && err != sql.ErrNoRows {
|
||||||
return errors.WithStack(err)
|
return ws(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if schedStr == "recalc" {
|
if schedStr == "recalc" {
|
||||||
|
@ -274,37 +279,37 @@ func sched() error {
|
||||||
|
|
||||||
count, err := c.Recalc.Replies()
|
count, err := c.Recalc.Replies()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithStack(err)
|
return ws(err)
|
||||||
}
|
}
|
||||||
log.Printf("Deleted %d orphaned replies.", count)
|
log.Printf("Deleted %d orphaned replies.", count)
|
||||||
|
|
||||||
count, err = c.Recalc.Forums()
|
count, err = c.Recalc.Forums()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithStack(err)
|
return ws(err)
|
||||||
}
|
}
|
||||||
log.Printf("Recalculated %d forum topic counts.", count)
|
log.Printf("Recalculated %d forum topic counts.", count)
|
||||||
|
|
||||||
count, err = c.Recalc.Subscriptions()
|
count, err = c.Recalc.Subscriptions()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithStack(err)
|
return ws(err)
|
||||||
}
|
}
|
||||||
log.Printf("Deleted %d orphaned subscriptions.", count)
|
log.Printf("Deleted %d orphaned subscriptions.", count)
|
||||||
|
|
||||||
count, err = c.Recalc.ActivityStream()
|
count, err = c.Recalc.ActivityStream()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithStack(err)
|
return ws(err)
|
||||||
}
|
}
|
||||||
log.Printf("Deleted %d orphaned activity stream items.", count)
|
log.Printf("Deleted %d orphaned activity stream items.", count)
|
||||||
|
|
||||||
err = c.Recalc.Users()
|
err = c.Recalc.Users()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithStack(err)
|
return ws(err)
|
||||||
}
|
}
|
||||||
log.Print("Recalculated user post stats.")
|
log.Print("Recalculated user post stats.")
|
||||||
|
|
||||||
count, err = c.Recalc.Attachments()
|
count, err = c.Recalc.Attachments()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithStack(err)
|
return ws(err)
|
||||||
}
|
}
|
||||||
log.Printf("Deleted %d orphaned attachments.", count)
|
log.Printf("Deleted %d orphaned attachments.", count)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue