Example #1
0
def patch_messages(messages):
    conn = db.connect_torndb()
    mongo = db.connect_mongo()
    for message in messages:
        if message["relateType"] == 70:
            message["newsId"] = None
            if message["relateId"] is not None and message["relateId"].strip(
            ) != "":
                try:
                    funding_id = int(message["relateId"].strip())
                    funding = conn.get("select * from funding where id=%s",
                                       funding_id)
                    if funding is not None and funding[
                            "newsId"] is not None and funding["newsId"].strip(
                            ) != "":
                        news_id = funding["newsId"].strip()
                        news = mongo.article.news.find_one(
                            {"_id": ObjectId(news_id)})
                        if news is not None:
                            message["newsId"] = news_id
                            message["newsTitle"] = news["title"]
                except:
                    pass

                # company, investors, round, investment
                try:
                    funding_id = int(message["relateId"].strip())
                    funding = conn.get("select * from funding where id=%s",
                                       funding_id)
                    if funding is not None:
                        company_id = funding["companyId"]
                        company = conn.get("select * from company where id=%s",
                                           company_id)
                        message["companyName"] = company["name"]
                        message["brief"] = company["brief"]
                        message["companyCode"] = company["code"]
                        message["round"] = funding_helper.get_round_desc(
                            funding["round"])
                        message[
                            "investment"] = funding_helper.gen_investment_desc(
                                funding["investment"], funding["precise"],
                                funding["preciseDesc"], funding["currency"])
                        message["investors"] = funding_helper.gen_investors(
                            funding["investorsRaw"], funding["investors"])
                        message["source"] = funding["source"]
                except:
                    pass
    mongo.close()
    conn.close()
Example #2
0
def get_detail(conn, item):
    funding_id = item["fundingId"]
    funding = conn.get("select * from funding where id=%s", funding_id)
    company = conn.get("select * from company where id=%s", item["companyId"])
    company["round"] = funding_helper.get_round_desc(funding["round"])
    company["fundingCreator"] = ""
    if funding["createUser"] is not None:
        user = conn.get("select * from user where id=%s", funding["createUser"])
        if user is not None:
            company["fundingCreator"] = user["username"]
    elif funding["modifyUser"] is not None:
        user = conn.get("select * from user where id=%s", funding["modifyUser"])
        if user is not None:
            company["fundingCreator"] = user["username"]
    return company
Example #3
0
def get_investor_message_content(conn, mongo, m):
    _id = m["investorMessageId"]
    m_mysql = conn.get("select * from investor_message where id=%s", _id)
    if m['relateType'] == 10:
        return '<a href="http://www.xiniudata.com/news/' + m['relateId'] + '">' + m_mysql['message'] + '</a>'

    if m['trackDimension'] == 7002:  # 完成新一轮融资
        funding_id = m['relateId']
        funding = conn.get("select * from funding where id=%s", funding_id)
        company = conn.get("select * from company where id=%s", funding["companyId"])
        str_money = funding_helper.gen_investment_desc(funding["investment"], funding["precise"],
                                                       funding["preciseDesc"],
                                                       funding["currency"])
        if str_money == "金额未知":
            str_money = '未披露'

        str_investors = funding_helper.gen_investors(funding["investorsRaw"], funding["investors"])
        if str_investors != "未透露":
            str_investors = "为%s" % str_investors

        msg = '投资了<a href="https://www.xiniudata.com/company/%s/overview">%s</a>,轮次%s,金额%s,投资机构%s' % \
              (company["code"], company["name"],
               funding_helper.get_round_desc(funding["round"]),
               str_money,
               str_investors)
        return msg

    if m['trackDimension'] == 7005:
        funding_id = m['relateId']
        funding = conn.get("select * from funding where id=%s", funding_id)
        company = conn.get("select * from company where id=%s", funding["companyId"])
        round = funding_helper.get_round_desc(funding["round"])
        if round == "轮次未知":
            round = "未披露"
        else:
            round = "为%s" % round
        msg = '退出了<a href="https://www.xiniudata.com/company/%s/overview">%s</a>,退出方式%s' % \
              (company["code"], company["name"], round)
        return msg

    if m['trackDimension'] == 7006:  # 已投项目发生投资事件
        funding_id = m['relateId']
        funding = conn.get("select * from funding where id=%s", funding_id)
        company = conn.get("select * from company where id=%s", funding["companyId"])
        str_money = funding_helper.gen_investment_desc(funding["investment"], funding["precise"],
                                                       funding["preciseDesc"],
                                                       funding["currency"])
        if str_money == "金额未知":
            str_money = '未披露'

        str_investors = funding_helper.gen_investors(funding["investorsRaw"], funding["investors"])
        if str_investors != "未透露":
            str_investors = "为%s" % str_investors

        msg = '投资过的<a href="https://www.xiniudata.com/company/%s/overview">%s</a>获得新一轮融资,轮次%s,金额%s,投资机构%s' % \
              (company["code"], company["name"],
               funding_helper.get_round_desc(funding["round"]),
               str_money,
               str_investors)
        return msg

    return m_mysql["message"]
