From 38016abb686ed348b1ac43eddf262f52c2d906b6 Mon Sep 17 00:00:00 2001 From: Wang Zhiyong Date: Fri, 22 Mar 2024 03:53:51 +0000 Subject: [PATCH] update --- osgraph/api.cpp | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/osgraph/api.cpp b/osgraph/api.cpp index e70ea6083e..b8eea72efe 100644 --- a/osgraph/api.cpp +++ b/osgraph/api.cpp @@ -380,9 +380,18 @@ std::string topn_developer(lgraph_api::GraphDB &db, const std::string& request) std::unordered_set get_repos_by_developer(lgraph_api::GraphDB &db, int64_t developer_vid) { auto txn = db.CreateReadTxn(); auto vit = txn.GetVertexIterator(developer_vid); + bool has_bot = false; auto developer_name = vit.GetField("name").AsString(); - LOG_INFO() << FMA_FMT("get_repos_by_developer begin {}", developer_name); - int16_t push_id = txn.GetEdgeLabelId("push"); + auto pos = developer_name.find("bot"); + if (pos != std::string::npos) { + has_bot = true; + } + pos = developer_name.find("Bot"); + if (pos != std::string::npos) { + has_bot = true; + } + //LOG_INFO() << FMA_FMT("get_repos_by_developer begin {}", developer_name); + //int16_t push_id = txn.GetEdgeLabelId("push"); int16_t has_pr_id = txn.GetEdgeLabelId("has_pr"); int16_t open_pr_id = txn.GetEdgeLabelId("open_pr"); @@ -394,7 +403,7 @@ std::unordered_set get_repos_by_developer(lgraph_api::GraphDB &db, int6 int16_t comment_issue_id = txn.GetEdgeLabelId("comment_issue"); std::unordered_set repos; - { + /*{ int count = 0; lgraph_api::EdgeUid euid; euid.lid = push_id; @@ -408,7 +417,7 @@ std::unordered_set get_repos_by_developer(lgraph_api::GraphDB &db, int6 } repos.insert(eit.GetDst()); } - } + }*/ { std::vector pr_ids; { @@ -419,7 +428,7 @@ std::unordered_set get_repos_by_developer(lgraph_api::GraphDB &db, int6 if (eit.GetLabelId() != open_pr_id) { break; } - if (++count > 10000) { + if (has_bot && ++count > 10000) { LOG_WARN() << "Invalid Developer: " << developer_name; return {}; } @@ -434,7 +443,7 @@ std::unordered_set get_repos_by_developer(lgraph_api::GraphDB &db, int6 if (eit.GetLabelId() != review_pr_id) { break; } - if (++count > 10000) { + if (has_bot && ++count > 10000) { LOG_WARN() << "Invalid Developer: " << developer_name; return {}; } @@ -449,7 +458,7 @@ std::unordered_set get_repos_by_developer(lgraph_api::GraphDB &db, int6 if (eit.GetLabelId() != comment_pr_id) { break; } - if (++count > 10000) { + if (has_bot && ++count > 10000) { LOG_WARN() << "Invalid Developer: " << developer_name; return {}; } @@ -479,7 +488,7 @@ std::unordered_set get_repos_by_developer(lgraph_api::GraphDB &db, int6 if (eit.GetLabelId() != open_issue_id) { break; } - if (++count > 10000) { + if (has_bot && ++count > 10000) { LOG_WARN() << "Invalid Developer: " << developer_name; return {}; } @@ -494,7 +503,7 @@ std::unordered_set get_repos_by_developer(lgraph_api::GraphDB &db, int6 if (eit.GetLabelId() != comment_issue_id) { break; } - if (++count > 10000) { + if (has_bot && ++count > 10000) { LOG_WARN() << "Invalid Developer: " << developer_name; return {}; } @@ -514,7 +523,7 @@ std::unordered_set get_repos_by_developer(lgraph_api::GraphDB &db, int6 } } } - LOG_INFO() << FMA_FMT("get_repos_by_developer end {}", developer_name); + //LOG_INFO() << FMA_FMT("get_repos_by_developer end {}", developer_name); return repos; } @@ -522,7 +531,7 @@ std::unordered_set get_developers_by_repo(lgraph_api::GraphDB &db, int6 auto txn = db.CreateReadTxn(); auto vit = txn.GetVertexIterator(repo_vid); - int16_t push_id = txn.GetEdgeLabelId("push"); + //int16_t push_id = txn.GetEdgeLabelId("push"); int16_t has_issue_id = txn.GetEdgeLabelId("has_issue"); int16_t open_issue_id = txn.GetEdgeLabelId("open_issue"); @@ -534,7 +543,7 @@ std::unordered_set get_developers_by_repo(lgraph_api::GraphDB &db, int6 int16_t comment_pr_id = txn.GetEdgeLabelId("comment_pr"); std::unordered_set developers; - { + /*{ lgraph_api::EdgeUid euid; euid.lid = push_id; for (auto eit = vit.GetInEdgeIterator(euid, true); eit.IsValid(); eit.Next()) { @@ -543,7 +552,7 @@ std::unordered_set get_developers_by_repo(lgraph_api::GraphDB &db, int6 } developers.insert(eit.GetSrc()); } - } + }*/ { std::vector issue_ids; lgraph_api::EdgeUid euid;