Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ljcui committed Mar 22, 2024
1 parent 037c258 commit 38016ab
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions osgraph/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,18 @@ std::string topn_developer(lgraph_api::GraphDB &db, const std::string& request)
std::unordered_set<int64_t> 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");
Expand All @@ -394,7 +403,7 @@ std::unordered_set<int64_t> get_repos_by_developer(lgraph_api::GraphDB &db, int6
int16_t comment_issue_id = txn.GetEdgeLabelId("comment_issue");

std::unordered_set<int64_t> repos;
{
/*{
int count = 0;
lgraph_api::EdgeUid euid;
euid.lid = push_id;
Expand All @@ -408,7 +417,7 @@ std::unordered_set<int64_t> get_repos_by_developer(lgraph_api::GraphDB &db, int6
}
repos.insert(eit.GetDst());
}
}
}*/
{
std::vector<int64_t> pr_ids;
{
Expand All @@ -419,7 +428,7 @@ std::unordered_set<int64_t> 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 {};
}
Expand All @@ -434,7 +443,7 @@ std::unordered_set<int64_t> 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 {};
}
Expand All @@ -449,7 +458,7 @@ std::unordered_set<int64_t> 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 {};
}
Expand Down Expand Up @@ -479,7 +488,7 @@ std::unordered_set<int64_t> 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 {};
}
Expand All @@ -494,7 +503,7 @@ std::unordered_set<int64_t> 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 {};
}
Expand All @@ -514,15 +523,15 @@ std::unordered_set<int64_t> 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;
}

std::unordered_set<int64_t> get_developers_by_repo(lgraph_api::GraphDB &db, int64_t repo_vid) {
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");
Expand All @@ -534,7 +543,7 @@ std::unordered_set<int64_t> get_developers_by_repo(lgraph_api::GraphDB &db, int6
int16_t comment_pr_id = txn.GetEdgeLabelId("comment_pr");

std::unordered_set<int64_t> developers;
{
/*{
lgraph_api::EdgeUid euid;
euid.lid = push_id;
for (auto eit = vit.GetInEdgeIterator(euid, true); eit.IsValid(); eit.Next()) {
Expand All @@ -543,7 +552,7 @@ std::unordered_set<int64_t> get_developers_by_repo(lgraph_api::GraphDB &db, int6
}
developers.insert(eit.GetSrc());
}
}
}*/
{
std::vector<int64_t> issue_ids;
lgraph_api::EdgeUid euid;
Expand Down

0 comments on commit 38016ab

Please sign in to comment.