Ejemplo n.º 1
0
def __topic_27(db, funding):
    """
    每日退出事件
    """

    global logger_track
    if funding.round and (funding.round == 1110 or funding.round == 1120):
        active = 'Y' if dbutil.get_topic_auto_pubilsh_status(
            db, 27) == 'Y' else 'P'
        # cid = dbutil.get_corporate_companies(db, funding.corporateId)[0]
        cid = funding.companyId
        if funding.round == 1120:
            msg = u'%s,%s被%s收购' % \
                  (dbutil.get_company_brief(db, cid), dbutil.get_company_name(db, cid), funding.investorsRaw)
        else:
            msg = u'%s,%s完成上市' % \
                  (dbutil.get_company_brief(db, cid), dbutil.get_company_name(db, cid))
        tpm = dbutil.update_topic_message(db, 27, msg, active, 70, funding.id)
        if tpm:
            send_msg(tpm, 'topic_message')
            # for cid in dbutil.get_corporate_companies(db, funding.corporateId):
            tpc = dbutil.update_topic_company(db, 27, cid, active)
            # if active == 'Y':
            if tpc:
                dbutil.update_topic_message_company(db, tpm, tpc)
            send_msg(tpc, 'topic_company')
        logger_track.info('27 for %s, add tpm %s' % (funding.id, tpm))
    else:
        logger_track.info('27 not for %s' % funding.id)
Ejemplo n.º 2
0
def fa_relevant_track():

    # topic52
    global logger_track
    db = dbcon.connect_torndb()
    day7 = datetime.now() - timedelta(days=7)
    for cid in dbutil.get_all_fund_raising(db):
        logger_track.info('Processing %s' % cid)
        brief = dbutil.get_company_brief(db, cid)
        msg = u'%s, %s开启了新一轮融资' % (brief, dbutil.get_company_name(db, cid))
        active = 'Y' if (dbutil.get_company_verify(db, cid) == 'Y'
                         and brief) else 'P'
        tpm = dbutil.update_topic_message_withoutdup(
            db,
            52,
            msg,
            active,
            80,
            dbutil.get_company_latest_fa(db, cid, day7),
            detail_id=cid)
        tpc = dbutil.update_topic_company(db, 52, cid, active)
        if tpm:
            dbutil.update_topic_message_company(db, tpm, tpc)
            send_msg(tpm, 'topic_message')
            send_msg(tpc, 'topic_company')
            logger_track.info('Updated %s' % cid)
    dbutil.update_last_message_time(db, 52)
Ejemplo n.º 3
0
def __topic_29(db, funding):
    """
    BAT又在这些领域出手了
    187, 217, 117
    """

    investors = set(dbutil.get_funding_investor_ids(
        db, funding.id)) & {187, 217, 117}
    if investors:
        active = 'Y' if dbutil.get_topic_auto_pubilsh_status(
            db, 29) == 'Y' else 'P'
        cid = funding.companyId
        investors = ','.join(
            [dbutil.get_investor_name(db, iid) for iid in investors])
        msg = u'%s投资了%s,%s' % \
              (investors, dbutil.get_company_brief(db, cid), dbutil.get_company_name(db, cid))
        tpm = dbutil.update_topic_message(db, 29, msg, active, 70, funding.id)
        # if active == 'Y':
        if tpm:
            send_msg(tpm, 'topic_message')
            tpc = dbutil.update_topic_company(db, 29, cid, active)
            if tpc:
                dbutil.update_topic_message_company(db, tpm, tpc)
            send_msg(tpc, 'topic_company')
        logger_track.info('29 for %s, add tpm %s' % (funding.id, tpm))
    else:
        logger_track.info('29 not for %s' % funding.id)
Ejemplo n.º 4
0
def __topic_28(db, funding):
    """
    红杉真格经纬IDG
    114, 122, 125, 109
    """

    investors = set(dbutil.get_funding_investor_ids(
        db, funding.id)) & {114, 122, 125, 109}
    if investors:
        active = 'Y' if dbutil.get_topic_auto_pubilsh_status(
            db, 28) == 'Y' else 'P'
        # cid = dbutil.get_corporate_companies(db, funding.corporateId)[0]
        cid = funding.companyId
        investors = ','.join(
            [dbutil.get_investor_name(db, iid) for iid in investors])
        msg = u'%s投资了%s,%s' % \
              (investors, dbutil.get_company_brief(db, cid), dbutil.get_company_name(db, cid))
        tpm = dbutil.update_topic_message(db, 28, msg, active, 70, funding.id)
        # if active == 'Y':
        if tpm:
            send_msg(tpm, 'topic_message')
            # for cid in dbutil.get_corporate_companies(db, funding.corporateId):
            tpc = dbutil.update_topic_company(db, 28, cid, active)
            # if active == 'Y':
            if tpc:
                dbutil.update_topic_message_company(db, tpm, tpc)
            send_msg(tpc, 'topic_company')
        logger_track.info('28 for %s, add tpm %s' % (funding.id, tpm))
    else:
        logger_track.info('28 not for %s' % funding.id)
Ejemplo n.º 5
0
def __compare(c, fo, db, e):

    old = db.query('select tag.name name from tag, company_tag_rel rel where tagId=tag.id and tag.type=11012 '
                   'and companyId=%s and (rel.active is null or rel.active="Y")', c.id)
    old = ','.join([v.name for v in old])
    e.extract(c.id)
    new = db.query('select tag.name name from tag, company_tag_rel rel where tagId=tag.id and tag.type=11012 '
                   'and companyId=%s and (rel.active is null or rel.active="Y")', c.id)
    new = ','.join([v.name for v in new])
    fo.write('%s\t%s\t%s\t%s\t%s\n' % (dbutil.get_company_code(db, c.id), dbutil.get_company_name(db, c.id),
                                       dbutil.get_company_brief(db, c.id), old, new))
