Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions apps/api/src/routes/v1/code-review.http.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { HttpApiBuilder } from "effect/unstable/httpapi"
import { CurrentTenant, MapleApi } from "@maple/domain/http"
import { Effect } from "effect"
import { PrReviewAnalyticsService } from "@maple/backend/services/pr-review/PrReviewAnalyticsService"

export const HttpCodeReviewLive = HttpApiBuilder.group(MapleApi, "codeReview", (handlers) =>
Effect.gen(function* () {
const analytics = yield* PrReviewAnalyticsService

return handlers
.handle("analytics", ({ query }) =>
Effect.gen(function* () {
const tenant = yield* CurrentTenant.Context
return yield* analytics.analytics(tenant.orgId, query)
}),
)
.handle("listReviews", ({ query }) =>
Effect.gen(function* () {
const tenant = yield* CurrentTenant.Context
return yield* analytics.listReviews(tenant.orgId, query)
}),
)
.handle("getReview", ({ params }) =>
Effect.gen(function* () {
const tenant = yield* CurrentTenant.Context
return yield* analytics.getReview(tenant.orgId, params.reviewId)
}),
)
.handle("listFindings", ({ query }) =>
Effect.gen(function* () {
const tenant = yield* CurrentTenant.Context
return yield* analytics.listFindings(tenant.orgId, query)
}),
)
}),
)
2 changes: 2 additions & 0 deletions apps/api/src/runtime/http-graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { V1ErrorBoundaryLive } from "@maple/backend/http/error-boundary"
import { HttpDemoLive } from "@/routes/internal/demo.http"
import { DiscoveryRouter, instanceApiV2, NotFoundRouter } from "@/routes/discovery.http"
import { HttpDigestLive } from "@/routes/internal/digest.http"
import { HttpCodeReviewLive } from "@/routes/v1/code-review.http"
import { HttpErrorsLive } from "@/routes/v1/errors.http"
import { HttpIntegrationsLive, IntegrationsCallbackRouter } from "@/routes/v1/integrations.http"
import { OAuthDiscoveryRouter } from "@/routes/v1/oauth-discovery.http"
Expand Down Expand Up @@ -110,6 +111,7 @@ const ApiRoutes = HttpApiBuilder.layer(MapleApi).pipe(
Layer.provide(HttpAuthPublicLive),
Layer.provide(HttpAuthLive),
Layer.provide(HttpBillingPublicLive),
Layer.provide(HttpCodeReviewLive),
Layer.provide(HttpErrorsLive),
Layer.provide(HttpIntegrationsLive),
Layer.provide(HttpOrgClickHouseSettingsLive),
Expand Down
2 changes: 2 additions & 0 deletions apps/api/src/runtime/service-graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ import { WarehouseQueryService } from "@maple/backend/services/warehouse/Warehou
import { QueryEngineService } from "@maple/backend/services/warehouse/QueryEngineService"
import { OrgClickHouseSettingsService } from "@maple/backend/services/org/OrgClickHouseSettingsService"
import { VcsSourceService } from "@maple/backend/services/integrations/vcs/VcsSourceService"
import { PrReviewAnalyticsService } from "@maple/backend/services/pr-review/PrReviewAnalyticsService"

/** Services consumed by HTTP routes; each service owns its implementation dependencies. */
export const HttpServicesLive = Layer.mergeAll(
Expand Down Expand Up @@ -132,6 +133,7 @@ export const HttpServicesLive = Layer.mergeAll(
WebAnalyticsDigestService.layer,
DemoService.layer,
GithubConnectService.layer,
PrReviewAnalyticsService.layer,
VcsCommitService.layer,
VcsSourceService.layer,
ChatWorkspaceService.layer,
Expand Down
22 changes: 22 additions & 0 deletions apps/web/src/components/code-review/author-avatar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Avatar, AvatarFallback, AvatarImage } from "@maple/ui/components/ui/avatar"
import { cn } from "@maple/ui/lib/utils"

/** A GitHub login's avatar, from GitHub's public `<login>.png` redirect; the initial while it loads. */
export function AuthorAvatar({ login, className }: { login: string; className?: string }) {
return (
<Avatar className={cn("size-[18px] text-[9px]", className)}>
<AvatarImage src={`https://github.com/${encodeURIComponent(login)}.png?size=64`} alt="" />
<AvatarFallback>{login.slice(0, 1).toUpperCase()}</AvatarFallback>
</Avatar>
)
}

/** Avatar and login on one line, the way an author is shown everywhere in Code Review. */
export function AuthorLabel({ login, className }: { login: string; className?: string }) {
return (
<span className={cn("inline-flex min-w-0 items-center gap-1.5", className)}>
<AuthorAvatar login={login} />
<span className="truncate">{login}</span>
</span>
)
}
Loading
Loading