I am looking to populate a scripted field with the number of stories resolved vs. the total number of stories so I can show on a Kanban Card (see image).
The code I have works but I am only able to count all resolved issues vs. total issues linked.
I want the calculation to be limited to Stories only.
In the pasted code, I have a commented out block that will count only linked Stories which I know works fine.
What I am missing is the code that will only count the number of resolved Stories so I can feed that value into the variable "y".
Appreciate any guidance!

import com.atlassian.jira.component.ComponentAccessor
int x = 0
int y = 0
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def linkedIssues = ComponentAccessor.getIssueLinkManager().getLinkCollection(issue, currentUser).getAllIssues()
def resolvedIssues = ComponentAccessor.getIssueLinkManager().getLinkCollection(issue, issue.reporter).getAllIssues()
/*
if (linkedIssues.size() > 0){
for (int i = 0; i < linkedIssues.size(); i++){
// Use the following IF statements to limit the count to certain issue types
if (linkedIssues[i].getIssueType().getName() == "Story"){
x = x + 1
}
//if (linkedIssues[i].getIssueType().getName() == "Task"){
x = x + 1
}
}
}
*/
// Gets count of linked issues regardless of issue type
x = linkedIssues.size()
//Counts number of resolved issues
y = resolvedIssues.count{it.resolution != null}
// Formats output
if (x > 0) {
if (y > 0) {
return "[" + y + " of " + x + "]"
}}else return null
Additional question:
In lines 6 & 7, is it okay to use currentUser and issue.reporter or will this limit the calculation based on access rights?