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">
<template slot="default" slot-scope="{ openMenu, closeMenu, isOpen }">
<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" />
<div>
<ds-text class="userinfo">
@ -26,7 +26,7 @@
</div>
</nuxt-link>
</template>
<template slot="popover">
<template slot="popover" v-if="showCounts">
<div style="min-width: 250px">
<hc-badges v-if="user.badges && user.badges.length" :badges="user.badges" />
<ds-text
@ -106,6 +106,7 @@ export default {
showAvatar: { type: Boolean, default: true },
trunc: { type: Number, default: 18 }, // "-1" is no trunc
dateTime: { type: [Date, String], default: null },
showCounts: { type: Boolean, default: true },
},
computed: {
...mapGetters({
@ -142,6 +143,9 @@ export default {
this.user.followedByCount = followedByCount
this.user.followedByCurrentUser = followedByCurrentUser
},
openInfoMenu() {
if (this.showCounts) this.openMenu(true)
},
},
}
</script>

View File

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

View File

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