Hi,
I have stories and a playlist history. I want to get some stats, ie
the number of time that a story was played during the day, the month
and the year.
MODEL.PY
class Story(SQLObject):
class sqlmeta:
idName = 'story_id'
title = UnicodeCol(length=100)
onair = SingleJoin('Onair', joinColumn="story_id")
history = MultipleJoin('Onairhist', joinColumn="story_id")
class Onairhist(SQLObject):
class sqlmeta:
idName = 'onairhist_id'
story = ForeignKey('Story')
created = DateTimeCol(default=datetime.now)
CONTROLLERS.PY
@expose(template="aarton.templates.stats")
def stats(self):
oneYearAgo = datetime.datetime.now() -
datetime.timedelta(days=365)
oneMonthAgo = datetime.datetime.now() -
datetime.timedelta(days=30)
oneDayAgo = datetime.datetime.now() -
datetime.timedelta(days=1)
history = []
stories = Story.select(Story.q.status ==4)
for story in stories:
history.append((story,
Onairhist.select(AND(Onairhist.q.created >= oneDayAgo, Story.q.id ==
story.id)).count()))
return dict(history = history)
The request:
Onairhist.select(AND(Onairhist.q.created >= oneDayAgo, Story.q.id ==
3)).count()
Is translated by:
SELECT onairhist.onairhist_id, onairhist.story_id, onairhist.created
FROM story, onairhist WHERE (((onairhist.created) >= ('2008-01-26
16:33:03')) AND ((story.story_id) = (3)))
So, it fails because the where statement is incomplete... it lacks:
"AND ((story.story_id) = (onairhist.story_id))"
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---