mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 03:19:46 +00:00
Disable stats for now (performance)
This commit is contained in:
parent
a0ebd80c7e
commit
1474050721
2 changed files with 25 additions and 26 deletions
|
|
@ -1,8 +1,6 @@
|
|||
import { Conf } from '@/config.ts';
|
||||
import * as eventsDB from '@/db/events.ts';
|
||||
import { findUser } from '@/db/users.ts';
|
||||
import { lodash, nip19, type UnsignedEvent } from '@/deps.ts';
|
||||
import { getFollowedPubkeys } from '@/queries.ts';
|
||||
import { jsonMetaContentSchema } from '@/schemas/nostr.ts';
|
||||
import { verifyNip05Cached } from '@/utils/nip05.ts';
|
||||
import { Nip05, nostrDate, nostrNow, parseNip05 } from '@/utils.ts';
|
||||
|
|
@ -26,12 +24,12 @@ async function renderAccount(event: UnsignedEvent<0>, opts: ToAccountOpts = {})
|
|||
|
||||
const npub = nip19.npubEncode(pubkey);
|
||||
|
||||
const [user, parsed05, followersCount, followingCount, statusesCount] = await Promise.all([
|
||||
const [user, parsed05 /*followersCount, followingCount, statusesCount*/] = await Promise.all([
|
||||
findUser({ pubkey }),
|
||||
parseAndVerifyNip05(nip05, pubkey),
|
||||
eventsDB.countFilters([{ kinds: [3], '#p': [pubkey] }]),
|
||||
getFollowedPubkeys(pubkey).then((pubkeys) => pubkeys.length),
|
||||
eventsDB.countFilters([{ kinds: [1], authors: [pubkey] }]),
|
||||
// eventsDB.countFilters([{ kinds: [3], '#p': [pubkey] }]),
|
||||
// getFollowedPubkeys(pubkey).then((pubkeys) => pubkeys.length),
|
||||
// eventsDB.countFilters([{ kinds: [1], authors: [pubkey] }]),
|
||||
]);
|
||||
|
||||
return {
|
||||
|
|
@ -46,8 +44,8 @@ async function renderAccount(event: UnsignedEvent<0>, opts: ToAccountOpts = {})
|
|||
emojis: renderEmojis(event),
|
||||
fields: [],
|
||||
follow_requests_count: 0,
|
||||
followers_count: followersCount,
|
||||
following_count: followingCount,
|
||||
followers_count: 0,
|
||||
following_count: 0,
|
||||
fqn: parsed05?.handle || npub,
|
||||
header: banner,
|
||||
header_static: banner,
|
||||
|
|
@ -65,7 +63,7 @@ async function renderAccount(event: UnsignedEvent<0>, opts: ToAccountOpts = {})
|
|||
follow_requests_count: 0,
|
||||
}
|
||||
: undefined,
|
||||
statuses_count: statusesCount,
|
||||
statuses_count: 0,
|
||||
url: Conf.local(`/users/${pubkey}`),
|
||||
username: parsed05?.nickname || npub.substring(0, 8),
|
||||
pleroma: {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import { isCWTag } from 'https://gitlab.com/soapbox-pub/mostr/-/raw/c67064aee5ade5e01597c6d23e22e53c628ef0e2/src/nostr/tags.ts';
|
||||
|
||||
import { Conf } from '@/config.ts';
|
||||
import * as eventsDB from '@/db/events.ts';
|
||||
import { type Event, findReplyTag, nip19 } from '@/deps.ts';
|
||||
import { getMediaLinks, parseNoteContent } from '@/note.ts';
|
||||
import { getAuthor } from '@/queries.ts';
|
||||
|
|
@ -12,7 +11,7 @@ import { accountFromPubkey, renderAccount } from '@/views/mastodon/accounts.ts';
|
|||
import { DittoAttachment, renderAttachment } from '@/views/mastodon/attachments.ts';
|
||||
import { renderEmojis } from '@/views/mastodon/emojis.ts';
|
||||
|
||||
async function renderStatus(event: Event<1>, viewerPubkey?: string) {
|
||||
async function renderStatus(event: Event<1>, _viewerPubkey?: string) {
|
||||
const profile = await getAuthor(event.pubkey);
|
||||
const account = profile ? await renderAccount(profile) : await accountFromPubkey(event.pubkey);
|
||||
|
||||
|
|
@ -28,19 +27,19 @@ async function renderStatus(event: Event<1>, viewerPubkey?: string) {
|
|||
|
||||
const { html, links, firstUrl } = parseNoteContent(event.content);
|
||||
|
||||
const [mentions, card, repliesCount, reblogsCount, favouritesCount, [repostEvent], [reactionEvent]] = await Promise
|
||||
const [mentions, card /*repliesCount, reblogsCount, favouritesCount, [repostEvent], [reactionEvent]*/] = await Promise
|
||||
.all([
|
||||
Promise.all(mentionedPubkeys.map(toMention)),
|
||||
firstUrl ? unfurlCardCached(firstUrl) : null,
|
||||
eventsDB.countFilters([{ kinds: [1], '#e': [event.id] }]),
|
||||
eventsDB.countFilters([{ kinds: [6], '#e': [event.id] }]),
|
||||
eventsDB.countFilters([{ kinds: [7], '#e': [event.id] }]),
|
||||
viewerPubkey
|
||||
? eventsDB.getFilters([{ kinds: [6], '#e': [event.id], authors: [viewerPubkey] }], { limit: 1 })
|
||||
: [],
|
||||
viewerPubkey
|
||||
? eventsDB.getFilters([{ kinds: [7], '#e': [event.id], authors: [viewerPubkey] }], { limit: 1 })
|
||||
: [],
|
||||
// eventsDB.countFilters([{ kinds: [1], '#e': [event.id] }]),
|
||||
// eventsDB.countFilters([{ kinds: [6], '#e': [event.id] }]),
|
||||
// eventsDB.countFilters([{ kinds: [7], '#e': [event.id] }]),
|
||||
// viewerPubkey
|
||||
// ? eventsDB.getFilters([{ kinds: [6], '#e': [event.id], authors: [viewerPubkey] }], { limit: 1 })
|
||||
// : [],
|
||||
// viewerPubkey
|
||||
// ? eventsDB.getFilters([{ kinds: [7], '#e': [event.id], authors: [viewerPubkey] }], { limit: 1 })
|
||||
// : [],
|
||||
]);
|
||||
|
||||
const content = buildInlineRecipients(mentions) + html;
|
||||
|
|
@ -68,11 +67,13 @@ async function renderStatus(event: Event<1>, viewerPubkey?: string) {
|
|||
spoiler_text: (cw ? cw[1] : subject?.[1]) || '',
|
||||
visibility: 'public',
|
||||
language: event.tags.find((tag) => tag[0] === 'lang')?.[1] || null,
|
||||
replies_count: repliesCount,
|
||||
reblogs_count: reblogsCount,
|
||||
favourites_count: favouritesCount,
|
||||
favourited: reactionEvent?.content === '+',
|
||||
reblogged: Boolean(repostEvent),
|
||||
replies_count: 0,
|
||||
reblogs_count: 0,
|
||||
favourites_count: 0,
|
||||
// favourited: reactionEvent?.content === '+',
|
||||
favourited: false,
|
||||
// reblogged: Boolean(repostEvent),
|
||||
reblogged: false,
|
||||
muted: false,
|
||||
bookmarked: false,
|
||||
reblog: null,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue