generated from coulomb/repo-seed
fix(WP-0014): pre-flight compilation fixes, Tailwind pipeline, and admin seed
A2 — Compilation fixes: - Remove inline FK constraints from Schema.sql; IHP schema compiler cannot parse them. Add 1744329600-restore-fk-constraints.sql migration to restore referential integrity at the DB level. - Rename `#label` → `#label_` throughout to avoid clash with Haskell built-in. - Fix `hub.id == hid` UUID comparisons to use `toUUID hub.id`. - Replace non-existent `setStatus`/`respondJson` calls with `renderJsonWithStatusCode` throughout Api controllers. - Fix qualified package import for `cryptohash-sha256` in Auth.hs. - Add `CanSelect (Text, Text)` instance in Helper.View. - Refactor HSX inline lambdas to named helper functions in 100+ views (GHC cannot infer types for anonymous functions inside quasi-quoted HSX). - Fix missing imports (IHP.QueryBuilder, IHP.Fetch, Web.Routes, Only, etc.) across helpers and controllers. - Remove duplicate `diffUTCTime` definition in BottleneckDetector. - Change `createEventForHub` return type from `IO ResponseReceived` to `IO ()`. - Seed type-registry vocabulary via 1744502400-seed-type-registries.sql (moved from Schema.sql where IHP does not execute INSERT statements). A3 — Tailwind build pipeline: - Add `tailwindcss` to flake.nix native packages. - Uncomment `tailwind.exec` process in devenv shell config. - Add tailwind/tailwind.config.js (scans Web/View/**/*.hs). - Add tailwind/app.css with @tailwind directives. A4 — Admin user seed: - Add 1744416000-seed-admin-user.sql: inserts admin@inter-hub.local with bcrypt-hashed password admin1234! (cost 10). - Add .env.example documenting all required environment variables and default admin credentials. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
module Web.View.LearningDashboard.Show where
|
||||
|
||||
import Web.View.Prelude
|
||||
import IHP.ViewPrelude
|
||||
import Data.Time (diffUTCTime, getCurrentTime, nominalDay)
|
||||
|
||||
data ShowView = ShowView
|
||||
@@ -21,25 +21,13 @@ instance View ShowView where
|
||||
{-- Panel 1: Top annotation predictors --}
|
||||
<div class="bg-white shadow rounded-lg p-5">
|
||||
<h2 class="text-base font-semibold text-gray-800 mb-4">Top Annotation Predictors</h2>
|
||||
{if null topCorrelations
|
||||
then [hsx|<p class="text-sm text-gray-400">No data — run correlation analysis per hub.</p>|]
|
||||
else [hsx|
|
||||
<div class="space-y-2">
|
||||
{forM_ topCorrelations renderCorrelation}
|
||||
</div>
|
||||
|]}
|
||||
{renderCorrelationsSection topCorrelations}
|
||||
</div>
|
||||
|
||||
{-- Panel 2: Pattern performance ranking --}
|
||||
<div class="bg-white shadow rounded-lg p-5">
|
||||
<h2 class="text-base font-semibold text-gray-800 mb-4">Pattern Performance Ranking</h2>
|
||||
{if null patternRankings
|
||||
then [hsx|<p class="text-sm text-gray-400">No data — run pattern performance per hub.</p>|]
|
||||
else [hsx|
|
||||
<div class="space-y-2">
|
||||
{forM_ patternRankings renderPatternRank}
|
||||
</div>
|
||||
|]}
|
||||
{renderPatternRankingsSection patternRankings}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -57,95 +45,121 @@ instance View ShowView where
|
||||
{-- Panel 4: Recent learning insights --}
|
||||
<div class="bg-white shadow rounded-lg p-5">
|
||||
<h2 class="text-base font-semibold text-gray-800 mb-4">Recent Insights</h2>
|
||||
{if null recentInsights
|
||||
then [hsx|<p class="text-sm text-gray-400">No insights yet.</p>|]
|
||||
else [hsx|
|
||||
<div class="space-y-3">
|
||||
{forM_ recentInsights renderInsight}
|
||||
</div>
|
||||
|]}
|
||||
{renderInsightsSection recentInsights}
|
||||
</div>
|
||||
|
||||
{-- Panel 5: Knowledge base highlights --}
|
||||
<div class="bg-white shadow rounded-lg p-5">
|
||||
<h2 class="text-base font-semibold text-gray-800 mb-4">Knowledge Highlights</h2>
|
||||
{if null knowledgeHighlights
|
||||
then [hsx|<p class="text-sm text-gray-400">No entries yet — distil a decision.</p>|]
|
||||
else [hsx|
|
||||
<div class="space-y-3">
|
||||
{forM_ knowledgeHighlights renderKnowledge}
|
||||
</div>
|
||||
|]}
|
||||
{renderKnowledgeSection knowledgeHighlights}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|]
|
||||
where
|
||||
renderCorrelation c = [hsx|
|
||||
<div class="flex items-center gap-3">
|
||||
<span class="text-sm text-gray-700 w-32 truncate">{c.annotationCategory}</span>
|
||||
<div class="flex-1 bg-gray-200 rounded-full h-2">
|
||||
<div class={barColor c.correlationScore}
|
||||
style={"width:" <> show (round (c.correlationScore * 100) :: Int) <> "%"}></div>
|
||||
</div>
|
||||
<span class="text-xs text-gray-500">{show (round (c.correlationScore * 100) :: Int)}%</span>
|
||||
</div>
|
||||
|]
|
||||
renderCorrelationsSection :: [OutcomeCorrelation] -> Html
|
||||
renderCorrelationsSection [] = [hsx|<p class="text-sm text-gray-400">No data — run correlation analysis per hub.</p>|]
|
||||
renderCorrelationsSection cs = [hsx|
|
||||
<div class="space-y-2">
|
||||
{forEach cs renderCorrelation}
|
||||
</div>
|
||||
|]
|
||||
|
||||
barColor s
|
||||
| s >= 0.7 = "h-2 rounded-full bg-green-500" :: Text
|
||||
| s >= 0.4 = "h-2 rounded-full bg-yellow-500"
|
||||
| otherwise = "h-2 rounded-full bg-red-400"
|
||||
renderPatternRankingsSection :: [PatternPerformanceRecord] -> Html
|
||||
renderPatternRankingsSection [] = [hsx|<p class="text-sm text-gray-400">No data — run pattern performance per hub.</p>|]
|
||||
renderPatternRankingsSection rs = [hsx|
|
||||
<div class="space-y-2">
|
||||
{forEach rs renderPatternRank}
|
||||
</div>
|
||||
|]
|
||||
|
||||
renderPatternRank r =
|
||||
let rate = if r.totalOutcomeCount > 0
|
||||
then fromIntegral r.positiveOutcomeCount / fromIntegral r.totalOutcomeCount :: Double
|
||||
else 0.0
|
||||
in [hsx|
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="text-xs text-gray-400 w-5">{maybe "-" show r.outcomeRank}</span>
|
||||
<a href={ShowWidgetPatternAction { widgetPatternId = r.widgetPatternId }}
|
||||
class="text-sm text-blue-600 hover:underline truncate flex-1">
|
||||
{show r.widgetPatternId}
|
||||
</a>
|
||||
<span class="text-xs text-gray-500">{show (round (rate * 100) :: Int)}%</span>
|
||||
</div>
|
||||
|]
|
||||
renderInsightsSection :: [LearningInsight] -> Html
|
||||
renderInsightsSection [] = [hsx|<p class="text-sm text-gray-400">No insights yet.</p>|]
|
||||
renderInsightsSection is = [hsx|
|
||||
<div class="space-y-3">
|
||||
{forEach is renderInsight}
|
||||
</div>
|
||||
|]
|
||||
|
||||
renderThresholdStatus (h, mCfg) =
|
||||
let driftClass = case mCfg of
|
||||
Nothing -> "text-red-500" :: Text
|
||||
Just cfg -> "text-green-600"
|
||||
label = case mCfg of
|
||||
Nothing -> "Not calibrated"
|
||||
Just cfg -> "Calibrated"
|
||||
in [hsx|
|
||||
<div class="flex justify-between text-sm">
|
||||
<span class="text-gray-700">{h.name}</span>
|
||||
<span class={driftClass}>{label}</span>
|
||||
</div>
|
||||
|]
|
||||
renderKnowledgeSection :: [InstitutionalKnowledgeEntry] -> Html
|
||||
renderKnowledgeSection [] = [hsx|<p class="text-sm text-gray-400">No entries yet — distil a decision.</p>|]
|
||||
renderKnowledgeSection es = [hsx|
|
||||
<div class="space-y-3">
|
||||
{forEach es renderKnowledge}
|
||||
</div>
|
||||
|]
|
||||
|
||||
renderInsight i = [hsx|
|
||||
<div class="border-l-4 border-indigo-400 pl-3">
|
||||
<p class="text-xs font-medium text-gray-700">{i.title}</p>
|
||||
<p class="text-xs text-gray-400">{insightTypeBadge i.insightType}</p>
|
||||
</div>
|
||||
|]
|
||||
renderCorrelation :: OutcomeCorrelation -> Html
|
||||
renderCorrelation c = [hsx|
|
||||
<div class="flex items-center gap-3">
|
||||
<span class="text-sm text-gray-700 w-32 truncate">{c.annotationCategory}</span>
|
||||
<div class="flex-1 bg-gray-200 rounded-full h-2">
|
||||
<div class={barColor c.correlationScore}
|
||||
style={"width:" <> show (round (c.correlationScore * 100) :: Int) <> "%"}></div>
|
||||
</div>
|
||||
<span class="text-xs text-gray-500">{show (round (c.correlationScore * 100) :: Int)}%</span>
|
||||
</div>
|
||||
|]
|
||||
|
||||
insightTypeBadge t = case t of
|
||||
"annotation_predictor" -> "Annotation predictor" :: Text
|
||||
"threshold_calibration" -> "Threshold calibration"
|
||||
"pattern_ranking" -> "Pattern ranking"
|
||||
"routing_improvement" -> "Routing improvement"
|
||||
_ -> t
|
||||
barColor :: Double -> Text
|
||||
barColor s
|
||||
| s >= 0.7 = "h-2 rounded-full bg-green-500"
|
||||
| s >= 0.4 = "h-2 rounded-full bg-yellow-500"
|
||||
| otherwise = "h-2 rounded-full bg-red-400"
|
||||
|
||||
renderKnowledge e = [hsx|
|
||||
<div>
|
||||
<a href={ShowInstitutionalKnowledgeAction { knowledgeEntryId = e.id }}
|
||||
class="text-sm text-blue-600 hover:underline">
|
||||
{take 80 e.summary <> if length e.summary > 80 then "…" else ""}
|
||||
</a>
|
||||
</div>
|
||||
|]
|
||||
renderPatternRank :: PatternPerformanceRecord -> Html
|
||||
renderPatternRank r =
|
||||
let rate = if r.totalOutcomeCount > 0
|
||||
then fromIntegral r.positiveOutcomeCount / fromIntegral r.totalOutcomeCount :: Double
|
||||
else 0.0
|
||||
in [hsx|
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="text-xs text-gray-400 w-5">{maybe "-" show r.outcomeRank}</span>
|
||||
<a href={ShowWidgetPatternAction (r.widgetPatternId)}
|
||||
class="text-sm text-blue-600 hover:underline truncate flex-1">
|
||||
{show r.widgetPatternId}
|
||||
</a>
|
||||
<span class="text-xs text-gray-500">{show (round (rate * 100) :: Int)}%</span>
|
||||
</div>
|
||||
|]
|
||||
|
||||
renderThresholdStatus :: (Hub, Maybe AdaptiveThresholdConfig) -> Html
|
||||
renderThresholdStatus (h, mCfg) =
|
||||
let driftClass = case mCfg of
|
||||
Nothing -> "text-red-500" :: Text
|
||||
Just _ -> "text-green-600"
|
||||
label = case mCfg of
|
||||
Nothing -> "Not calibrated" :: Text
|
||||
Just _ -> "Calibrated"
|
||||
in [hsx|
|
||||
<div class="flex justify-between text-sm">
|
||||
<span class="text-gray-700">{h.name}</span>
|
||||
<span class={driftClass}>{label}</span>
|
||||
</div>
|
||||
|]
|
||||
|
||||
renderInsight :: LearningInsight -> Html
|
||||
renderInsight i = [hsx|
|
||||
<div class="border-l-4 border-indigo-400 pl-3">
|
||||
<p class="text-xs font-medium text-gray-700">{i.title}</p>
|
||||
<p class="text-xs text-gray-400">{insightTypeBadge i.insightType}</p>
|
||||
</div>
|
||||
|]
|
||||
|
||||
insightTypeBadge :: Text -> Text
|
||||
insightTypeBadge t = case t of
|
||||
"annotation_predictor" -> "Annotation predictor"
|
||||
"threshold_calibration" -> "Threshold calibration"
|
||||
"pattern_ranking" -> "Pattern ranking"
|
||||
"routing_improvement" -> "Routing improvement"
|
||||
_ -> t
|
||||
|
||||
renderKnowledge :: InstitutionalKnowledgeEntry -> Html
|
||||
renderKnowledge e = [hsx|
|
||||
<div>
|
||||
<a href={ShowInstitutionalKnowledgeAction (e.id)}
|
||||
class="text-sm text-blue-600 hover:underline">
|
||||
{take 80 e.summary <> if length e.summary > 80 then "…" else ""}
|
||||
</a>
|
||||
</div>
|
||||
|]
|
||||
|
||||
Reference in New Issue
Block a user