def one_topic_clear(topicname_start): topicname, start_datetime = topicname_start em = EventManager() topicid = em.getEventIDByName(topicname) start_ts = datetime2ts(start_datetime) event = Event(topicid) event.initialize(start_ts)
def record(cls, user, action, *args): c = cls() c.created = datetime.utcnow() c.timestamp = datetime2ts(c.created) c.user_id = user.id c.revision = cls.query.filter_by(user_id=user.id).count() c.data = json.dumps([action] + list(args), ensure_ascii=False) _data = str(c.revision) + str(c.timestamp) + c.data _data = _data.encode() state.db.session.add(c) state.db.session.commit()
def initializeNewsTopic(): """初始化新闻话题 """ em = EventManager() topicname = u'外滩踩踏' start_datetime = "2015-01-02 00:00:00" topicid = em.getEventIDByName(topicname) start_ts = datetime2ts(start_datetime) event = Event(topicid) event.initialize(start_ts)
def initializeWeiboTopic(): """初始化weibo话题 """ em = EventManager() # topicname = u'外滩踩踏-微博' # start_datetime = "2015-01-02 00:00:00" # topicname = u'呼格案-微博' # start_datetime = "2014-12-14 00:00:00" # topicname = u'复旦投毒案-微博' # start_datetime = "2014-12-15 00:00:00" topicname = u'APEC-微博' start_datetime = "2014-12-15 00:00:00" topicid = em.getEventIDByName(topicname) start_ts = datetime2ts(start_datetime) event = Event(topicid) event.initialize(start_ts)
#-*-coding=utf-8-*- from utils import datetime2ts MONGO_DB_NAME = "news" EVENTS_COLLECTION = "news_topic" SUB_EVENTS_COLLECTION = "news_subevent" SUB_EVENTS_FEATURE_COLLECTION = "news_subevent_feature" EVENTS_NEWS_COLLECTION_PREFIX = "post_" EVENTS_COMMENTS_COLLECTION_PREFIX = "comment_" START_DATETIME = "2014-01-01 00:00:00" END_DATETIME = "2014-11-04 00:00:00" START_TS = datetime2ts(START_DATETIME) END_TS = datetime2ts(END_DATETIME)
def json(self): timestamp = self.timestamp or datetime2ts(self.created) return [self.revision, timestamp, self.data]
def timestamp(self): return utils.datetime2ts(self.modified)