Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove connections and action calls from the default functions list #483

Merged
merged 1 commit into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private void buildUtilityNodes(Map<String, String> queryMap) {
DatabaseManager dbManager = DatabaseManager.getInstance();

List<FunctionResult> functionResults = CommonUtils.hasNoKeyword(queryMap, "q") ?
dbManager.getFunctionsByOrg("ballerina") :
dbManager.getFunctionsByOrg("ballerina", DatabaseManager.FunctionKind.FUNCTION) :
dbManager.searchFunctions(queryMap, DatabaseManager.FunctionKind.FUNCTION);

for (FunctionResult functionResult : functionResults) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public List<FunctionResult> getAllFunctions(FunctionKind kind) {
}
}

public List<FunctionResult> getFunctionsByOrg(String orgName) {
public List<FunctionResult> getFunctionsByOrg(String orgName, FunctionKind functionKind) {
String sql = "SELECT " +
"f.function_id, " +
"f.name AS function_name, " +
Expand All @@ -152,11 +152,12 @@ public List<FunctionResult> getFunctionsByOrg(String orgName) {
"p.version " +
"FROM Function f " +
"JOIN Package p ON f.package_id = p.package_id " +
"WHERE p.org = ?;";
"WHERE f.kind = ? AND p.org = ?;";

try (Connection conn = DriverManager.getConnection(dbPath);
PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setString(1, orgName);
stmt.setString(1, functionKind.name());
stmt.setString(2, orgName);
ResultSet rs = stmt.executeQuery();
List<FunctionResult> functionResults = new ArrayList<>();
while (rs.next()) {
Expand Down Expand Up @@ -306,7 +307,7 @@ public Optional<FunctionResult> getAction(String org, String module, String symb
} else {
sql.append("AND f.name = ?;");
}

try (Connection conn = DriverManager.getConnection(dbPath);
PreparedStatement stmt = conn.prepareStatement(sql.toString())) {
stmt.setString(1, org);
Expand Down
Loading
Loading