Skip to content

Commit c68796e

Browse files
authored
Merge pull request #106 from jordanopensource/feature/count-issues-pull-requests-and-code-reviews
Feature/count issues pull requests and code reviews
2 parents 88b7a09 + 3ef8017 commit c68796e

File tree

5 files changed

+95
-22
lines changed

5 files changed

+95
-22
lines changed

components/Contributors.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
:image-url="user.avatar_url"
1818
:profile-url="user.profile_url"
1919
:score="user.score"
20-
:contributions="user.commitsTotalCount"
20+
:contributions="user.contributionsTotalCount"
2121
:rank="user.currentRank"
2222
:is-josa-member="user.isJOSAMember"
2323
/>
@@ -50,20 +50,21 @@ export default {
5050
period: 'period',
5151
show: 'show',
5252
userSearchTerm: 'userSearchTerm',
53+
countType: 'countType',
5354
}),
5455
},
5556
methods: {
5657
async fetchCurrentPage(page) {
5758
if (this.userSearchTerm) {
5859
const response = await this.$axios.get(
59-
`v1/users?page=${this.currentPage}&sort_by=${this.sortBy}&period=${this.period}&contributors=${this.show}&search=${this.userSearchTerm}`,
60+
`v1/users?page=${this.currentPage}&sort_by=${this.sortBy}&period=${this.period}&contributors=${this.show}&search=${this.userSearchTerm}&type=${this.countType}`,
6061
)
6162
6263
this.$store.commit('setUsers', response.data.users)
6364
this.$store.commit('setPageCount', response.data.totalPages)
6465
} else {
6566
const response = await this.$axios.get(
66-
`v1/users?page=${this.currentPage}&sort_by=${this.sortBy}&period=${this.period}&contributors=${this.show}`,
67+
`v1/users?page=${this.currentPage}&sort_by=${this.sortBy}&period=${this.period}&contributors=${this.show}&type=${this.countType}`,
6768
)
6869
6970
this.$store.commit('setUsers', response.data.users)

components/InputsSection.vue

Lines changed: 82 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
</div>
66
<div class="sort-section">
77
<h6 class="text-xs font-bold pb-2">Period:</h6>
8-
<div class="flex lg:flex-col">
8+
<div class="flex lg:flex-col gap-1">
99
<PeriodDropdown />
1010
</div>
1111
</div>
1212
<div class="sort-section has-border">
1313
<h6 class="text-xs font-bold pb-2">Sort by:</h6>
14-
<div class="flex lg:flex-col">
14+
<div class="flex lg:flex-col gap-1">
1515
<RadioButton
1616
class="lg:pb-1"
1717
:input-id="`score`"
@@ -24,18 +24,18 @@
2424
/>
2525
<RadioButton
2626
class="pb-2 contributions-radio"
27-
:input-id="`commits`"
27+
:input-id="`contributions`"
2828
:input-name="`sortby`"
29-
:label-for="`commits`"
30-
:label-text="`Commits`"
31-
:value="'commit'"
29+
:label-for="`contributions`"
30+
:label-text="`Contributions`"
31+
:value="'contributions'"
3232
@on-sort-by-changed="onSortByChanged"
3333
/>
3434
</div>
3535
</div>
3636
<div class="sort-section has-border">
3737
<h6 class="text-xs font-bold pb-2">Show:</h6>
38-
<div class="flex lg:flex-col">
38+
<div class="flex lg:flex-col gap-1">
3939
<RadioButton
4040
class="lg:pb-1"
4141
:input-id="`all`"
@@ -59,15 +59,35 @@
5959
</div>
6060
<div class="sort-section">
6161
<h6 class="text-xs font-bold pb-2">Count:</h6>
62-
<div class="flex lg:flex-col">
63-
<CheckBox
62+
<div class="flex lg:flex-col justify-between gap-1">
63+
<div class="flex">
64+
<RadioButton
65+
class="lg:pb-1"
66+
:input-id="`all contributions`"
67+
:input-name="`count`"
68+
:label-for="`all contributions`"
69+
:label-text="`All Contributions`"
70+
:checked="true"
71+
:value="'all'"
72+
@on-count-type-changed="onCountTypeChanged"
73+
/>
74+
<div class="tooltip">
75+
<span class="text-sm font-bold cursor-pointer px-1 blue-green">
76+
&#9432;
77+
</span>
78+
<span class="tooltip-text">
79+
Commits, Issues, Pull Requests and Code Reviews.
80+
</span>
81+
</div>
82+
</div>
83+
<RadioButton
6484
class="lg:pb-1"
6585
:input-id="`commits`"
6686
:input-name="`count`"
6787
:label-for="`commits`"
6888
:label-text="`Commits`"
69-
:checked="true"
7089
:value="'commits'"
90+
@on-count-type-changed="onCountTypeChanged"
7191
/>
7292
</div>
7393
</div>
@@ -77,13 +97,11 @@
7797
<script>
7898
import { mapGetters } from 'vuex'
7999
import RadioButton from './RadioButton.vue'
80-
import CheckBox from './CheckBox.vue'
81100
import PeriodDropdown from './PeriodDropdown.vue'
82101
export default {
83102
name: 'InputsSection',
84103
components: {
85104
RadioButton,
86-
CheckBox,
87105
PeriodDropdown,
88106
},
89107
props: {
@@ -96,6 +114,7 @@ export default {
96114
getShow: 'getShow',
97115
getSortBy: 'getSortBy',
98116
getUserSearchTerm: 'getUserSearchTerm',
117+
getCountType: 'getCountType',
99118
}),
100119
},
101120
methods: {
@@ -105,13 +124,13 @@ export default {
105124
106125
if (this.getUserSearchTerm) {
107126
const response = await this.$axios.get(
108-
`v1/users?sort_by=${sortBy}&page=${this.getCurrentPage}&period=${this.getPeriod}&contributors=${this.getShow}&search=${this.getUserSearchTerm}`,
127+
`v1/users?sort_by=${sortBy}&page=${this.getCurrentPage}&period=${this.getPeriod}&contributors=${this.getShow}&search=${this.getUserSearchTerm}&type=${this.getCountType}`,
109128
)
110129
this.$store.commit('setUsers', response.data.users)
111130
this.$store.commit('setPageCount', response.data.totalPages)
112131
} else {
113132
const response = await this.$axios.get(
114-
`v1/users?sort_by=${sortBy}&page=${this.getCurrentPage}&period=${this.getPeriod}&contributors=${this.getShow}`,
133+
`v1/users?sort_by=${sortBy}&page=${this.getCurrentPage}&period=${this.getPeriod}&contributors=${this.getShow}&type=${this.getCountType}`,
115134
)
116135
117136
this.$store.commit('setUsers', response.data.users)
@@ -123,14 +142,14 @@ export default {
123142
this.$store.commit('setShow', show)
124143
if (this.getUserSearchTerm) {
125144
const response = await this.$axios.get(
126-
`v1/users?sort_by=${this.getSortBy}&page=${this.getCurrentPage}&period=${this.getPeriod}&contributors=${show}&search=${this.getUserSearchTerm}`,
145+
`v1/users?sort_by=${this.getSortBy}&page=${this.getCurrentPage}&period=${this.getPeriod}&contributors=${show}&search=${this.getUserSearchTerm}&type=${this.getCountType}`,
127146
)
128147
129148
this.$store.commit('setUsers', response.data.users)
130149
this.$store.commit('setPageCount', response.data.totalPages)
131150
} else {
132151
const response = await this.$axios.get(
133-
`v1/users?sort_by=${this.getSortBy}&page=${this.getCurrentPage}&period=${this.getPeriod}&contributors=${show}`,
152+
`v1/users?sort_by=${this.getSortBy}&page=${this.getCurrentPage}&period=${this.getPeriod}&contributors=${show}&type=${this.getCountType}`,
134153
)
135154
136155
this.$store.commit('setUsers', response.data.users)
@@ -141,20 +160,39 @@ export default {
141160
this.$store.commit('setCurrentPage', 1)
142161
if (searchTerm) {
143162
const response = await this.$axios.get(
144-
`v1/users?sort_by=${this.getSortBy}&page=${this.getCurrentPage}&period=${this.getPeriod}&contributors=${this.getShow}&search=${searchTerm}`,
163+
`v1/users?sort_by=${this.getSortBy}&page=${this.getCurrentPage}&period=${this.getPeriod}&contributors=${this.getShow}&search=${searchTerm}&type=${this.getCountType}`,
145164
)
146165
this.$store.commit('setUserSearchTerm', searchTerm)
147166
this.$store.commit('setUsers', response.data.users)
148167
this.$store.commit('setPageCount', response.data.totalPages)
149168
} else {
150169
const response = await this.$axios.get(
151-
`v1/users?sort_by=${this.getSortBy}&page=${this.getCurrentPage}&period=${this.getPeriod}&contributors=${this.getShow}`,
170+
`v1/users?sort_by=${this.getSortBy}&page=${this.getCurrentPage}&period=${this.getPeriod}&contributors=${this.getShow}&type=${this.getCountType}`,
152171
)
153172
this.$store.commit('setUserSearchTerm', '')
154173
this.$store.commit('setUsers', response.data.users)
155174
this.$store.commit('setPageCount', response.data.totalPages)
156175
}
157176
},
177+
async onCountTypeChanged(countType) {
178+
this.$store.commit('setCurrentPage', 1)
179+
this.$store.commit('setCountType', countType)
180+
if (this.getUserSearchTerm) {
181+
const response = await this.$axios.get(
182+
`v1/users?sort_by=${this.getSortBy}&page=${this.getCurrentPage}&period=${this.getPeriod}&contributors=${this.getShow}&search=${this.getUserSearchTerm}&type=${this.getCountType}`,
183+
)
184+
185+
this.$store.commit('setUsers', response.data.users)
186+
this.$store.commit('setPageCount', response.data.totalPages)
187+
} else {
188+
const response = await this.$axios.get(
189+
`v1/users?sort_by=${this.getSortBy}&page=${this.getCurrentPage}&period=${this.getPeriod}&contributors=${this.getShow}&type=${this.getCountType}`,
190+
)
191+
192+
this.$store.commit('setUsers', response.data.users)
193+
this.$store.commit('setPageCount', response.data.totalPages)
194+
}
195+
},
158196
},
159197
}
160198
</script>
@@ -172,4 +210,30 @@ export default {
172210
margin-left: 2.8rem;
173211
@apply lg:ml-0;
174212
}
213+
214+
/* Tooltip container */
215+
.tooltip {
216+
@apply p-0;
217+
}
218+
219+
/* Tooltip text */
220+
.tooltip .tooltip-text {
221+
@apply w-32 bg-white text-black p-2 text-xs;
222+
visibility: hidden;
223+
text-align: center;
224+
border-radius: 6px;
225+
226+
/* Position the tooltip text */
227+
position: absolute;
228+
z-index: 1;
229+
}
230+
231+
/* Show the tooltip text when you mouse over the tooltip container */
232+
.tooltip:hover .tooltip-text {
233+
visibility: visible;
234+
}
235+
236+
.blue-green {
237+
color: #00b199;
238+
}
175239
</style>

components/RadioButton.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ export default {
5353
} else if (this.inputName === 'show') {
5454
const show = event.target.value
5555
this.$emit('on-show-changed', show)
56+
} else if (this.inputName === 'count') {
57+
const countType = event.target.value
58+
this.$emit('on-count-type-changed', countType)
5659
}
5760
},
5861
},

components/UserCard.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<p class="blue">{{ score }}</p>
4949
</div>
5050
<div class="flex flex-col">
51-
<p class="counters">Commits</p>
51+
<p class="counters">Contributions</p>
5252
<p class="blue-green">{{ contributions }}</p>
5353
</div>
5454
</div>

store/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export const state = () => ({
1111
period: 'last_30_days',
1212
chartPeriod: 'last_year',
1313
show: 'all',
14+
countType: 'all',
1415
orgSearchTerm: '',
1516
userSearchTerm: '',
1617
})
@@ -23,6 +24,7 @@ export const getters = {
2324
getPeriod: (state) => state.period,
2425
getChartPeriod: (state) => state.chartPeriod,
2526
getShow: (state) => state.show,
27+
getCountType: (state) => state.countType,
2628
getOrgSearchTerm: (state) => state.orgSearchTerm,
2729
getUserSearchTerm: (state) => state.userSearchTerm,
2830
}
@@ -64,6 +66,9 @@ export const mutations = {
6466
setShow(state, show) {
6567
state.show = show
6668
},
69+
setCountType(state, countType) {
70+
state.countType = countType
71+
},
6772
setOrgSearchTerm(state, searchTerm) {
6873
state.orgSearchTerm = searchTerm
6974
},

0 commit comments

Comments
 (0)