-
Notifications
You must be signed in to change notification settings - Fork 2
stats prototype implemented on landing page + more #157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
2 changes: 2 additions & 0 deletions
2
prisma/migrations/20250817230111_add_composite_index_for_stats_performance/migration.sql
This file contains hidden or 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,2 @@ | ||
| -- CreateIndex | ||
| CREATE INDEX "jules_tasks_flaggedForRetry_createdAt_idx" ON "jules_tasks"("flaggedForRetry", "createdAt"); |
This file contains hidden or 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 hidden or 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,20 @@ | ||
| import { db } from "@/server/db"; | ||
| import { NextResponse } from "next/server"; | ||
|
|
||
| export async function GET() { | ||
| try { | ||
| const totalRepositories = await db.installationRepository.count({ | ||
| where: { | ||
| removedAt: null, // only active repositories | ||
| }, | ||
| }); | ||
|
|
||
| return NextResponse.json({ totalRepositories }); | ||
| } catch (error) { | ||
| console.error("Failed to fetch repository stats:", error); | ||
| return NextResponse.json( | ||
| { error: "Failed to fetch stats" }, | ||
| { status: 500 }, | ||
| ); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,80 @@ | ||
| import { Card, CardContent } from "@/components/ui/card"; | ||
| import { appRouter } from "@/server/api/root"; | ||
| import { createCallerFactory } from "@/server/api/trpc"; | ||
| import { db } from "@/server/db"; | ||
| import { env } from "@/lib/env"; | ||
|
|
||
| export async function StatsSection() { | ||
| const createCaller = createCallerFactory(appRouter); | ||
| const caller = createCaller({ | ||
| headers: new Headers(), | ||
| db, | ||
| env, | ||
| }); | ||
|
|
||
| let stats; | ||
| try { | ||
| stats = await caller.tasks.publicStats(); | ||
| } catch (error) { | ||
| console.error("Failed to fetch stats:", error); | ||
| return null; | ||
| } | ||
|
|
||
| const statItems = [ | ||
| { | ||
| label: "Total Tasks Processed", | ||
| value: stats.totalTasks.toLocaleString(), | ||
| description: "GitHub issues processed through the queue", | ||
| borderColor: "border-jules-primary", | ||
| textColor: "text-jules-primary", | ||
| }, | ||
| { | ||
| label: "Total Retries Handled", | ||
| value: stats.totalRetries.toLocaleString(), | ||
| description: "Tasks automatically retried when Jules hit limits", | ||
| borderColor: "border-jules-pink", | ||
| textColor: "text-jules-pink", | ||
| }, | ||
| { | ||
| label: "Repositories Connected", | ||
| value: stats.totalRepositories.toLocaleString(), | ||
| description: "Repositories with the queue integration", | ||
| borderColor: "border-jules-cyan", | ||
| textColor: "text-jules-cyan", | ||
| }, | ||
| ]; | ||
|
|
||
| return ( | ||
| <section className="py-16 bg-jules-secondary-5"> | ||
| <div className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8"> | ||
| <div className="text-center mb-8"> | ||
| <h2 className="text-2xl md:text-3xl font-bold text-white mb-6"> | ||
| Jules Queue in Numbers | ||
| </h2> | ||
| <p className="text-lg text-gray-300"> | ||
| Statistics from our hosted deployment | ||
| </p> | ||
| </div> | ||
|
|
||
| <div className="grid grid-cols-1 sm:grid-cols-3 gap-6 max-w-3xl mx-auto"> | ||
| {statItems.map((stat) => ( | ||
| <Card | ||
| key={stat.label} | ||
| className={`border bg-jules-darker ${stat.borderColor}`} | ||
| > | ||
| <CardContent className="p-6 text-center"> | ||
| <div className={`text-3xl font-bold mb-2 ${stat.textColor}`}> | ||
| {stat.value} | ||
| </div> | ||
| <div className="text-white">{stat.label}</div> | ||
| <div className="text-sm text-gray-400 mt-2"> | ||
| {stat.description} | ||
| </div> | ||
| </CardContent> | ||
| </Card> | ||
| ))} | ||
| </div> | ||
| </div> | ||
| </section> | ||
| ); | ||
| } |
This file contains hidden or 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 hidden or 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,35 @@ | ||
| import { useEffect, useState } from "react"; | ||
|
|
||
| interface RepositoryStats { | ||
| totalRepositories: number; | ||
| } | ||
|
|
||
| export function useRepositoryStats() { | ||
| const [stats, setStats] = useState<RepositoryStats | null>(null); | ||
| const [isLoading, setIsLoading] = useState(true); | ||
| const [error, setError] = useState<string | null>(null); | ||
|
|
||
| useEffect(() => { | ||
| const fetchStats = async () => { | ||
| try { | ||
| setIsLoading(true); | ||
| const response = await fetch("/api/stats/repositories"); | ||
| if (!response.ok) { | ||
| throw new Error("Failed to fetch stats"); | ||
| } | ||
| const data = await response.json(); | ||
| setStats(data); | ||
| setError(null); | ||
| } catch (err) { | ||
| setError(err instanceof Error ? err.message : "Failed to fetch stats"); | ||
| setStats(null); | ||
| } finally { | ||
| setIsLoading(false); | ||
| } | ||
| }; | ||
|
|
||
| fetchStats(); | ||
| }, []); | ||
|
|
||
| return { stats, isLoading, error }; | ||
| } |
This file contains hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.