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