Ejemplo n.º 6
0
Archivo: rank.py Proyecto: yujiye/Codes
def score():

    db = dbcon.connect_torndb()
    with codecs.open('dumps/rank', 'w', 'utf-8') as fo:
        for tag in [u'大数据', u'小程序', u'短视频', u'民宿', u'足球', u'咖啡']:
            cids = []
            tid = dbutil.get_tag_id(db, tag)[0]
            complete = db.query(
                'select rel.companyId cid from company_tag_rel rel, company_scores s '
                'where (rel.active="Y" or rel.active is null) and rel.companyId=s.companyId '
                'and s.type=37010 and tagId=%s order by score desc limit 100;',
                tid)
            cids.extend([c.cid for c in complete])
            yellows = db.query(
                'select companyId cid, count(*) c from company_tag_rel rel, tag '
                'where tag.id=tagId and tag.type=11100 and (tag.active is null or tag.active="Y") '
                'and (rel.active="Y" or rel.active is null) and companyId in '
                '(select distinct companyId from company_tag_rel where tagId=%s '
                'and (active is null or active="Y")) group by companyId order by c desc limit 100;',
                tid)
            cids.extend([c.cid for c in yellows])
            msgs = db.query(
                'select msg.companyId cid, count(*) c from company_message msg, company_tag_rel rel '
                'where msg.active="Y" and msg.companyId=rel.companyId and msg.publishTime>"2018-02-01" '
                'and rel.tagId=%s and (rel.active="Y" or rel.active is null) group by msg.companyId '
                'order by c desc limit 100;', tid)
            cids.extend([c.cid for c in msgs])
            cids = set(cids)
            for cid in cids:
                name = dbutil.get_company_name(db, cid)
                brief = dbutil.get_company_brief(db, cid)
                url = 'http://www.xiniudata.com/#/company/%s/overview' % dbutil.get_company_code(
                    db, cid)
                s1 = dbutil.get_company_score(db, cid, 37010)
                s1 = 1 if s1 >= 0.5 else s1
                s2 = (len(dbutil.get_company_tags_yellow(db, cid, False)) + 1 -
                      dbutil.get_company_yellow_time_deduction(db, cid)) / 9
                s3 = (log10(
                    len(dbutil.get_company_messages(db, cid, 'Y',
                                                    '2018-02-01')) + 1)) / 4
                s4 = db.get(
                    'select confidence from company_tag_rel where companyId=%s and tagId=%s;',
                    cid, tid).confidence
                fo.write('%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n' %
                         (tag, name, brief, url, s1, round(s2, 2), round(
                             s3, 2), round(s4, 2)))
Ejemplo n.º 7
0
    def update_all_onfunding(self):

        global producer_track
        for fa in dbutil.get_all_FA(self.db, self.yesterday):
            cid = fa.companyId
            if not cid:
                continue
            msg = u'%s, %s开启了新一轮融资' % \
                  (dbutil.get_company_brief(self.db, cid), dbutil.get_company_name(self.db, cid))
            feed_back = dbutil.update_company_message(self.db, cid, msg, 8001,
                                                      80, fa.id)
            if feed_back:
                self.send_company_message_msg(feed_back)
                # investor track
            for iid in dbutil.get_company_investors(self.db, cid):
                imid = dbutil.update_investor_message(self.db, iid, msg, 8001,
                                                      80, fa.id)
                if imid:
                    dbutil.update_investor_message_detail(self.db, imid, cid)
Ejemplo n.º 8
0
def __topic_26(db, funding):
    """
    每日投融资速递
    """

    global logger_track, round_desc
    active = 'Y' if dbutil.get_topic_auto_pubilsh_status(db,
                                                         26) == 'Y' else 'P'
    # cid = dbutil.get_corporate_companies(db, funding.corporateId)[0]
    cid = funding.companyId
    if funding.round in (1105, 1110):
        msg = u'%s, %s%s上市' % \
              (dbutil.get_company_brief(db, cid), dbutil.get_company_name(db, cid), round_desc.get(funding.round))
    elif funding.round == 1120:
        msg = u'%s, %s%s' % \
              (dbutil.get_company_brief(db, cid), dbutil.get_company_name(db, cid), round_desc.get(funding.round))
    elif funding.round in (1106, 1130, 1140, 1150, 1160):
        msg = u'%s, %s完成了%s' % \
              (dbutil.get_company_brief(db, cid), dbutil.get_company_name(db, cid), round_desc.get(funding.round))
    elif funding.round == 0:
        msg = u'%s, %s完成了新一轮融资' % (dbutil.get_company_brief(
            db, cid), dbutil.get_company_name(db, cid))
    elif funding.round == 1111:
        msg = u'%s, %s完成了新一轮融资' % (dbutil.get_company_brief(
            db, cid), dbutil.get_company_name(db, cid))
    elif funding.round == 1131:
        msg = u'%s, %s完成了战略合并' % (dbutil.get_company_brief(
            db, cid), dbutil.get_company_name(db, cid))
    else:
        msg = u'%s, %s完成了%s融资' % \
              (dbutil.get_company_brief(db, cid), dbutil.get_company_name(db, cid), round_desc.get(funding.round))
    tpm = dbutil.update_topic_message(db, 26, msg, active, 70, funding.id)
    if tpm:
        send_msg(tpm, 'topic_message')
        tpc = dbutil.update_topic_company(db, 26, cid, active)
        if tpc:
            dbutil.update_topic_message_company(db, tpm, tpc)
        # if active == 'Y':
        send_msg(tpc, 'topic_company')
    logger_track.info('26 for %s, add tpm %s' % (funding.id, tpm))