Minor refactoring
This commit is contained in:
parent
295b16e943
commit
cd68da5b93
|
@ -49,6 +49,7 @@ const migrator = new Migrator({
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('Running migrations...');
|
console.log('Running migrations...');
|
||||||
await migrator.migrateToLatest();
|
const results = await migrator.migrateToLatest();
|
||||||
|
console.log('Migrations finished:', results);
|
||||||
|
|
||||||
export { db, type EventRow, type TagRow, type UserRow };
|
export { db, type EventRow, type TagRow, type UserRow };
|
||||||
|
|
|
@ -35,7 +35,7 @@ function insertEvent(event: SignedEvent): Promise<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getFilter<K extends number = number>(filter: Filter<K>): Promise<SignedEvent<K>[]> {
|
async function getFilter<K extends number = number>(filter: Filter<K>): Promise<SignedEvent<K>[]> {
|
||||||
let query = db.selectFrom('events').selectAll();
|
let query = db.selectFrom('events').selectAll().orderBy('created_at', 'desc');
|
||||||
|
|
||||||
for (const key of Object.keys(filter)) {
|
for (const key of Object.keys(filter)) {
|
||||||
switch (key as keyof Filter) {
|
switch (key as keyof Filter) {
|
||||||
|
|
|
@ -22,7 +22,7 @@ relay.subscribe(
|
||||||
/** Handle events through the loopback pipeline. */
|
/** Handle events through the loopback pipeline. */
|
||||||
function handleEvent(event: SignedEvent): void {
|
function handleEvent(event: SignedEvent): void {
|
||||||
console.info('loopback event:', event.id);
|
console.info('loopback event:', event.id);
|
||||||
insertEvent(event);
|
insertEvent(event).catch(console.warn);
|
||||||
trackHashtags(event);
|
trackHashtags(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue