Skip to content

Commit

Permalink
Adding a DB powered changelog (#456)
Browse files Browse the repository at this point in the history
* Updated Prisma for new DB table

* feat: Add changelog types + cached fetching

* feat: added UX components to fetch changelogs

* feat: wired into changelog index page

* Yarned

* Removed old styles

* remove unused imports

* Added placeholder default

* Added multi-tenant

* Scoped calls for tenants

* Remove manual posts

* removed bg white

* added style feedback from review
  • Loading branch information
kent authored Sep 9, 2024
1 parent 867fa72 commit b348e84
Show file tree
Hide file tree
Showing 11 changed files with 233 additions and 1,323 deletions.
13 changes: 13 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -2106,6 +2106,19 @@ view cyberVotingPower {
@@map("voting_power")
}

model changelog {
id Int @id @default(autoincrement())
dao_slug DaoSlug
title String @db.VarChar(255)
body String
author_address String @db.VarChar(255)
created_at DateTime @default(now()) @db.Timestamp(6)
updated_at DateTime @default(now()) @db.Timestamp(6)
@@index([dao_slug], map: "idx_changelog_dao_slug")
@@schema("alltenant")
}

view cyberVotingPowerSnaps {
id String @id
delegate String?
Expand Down
11 changes: 11 additions & 0 deletions src/app/api/common/changelogs/changelog.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { DaoSlug } from "@prisma/client";

export type Changelog = {
id: number;
dao_slug: DaoSlug;
title: string;
body: string;
author_address: string;
created_at: Date;
updated_at: Date;
};
33 changes: 33 additions & 0 deletions src/app/api/common/changelogs/getChangelogs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { cache } from "react";
import {
PaginatedResult,
paginateResult,
PaginationParams,
} from "@/app/lib/pagination";
import prisma from "@/app/lib/prisma";
import { DaoSlug } from "@prisma/client";
import { Changelog } from "./changelog";

async function getChangelogsForDAO({
daoSlug,
pagination,
}: {
daoSlug: DaoSlug;
pagination: PaginationParams;
}): Promise<PaginatedResult<Changelog[]>> {
const getChangelogsQuery = async (skip: number, take: number) => {
return prisma.changelog.findMany({
where: {
dao_slug: daoSlug,
},
orderBy: {
created_at: "desc",
},
skip,
take,
});
};

return await paginateResult(getChangelogsQuery, pagination);
}
export const fetchChangelogForDAO = cache(getChangelogsForDAO);
24 changes: 0 additions & 24 deletions src/app/changelog/changelog.module.scss

This file was deleted.

Loading

0 comments on commit b348e84

Please sign in to comment.