Skip to content

Commit

Permalink
fixed query to change effective OR filtering to AND
Browse files Browse the repository at this point in the history
  • Loading branch information
megamaz committed Oct 31, 2023
1 parent 9f8af12 commit 6fbffdc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion GitStats/src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "A Lightweight ElectronJS app to get statistics about a repository.",
"keywords": [],
"main": "./dist/app.js",
"version": "2.0.1",
"version": "2.0.2",
"author": "megamaz",
"scripts": {
"start": "electron-forge start",
Expand Down
19 changes: 18 additions & 1 deletion GitStats/src/renderer_stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ async function CreateIssueGraph() {
var has_label_filter = false;
var has_assignee_filter = false;

var label_count = 0;
var assignee_count = 0;

// get label IDs
var label_ids = [];
if(label_filter.value != '') {
Expand All @@ -57,6 +60,7 @@ async function CreateIssueGraph() {
label_filter.value.split(",").forEach(label => {
if(label != '') {
filters.push(`_label='${label}'`);
label_count ++;
}
});
label_id_querry += " WHERE " + filters.join(" OR ");
Expand All @@ -77,6 +81,7 @@ async function CreateIssueGraph() {
assignee_filter.value.split(",").forEach(assignee => {
if(assignee != '') {
filters.push(`_name='${assignee}'`);
assignee_count ++;
}
});
assignee_id_querry += " WHERE " + filters.join(" OR ");
Expand All @@ -102,7 +107,19 @@ async function CreateIssueGraph() {
if(has_assignee_filter) {
sql_querry += " INNER JOIN assigneelink ON issuelist._number=assigneelink._number";
}
sql_querry += " WHERE " + all_filters.join(" AND ");
sql_querry += " WHERE " + all_filters.join(" AND ") + ` GROUP BY issuelist._number`;
// thanks ChatGPT
if(label_count != 0 || assignee_count != 0) {
sql_querry += " HAVING "
if(label_count != 0) {
sql_querry += `COUNT(DISTINCT labellink._id) = ${label_count}`
}
if(label_count != 0 && assignee_count != 0)
sql_querry += " AND "
if(assignee_count != 0) {
sql_querry += `COUNT(DISTINCT assigneelink._id) = ${assignee_count}`
}
}
}

sql_querry += " ORDER BY _dateopen";
Expand Down

0 comments on commit 6fbffdc

Please sign in to comment.