Skip to content

Commit 75c3ac6

Browse files
feat: db design
1 parent 7f2f43b commit 75c3ac6

File tree

7 files changed

+920
-55
lines changed

7 files changed

+920
-55
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ dist/
1414
downloads/
1515
eggs/
1616
.eggs/
17-
lib/
17+
server/**/lib/
1818
lib64/
1919
parts/
2020
sdist/

async-code-web/app/page.tsx

Lines changed: 2 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -11,62 +11,10 @@ import { Badge } from "@/components/ui/badge";
1111
import { Label } from "@/components/ui/label";
1212
import { Separator } from "@/components/ui/separator";
1313
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
14+
import { Task } from "@/types";
15+
import { formatDiff, parseDiffStats } from "@/lib/utils";
1416

1517

16-
interface Task {
17-
id: string;
18-
status: string;
19-
prompt: string;
20-
repo_url: string;
21-
branch: string;
22-
model?: string;
23-
commit_hash?: string;
24-
error?: string;
25-
created_at: number;
26-
}
27-
28-
// Parse git diff to extract statistics
29-
function parseDiffStats(diff: string): { additions: number; deletions: number; files: number } {
30-
if (!diff) return { additions: 0, deletions: 0, files: 0 };
31-
32-
const lines = diff.split('\n');
33-
let additions = 0;
34-
let deletions = 0;
35-
const files = new Set<string>();
36-
37-
for (const line of lines) {
38-
if (line.startsWith('+++') || line.startsWith('---')) {
39-
const filePath = line.substring(4);
40-
if (filePath !== '/dev/null') {
41-
files.add(filePath);
42-
}
43-
} else if (line.startsWith('+') && !line.startsWith('+++')) {
44-
additions++;
45-
} else if (line.startsWith('-') && !line.startsWith('---')) {
46-
deletions++;
47-
}
48-
}
49-
50-
return { additions, deletions, files: files.size };
51-
}
52-
53-
// Format git diff with basic syntax highlighting
54-
function formatDiff(diff: string): string {
55-
if (!diff) return '';
56-
57-
return diff.split('\n').map(line => {
58-
if (line.startsWith('+++') || line.startsWith('---')) {
59-
return line; // File headers
60-
} else if (line.startsWith('@@')) {
61-
return line; // Hunk headers
62-
} else if (line.startsWith('+') && !line.startsWith('+++')) {
63-
return line; // Additions
64-
} else if (line.startsWith('-') && !line.startsWith('---')) {
65-
return line; // Deletions
66-
}
67-
return line; // Context lines
68-
}).join('\n');
69-
}
7018

7119
export default function Home() {
7220
const [prompt, setPrompt] = useState("");

async-code-web/lib/utils.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { type ClassValue, clsx } from "clsx"
2+
import { twMerge } from "tailwind-merge"
3+
4+
export function cn(...inputs: ClassValue[]) {
5+
return twMerge(clsx(inputs))
6+
}
7+
8+
// Format git diff with basic syntax highlighting
9+
export function formatDiff(diff: string): string {
10+
if (!diff) return '';
11+
12+
return diff.split('\n').map(line => {
13+
if (line.startsWith('+++') || line.startsWith('---')) {
14+
return line; // File headers
15+
} else if (line.startsWith('@@')) {
16+
return line; // Hunk headers
17+
} else if (line.startsWith('+') && !line.startsWith('+++')) {
18+
return line; // Additions
19+
} else if (line.startsWith('-') && !line.startsWith('---')) {
20+
return line; // Deletions
21+
}
22+
return line; // Context lines
23+
}).join('\n');
24+
}
25+
26+
// Parse git diff to extract statistics
27+
export function parseDiffStats(diff: string): { additions: number; deletions: number; files: number } {
28+
if (!diff) return { additions: 0, deletions: 0, files: 0 };
29+
30+
const lines = diff.split('\n');
31+
let additions = 0;
32+
let deletions = 0;
33+
const files = new Set<string>();
34+
35+
for (const line of lines) {
36+
if (line.startsWith('+++') || line.startsWith('---')) {
37+
const filePath = line.substring(4);
38+
if (filePath !== '/dev/null') {
39+
files.add(filePath);
40+
}
41+
} else if (line.startsWith('+') && !line.startsWith('+++')) {
42+
additions++;
43+
} else if (line.startsWith('-') && !line.startsWith('---')) {
44+
deletions++;
45+
}
46+
}
47+
48+
return { additions, deletions, files: files.size };
49+
}

async-code-web/types/index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export interface Task {
2+
id: string;
3+
status: string;
4+
prompt: string;
5+
repo_url: string;
6+
branch: string;
7+
model?: string;
8+
commit_hash?: string;
9+
error?: string;
10+
created_at: number;
11+
}

0 commit comments

Comments
 (0)