Try storing events in new database

This commit is contained in:
Alex Gleason
2023-08-06 15:03:29 -05:00
parent 91eac97d5c
commit 8ceb63fc89
2 changed files with 47 additions and 12 deletions

View File

@@ -1,9 +1,10 @@
import { Conf } from '@/config.ts';
import { db } from '@/db.ts';
import { RelayPool } from '@/deps.ts';
import { trends } from '@/trends.ts';
import { nostrDate, nostrNow } from '@/utils.ts';
import type { Event } from '@/event.ts';
import type { SignedEvent } from '@/event.ts';
const relay = new RelayPool([Conf.relay]);
@@ -19,13 +20,14 @@ relay.subscribe(
);
/** Handle events through the loopback pipeline. */
function handleEvent(event: Event): void {
function handleEvent(event: SignedEvent): void {
console.info('loopback event:', event.id);
db.insertEvent(event);
trackHashtags(event);
}
/** Track whenever a hashtag is used, for processing trending tags. */
function trackHashtags(event: Event): void {
function trackHashtags(event: SignedEvent): void {
const date = nostrDate(event.created_at);
const tags = event.tags