Example #4
0
def get_company_message_content(conn, mongo, m):
    _id = m["companyMessageId"]
    m_mysql = conn.get("select * from company_message where id=%s", _id)

    if m['relateType'] == 10:  # 新闻
        return '<a href="http://www.xiniudata.com/news/' + m['relateId'] + '">' + m_mysql['message'] + '</a>'

    if m['trackDimension'] in [2001, 2002, 2003, 2004, 2005, 3107, 3108, 3201]:
        artifact = conn.get("select * from artifact where id=%s", m["relateId"])
        app = artifact["name"]
        app_type = APP_TYPE.get(artifact["type"], "")

        if m['trackDimension'] in [2004, 2005, 3201, 2001]:  #
            msg = "%s应用【%s】%s" % (app_type, app, DIMENSION.get(m['trackDimension'], ""))
            return msg

        desc = ""
        if m['trackDimension'] in [ 2002, 2003 ]:   #
            if artifact["type"] == 4040:    # iOS
                itunes = mongo.market.itunes.find_one({"trackId": int(artifact["domain"])})
                if itunes is not None:
                    updates = itunes["releaseNotes"]
                    if updates is None or updates.strip() == "":
                        updates = "无"
                    desc = "更新内容:%s" % updates
            elif artifact["type"] == 4050:  # 安卓
                android = mongo.market.android.find_one({"apkname": artifact["domain"]})
                if android is not None:
                    updates = android["updates"]
                    if updates is None or updates.strip() == "":
                        updates = "无"
                    desc = "更新内容:%s" % updates

        if m['trackDimension'] in [3107, 3108]:
            detail_id = m["detailId"]
            if detail_id is not None:
                strs = detail_id.split(",")
                if len(strs) == 2:
                    genre = strs[0]
                    rank_type = strs[1]
                    if m['trackDimension'] == 3107:
                        desc = "入围%s-%s前100名" % (GENRE.get(genre, ""), RANK_TYPE.get(rank_type, ""))
                    if m['trackDimension'] == 3108:
                        desc = "跌出%s-%s前100名" % (GENRE.get(genre, ""), RANK_TYPE.get(rank_type, ""))

        msg = "%s应用【%s】%s" % (app_type, app, desc)
        return msg

    if m['trackDimension'] == 7002:  # 公司完成新一轮融资
        funding_id = m['relateId']
        funding = conn.get("select * from funding where id=%s", funding_id)
        str_money = funding_helper.gen_investment_desc(funding["investment"], funding["precise"], funding["preciseDesc"],
                                                  funding["currency"])
        if str_money == "金额未知":
            str_money = '未披露'
        str_investors = funding_helper.gen_investors(funding["investorsRaw"], funding["investors"])
        if str_investors != "未透露":
            str_investors = "为%s" % str_investors
        msg = "获得新一轮融资,轮次%s,金额%s,投资机构%s" % \
              (funding_helper.get_round_desc(funding["round"]),
               str_money,
               str_investors
               )
        return msg

    if m['trackDimension'] in [5001, 5002]:
        msg = m_mysql["message"]
        if msg is None or msg.strip() == "":
            msg = "变更信息未披露"
        return msg

    if m['trackDimension'] == 6001:
        relate_id = m["relateId"]
        cs = conn.query("select name from company where id in (" + relate_id + ")")
        msg = "发现了%s个潜在竞争对手:%s" % (len(cs), ", ".join([c["name"] for c in cs]))
        return msg

    if m['trackDimension'] == 4002:
        msg = "期无新职位发布"
        return msg

    if m['trackDimension'] == 4004:
        msg = "正在招核心岗位"
        return msg

    return m_mysql["message"]