-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make Github stars dynamic and improve database init (#5000)
I extracted the init database logic into its own file. You can now run it with yarn database:init. Added database entry for GitHub stars. Do you want me to remove the init route or is it used for something else ? --------- Co-authored-by: Ady Beraud <a.beraud96@gmail.com> Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
- Loading branch information
1 parent
fda0c3c
commit 0a7f823
Showing
27 changed files
with
237 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 11 additions & 4 deletions
15
packages/twenty-website/src/app/_components/ui/layout/header/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,20 @@ | ||
'use client'; | ||
import { desc } from 'drizzle-orm'; | ||
|
||
import { HeaderDesktop } from '@/app/_components/ui/layout/header/HeaderDesktop'; | ||
import { HeaderMobile } from '@/app/_components/ui/layout/header/HeaderMobile'; | ||
import { findOne } from '@/database/database'; | ||
import { githubStarsModel } from '@/database/model'; | ||
|
||
export const AppHeader = async () => { | ||
const githubStars = await findOne( | ||
githubStarsModel, | ||
desc(githubStarsModel.timestamp), | ||
); | ||
|
||
export const AppHeader = () => { | ||
return ( | ||
<> | ||
<HeaderDesktop /> | ||
<HeaderMobile /> | ||
<HeaderDesktop numberOfStars={githubStars?.[0]?.numberOfStars} /> | ||
<HeaderMobile numberOfStars={githubStars?.[0]?.numberOfStars} /> | ||
</> | ||
); | ||
}; |
26 changes: 26 additions & 0 deletions
26
packages/twenty-website/src/app/api/github-stars/route.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { desc } from 'drizzle-orm'; | ||
|
||
import { findOne } from '@/database/database'; | ||
import { githubStarsModel } from '@/database/model'; | ||
import { formatNumberOfStars } from '@/shared-utils/formatNumberOfStars'; | ||
|
||
export const dynamic = 'force-dynamic'; | ||
|
||
export async function GET() { | ||
try { | ||
const githubStars = await findOne( | ||
githubStarsModel, | ||
desc(githubStarsModel.timestamp), | ||
); | ||
|
||
const formattedGithubNumberOfStars = formatNumberOfStars( | ||
githubStars[0].numberOfStars, | ||
); | ||
|
||
return Response.json(formattedGithubNumberOfStars); | ||
} catch (error: any) { | ||
return new Response(`Github stars error: ${error?.message}`, { | ||
status: 500, | ||
}); | ||
} | ||
} |
46 changes: 0 additions & 46 deletions
46
packages/twenty-website/src/app/contributors/api/init/route.tsx
This file was deleted.
Oops, something went wrong.
10 changes: 5 additions & 5 deletions
10
packages/twenty-website/src/app/contributors/api/update/route.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { migrate } from '@/database/database'; | ||
|
||
export const migrateDatabase = async () => { | ||
await migrate(); | ||
process.exit(0); | ||
}; | ||
|
||
migrateDatabase(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
packages/twenty-website/src/database/postgres/migrations/0001_marvelous_eddie_brock.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
CREATE TABLE IF NOT EXISTS "githubStars" ( | ||
"timestamp" timestamp DEFAULT now() NOT NULL, | ||
"numberOfStars" integer | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,4 @@ | |
"breakpoints": true | ||
} | ||
] | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...ntributors/api/fetch-assignable-users.tsx → ...c/contributors/fetch-assignable-users.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.