Skip to content

Commit 3d3405b

Browse files
committed
Merge branch 'ops/count-query' into 'master'
Single GraphQL query for fetching story count Closes #29 See merge request SUSE-UIUX/eos-user-story!128
2 parents 14eaaf7 + 150f119 commit 3d3405b

File tree

1 file changed

+3
-26
lines changed

1 file changed

+3
-26
lines changed

src/pages/Home.js

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -131,32 +131,13 @@ const Home = () => {
131131

132132
useEffect(() => {
133133
const fetchStoryCount = async () => {
134-
const response = await axios.post(
135-
`${apiURL}/graphql`,
136-
{
137-
query: `
138-
query {
139-
userStoriesConnection(where: { user_story_status: { Status: "${currentStateSelected}" } }) {
140-
aggregate {
141-
count
142-
}
143-
}
144-
}`
145-
},
146-
{
147-
withCredentials: true
148-
}
149-
)
150-
setStoryCount(response.data.data.userStoriesConnection.aggregate.count)
151-
}
152-
const fetchStoryCountWithProduct = async () => {
153134
const response = await axios.post(
154135
`${apiURL}/graphql`,
155136
{
156137
query: `
157138
query {
158139
userStoriesConnection(where: { user_story_status: { Status: "${currentStateSelected}" },
159-
product: { Name: "${product}"} }) {
140+
${productQuery} }) {
160141
aggregate {
161142
count
162143
}
@@ -169,12 +150,8 @@ const Home = () => {
169150
)
170151
setStoryCount(response.data.data.userStoriesConnection.aggregate.count)
171152
}
172-
if (product === 'All') {
173-
fetchStoryCount()
174-
} else {
175-
fetchStoryCountWithProduct()
176-
}
177-
}, [currentStateSelected, product])
153+
fetchStoryCount()
154+
}, [currentStateSelected, product, productQuery])
178155

179156
useEffect(() => {
180157
const fetchProducts = async () => {

0 commit comments

Comments
 (0)