Remove counts to make less expensive db requests

This commit is contained in:
mattwr18 2019-12-09 17:41:38 +01:00
parent 79c6bd5c20
commit 60bf819a56
3 changed files with 14 additions and 19 deletions

View File

@ -8,7 +8,7 @@
<dropdown v-else :class="{ 'disabled-content': user.disabled }" placement="top-start" offset="0"> <dropdown v-else :class="{ 'disabled-content': user.disabled }" placement="top-start" offset="0">
<template slot="default" slot-scope="{ openMenu, closeMenu, isOpen }"> <template slot="default" slot-scope="{ openMenu, closeMenu, isOpen }">
<nuxt-link :to="userLink" :class="['user', isOpen && 'active']"> <nuxt-link :to="userLink" :class="['user', isOpen && 'active']">
<div @mouseover="openMenu(true)" @mouseleave="closeMenu(true)"> <div @mouseover="openInfoMenu" @mouseleave="closeMenu(true)">
<hc-avatar v-if="showAvatar" class="avatar" :user="user" /> <hc-avatar v-if="showAvatar" class="avatar" :user="user" />
<div> <div>
<ds-text class="userinfo"> <ds-text class="userinfo">
@ -26,7 +26,7 @@
</div> </div>
</nuxt-link> </nuxt-link>
</template> </template>
<template slot="popover"> <template slot="popover" v-if="showCounts">
<div style="min-width: 250px"> <div style="min-width: 250px">
<hc-badges v-if="user.badges && user.badges.length" :badges="user.badges" /> <hc-badges v-if="user.badges && user.badges.length" :badges="user.badges" />
<ds-text <ds-text
@ -106,6 +106,7 @@ export default {
showAvatar: { type: Boolean, default: true }, showAvatar: { type: Boolean, default: true },
trunc: { type: Number, default: 18 }, // "-1" is no trunc trunc: { type: Number, default: 18 }, // "-1" is no trunc
dateTime: { type: [Date, String], default: null }, dateTime: { type: [Date, String], default: null },
showCounts: { type: Boolean, default: true },
}, },
computed: { computed: {
...mapGetters({ ...mapGetters({
@ -142,6 +143,9 @@ export default {
this.user.followedByCount = followedByCount this.user.followedByCount = followedByCount
this.user.followedByCurrentUser = followedByCurrentUser this.user.followedByCurrentUser = followedByCurrentUser
}, },
openInfoMenu() {
if (this.showCounts) this.openMenu(true)
},
}, },
} }
</script> </script>

View File

@ -19,7 +19,7 @@
<!-- Content Column --> <!-- Content Column -->
<td class="ds-table-col" data-test="report-content"> <td class="ds-table-col" data-test="report-content">
<client-only v-if="isUser"> <client-only v-if="isUser">
<hc-user :user="report.resource" :showAvatar="false" :trunc="30" /> <hc-user :user="report.resource" :showAvatar="false" :trunc="30" :showCounts="false" />
</client-only> </client-only>
<nuxt-link v-else class="title" :to="linkTarget"> <nuxt-link v-else class="title" :to="linkTarget">
{{ linkText | truncate(50) }} {{ linkText | truncate(50) }}
@ -29,7 +29,12 @@
<!-- Author Column --> <!-- Author Column -->
<td class="ds-table-col" data-test="report-author"> <td class="ds-table-col" data-test="report-author">
<client-only v-if="!isUser"> <client-only v-if="!isUser">
<hc-user :user="report.resource.author" :showAvatar="false" :trunc="30" /> <hc-user
:user="report.resource.author"
:showAvatar="false"
:trunc="30"
:showCounts="false"
/>
</client-only> </client-only>
<span v-else></span> <span v-else></span>
</td> </td>
@ -46,6 +51,7 @@
:showAvatar="false" :showAvatar="false"
:trunc="30" :trunc="30"
:date-time="report.updatedAt" :date-time="report.updatedAt"
:showCounts="false"
/> />
</client-only> </client-only>
</td> </td>

View File

@ -29,9 +29,6 @@ export const reportsListQuery = () => {
id id
slug slug
name name
followedByCount
contributionsCount
commentedCount
} }
} }
resource { resource {
@ -42,9 +39,6 @@ export const reportsListQuery = () => {
name name
disabled disabled
deleted deleted
followedByCount
contributionsCount
commentedCount
} }
... on Comment { ... on Comment {
id id
@ -57,9 +51,6 @@ export const reportsListQuery = () => {
name name
disabled disabled
deleted deleted
followedByCount
contributionsCount
commentedCount
} }
post { post {
id id
@ -81,9 +72,6 @@ export const reportsListQuery = () => {
name name
disabled disabled
deleted deleted
followedByCount
contributionsCount
commentedCount
} }
} }
} }
@ -94,9 +82,6 @@ export const reportsListQuery = () => {
name name
disabled disabled
deleted deleted
followedByCount
contributionsCount
commentedCount
} }
createdAt createdAt
reasonCategory reasonCategory