-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3bba50e
commit 41bc538
Showing
6 changed files
with
68 additions
and
12 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
apps/web/src/actions/commits/fetchCommitsByProjectAction.ts
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,32 @@ | ||
'use server' | ||
|
||
import { CommitsRepository, CommitStatus } from '@latitude-data/core' | ||
import commitPresenter from '$/presenters/commitPresenter' | ||
|
||
import { z } from 'zod' | ||
import { withProject } from '../procedures' | ||
|
||
// Not really using pagination yet | ||
const RANDOM_ULTRA_LARGE_PAGE_SIZE = 1000 | ||
|
||
export const fetchCommitsByProjectAction = withProject | ||
.createServerAction() | ||
.input( | ||
z.object({ | ||
status: z.nativeEnum(CommitStatus), | ||
page: z.number().optional(), | ||
pageSize: z.number().optional(), | ||
}), | ||
{ type: 'json' }, | ||
) | ||
.handler(async ({ input, ctx }) => { | ||
return new CommitsRepository(ctx.workspace.id) | ||
.getCommitsByProject({ | ||
project: ctx.project, | ||
filterByStatus: input.status, | ||
page: input.page ?? 1, | ||
pageSize: input.pageSize ?? RANDOM_ULTRA_LARGE_PAGE_SIZE, | ||
}) | ||
.then((r) => r.unwrap()) | ||
.then((r) => r.map(commitPresenter)) | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Commit } from '@latitude-data/core' | ||
|
||
export default function commitPresenter(commit: Commit) { | ||
return commit | ||
} |
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