'Returns an estimate of the number of messages sent in the last day.
If it has been significantly less or more than one day since the last
call to this function, it will return None.'

@defer.inlineCallbacks
def count_daily_messages(self):

    def _count_messages(txn):
        sql = "\n                                                                SELECT    COALESCE(COUNT(*),    0)    FROM    events\n                                                                WHERE    type    =    'm.room.message'\n                                                                AND    stream_ordering    >    ?\n                                                "
        txn.execute(sql, (self.stream_ordering_day_ago,))
        (count,) = txn.fetchone()
        return count
    ret = (yield self.runInteraction('count_messages', _count_messages))
    defer.returnValue(ret)
