Parent: [b85e86] (diff)

Child: [bea16d] (diff)

Download this file

tasks.py    25 lines (20 with data), 656 Bytes

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