mirror of
https://git.sr.ht/~roxwize/mipilin
synced 2025-05-12 00:03:06 +00:00
i dont really know what i added
Signed-off-by: roxwize <rae@roxwize.xyz>
This commit is contained in:
parent
e3c09d7f0d
commit
7b563f5c31
24 changed files with 797 additions and 151 deletions
|
@ -4,6 +4,7 @@ import { follows, profiles, updates, users } from "../db/schema.js";
|
|||
import { and, desc, eq } from "drizzle-orm";
|
||||
import { getMoods, render } from "./util.js";
|
||||
import { PgColumn } from "drizzle-orm/pg-core";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export default async function (app: Express, db: NodePgDatabase) {
|
||||
const { moods } = await getMoods();
|
||||
|
@ -57,6 +58,19 @@ export default async function (app: Express, db: NodePgDatabase) {
|
|||
.limit(1)
|
||||
)[0];
|
||||
|
||||
// feed
|
||||
const now = dayjs();
|
||||
const userMoodFeed = (await db
|
||||
.select({
|
||||
mood: updates.mood,
|
||||
date: updates.date,
|
||||
desc: updates.description
|
||||
})
|
||||
.from(updates)
|
||||
.where(eq(updates.user, user.id))).map((e) => {
|
||||
return { user: user.name, mood: moods[e.mood], date: now.to(dayjs(e.date)), desc: e.desc }
|
||||
});
|
||||
|
||||
if (!isSelf) {
|
||||
userMood.mood = moods[userMood.mood as number];
|
||||
}
|
||||
|
@ -65,6 +79,7 @@ export default async function (app: Express, db: NodePgDatabase) {
|
|||
user,
|
||||
isSelf,
|
||||
userMood,
|
||||
userMoodFeed,
|
||||
isFollowing
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue