generated from coulomb/repo-seed
Convert all remaining `<- paramOrNothing / param / paramOrDefault /
currentUserOrNothing` monadic binds to `let` — these functions are pure
(ImplicitParams-based) in IHP v1.5, so `<-` is a type error in an IO
do-block.
Controllers fixed:
AgentDelegations, AiGovernancePolicies, Annotations, ApiConsumers,
CollectiveProposals, DecisionRecords, DeploymentRecords,
HubCapabilityManifests, HubRoutingRules, InstitutionalKnowledge,
OutcomeCorrelations, RequirementCandidates, TypeRegistries,
WebhookSubscriptions, Widgets,
Api/V2/{Annotations,InteractionEvents,Token}
WebhookSubscriptions: remove orphaned `Right () ->` case arm that was
left inside a bare `unless` block (structural parse error).
Also carries forward all in-progress fixes from the working tree:
helpers (AgentBridge, ApiRateLimit, BottleneckDetector,
CrossHubPropagation, FrictionScore),
views (CanSelect instances, HSX lambda extraction, formFor wrappers),
env/build (envrc GHCi perms, flake.nix Tailwind + GHC resource limits,
static/app.css additional Tailwind output).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
53 lines
2.0 KiB
Haskell
53 lines
2.0 KiB
Haskell
module Web.Controller.InstitutionalKnowledge where
|
|
|
|
-- IHF Phase 12 — Platform Memory (IHUB-WP-0013 T05)
|
|
|
|
import Web.Types
|
|
import Generated.Types
|
|
import IHP.Prelude
|
|
import IHP.ControllerPrelude
|
|
import Web.View.InstitutionalKnowledge.Index
|
|
import Web.View.InstitutionalKnowledge.Show
|
|
import IHP.ModelSupport (sqlQuery)
|
|
|
|
instance Controller InstitutionalKnowledgeController where
|
|
beforeAction = ensureIsUser
|
|
|
|
action InstitutionalKnowledgeAction = do
|
|
entries <- query @InstitutionalKnowledgeEntry
|
|
|> orderByDesc #createdAt
|
|
|> limit 50
|
|
|> fetch
|
|
hubs <- query @Hub |> fetch
|
|
render IndexView { entries, hubs, mQuery = Nothing }
|
|
|
|
action ShowInstitutionalKnowledgeAction { knowledgeEntryId } = do
|
|
entry <- fetch knowledgeEntryId
|
|
hub <- fetch entry.hubId
|
|
mDecision <- case entry.decisionRecordId of
|
|
Nothing -> pure Nothing
|
|
Just did -> fetchOneOrNothing did
|
|
render ShowView { entry, hub, mDecision }
|
|
|
|
action QueryKnowledgeBaseAction = do
|
|
let q = param @Text "q"
|
|
mHubStr = paramOrNothing @Text "hubId"
|
|
hubs <- query @Hub |> fetch
|
|
entries <- case mHubStr of
|
|
Nothing ->
|
|
sqlQuery
|
|
"SELECT * FROM institutional_knowledge_entries \
|
|
\ WHERE summary_tsv @@ plainto_tsquery('english', ?) \
|
|
\ ORDER BY ts_rank(summary_tsv, plainto_tsquery('english', ?)) DESC \
|
|
\ LIMIT 20"
|
|
(q, q)
|
|
Just hid ->
|
|
sqlQuery
|
|
"SELECT * FROM institutional_knowledge_entries \
|
|
\ WHERE hub_id = ? \
|
|
\ AND summary_tsv @@ plainto_tsquery('english', ?) \
|
|
\ ORDER BY ts_rank(summary_tsv, plainto_tsquery('english', ?)) DESC \
|
|
\ LIMIT 20"
|
|
(hid, q, q)
|
|
render IndexView { entries, hubs, mQuery = Just q }
|