|
a/ForgeDiscussion/forgediscussion/tasks.py |
|
b/ForgeDiscussion/forgediscussion/tasks.py |
1 |
import logging
|
1 |
import logging
|
2 |
|
2 |
|
3 |
from pylons import c
|
3 |
from pylons import c
|
4 |
|
4 |
from allura.lib.decorators import task
|
5 |
from forgediscussion import model as DM
|
|
|
6 |
|
5 |
|
7 |
log = logging.getLogger(__name__)
|
6 |
log = logging.getLogger(__name__)
|
8 |
|
7 |
|
|
|
8 |
@task
|
9 |
def calc_forum_stats(shortname):
|
9 |
def calc_forum_stats(shortname):
|
|
|
10 |
from forgediscussion import model as DM
|
10 |
forum = DM.Forum.query.get(
|
11 |
forum = DM.Forum.query.get(
|
11 |
shortname=shortname, app_config_id=c.app.config._id)
|
12 |
shortname=shortname, app_config_id=c.app.config._id)
|
12 |
if forum is None:
|
13 |
if forum is None:
|
13 |
log.error("Error looking up forum: %r", shortname)
|
14 |
log.error("Error looking up forum: %r", shortname)
|
14 |
return
|
15 |
return
|
15 |
forum.update_stats()
|
16 |
forum.update_stats()
|
16 |
|
17 |
|
|
|
18 |
@task
|
17 |
def calc_thread_stats(thread_id):
|
19 |
def calc_thread_stats(thread_id):
|
|
|
20 |
from forgediscussion import model as DM
|
18 |
thread = DM.ForumThread.query.get(_id=thread_id)
|
21 |
thread = DM.ForumThread.query.get(_id=thread_id)
|
19 |
if thread is None:
|
22 |
if thread is None:
|
20 |
log.error("Error looking up thread: %r", thread_id)
|
23 |
log.error("Error looking up thread: %r", thread_id)
|
21 |
thread.update_stats()
|
24 |
thread.update_stats()
|