Skip to content

Commit

Permalink
Merge pull request #982 from hmrc/BDOG-3328
Browse files Browse the repository at this point in the history
BDOG-3328 Tweak Test job page ui
  • Loading branch information
colin-lamed authored Dec 27, 2024
2 parents 2cbbeca + ee40b9f commit 399ee44
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
14 changes: 10 additions & 4 deletions app/uk/gov/hmrc/cataloguefrontend/search/SearchIndex.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import uk.gov.hmrc.cataloguefrontend.leakdetection.routes as leakRoutes
import uk.gov.hmrc.cataloguefrontend.model.{Environment, ServiceName}
import uk.gov.hmrc.cataloguefrontend.prcommenter.{PrCommenterConnector, routes as prcommenterRoutes}
import uk.gov.hmrc.cataloguefrontend.repository.routes as reposRoutes
import uk.gov.hmrc.cataloguefrontend.search.SearchIndex.{normalizeTerm, optimizeIndex}
import uk.gov.hmrc.cataloguefrontend.serviceconfigs.routes as serviceConfigsRoutes
import uk.gov.hmrc.cataloguefrontend.servicecommissioningstatus.routes as commissioningRoutes
import uk.gov.hmrc.cataloguefrontend.shuttering.{ShutterType, routes as shutterRoutes}
Expand All @@ -48,10 +47,10 @@ case class SearchTerm(
link : String,
weight : Float = 0.5f,
hints : Set[String] = Set.empty,
openInNewWindow: Boolean = false
openInNewWindow: Boolean = false
):
lazy val terms: Set[String] =
Set(name, linkType).union(hints).map(normalizeTerm)
Set(name, linkType).union(hints).map(SearchIndex.normalizeTerm)

@Singleton
class SearchIndex @Inject()(
Expand All @@ -61,6 +60,8 @@ class SearchIndex @Inject()(
userManagementConnector : UserManagementConnector
)(using ExecutionContext):

import SearchIndex.*

private[search] val cachedIndex =
AtomicReference[Map[String, Seq[SearchTerm]]](Map.empty)

Expand Down Expand Up @@ -95,7 +96,7 @@ class SearchIndex @Inject()(
teams <- teamsAndRepositoriesConnector.allTeams()
teamPageLinks = teams.flatMap(t => List(SearchTerm("teams", t.name.asString, teamRoutes.TeamsController.team(t.name).url, 0.5f),
SearchTerm("deployments", t.name.asString, s"${wrwRoutes.WhatsRunningWhereController.releases().url}?profile_type=team&profile_name=${URLEncoder.encode(t.name.asString, "UTF-8")}")))
repoLinks = repos.flatMap(r => List(SearchTerm(r.repoType.asString, r.name, catalogueRoutes.CatalogueController.repository(r.name).url, 0.5f, Set("repository")),
repoLinks = repos.flatMap(r => List(SearchTerm(repoTypeString(r.repoType), r.name, catalogueRoutes.CatalogueController.repository(r.name).url, 0.5f, Set("repository")),
SearchTerm("health", r.name, healthRoutes.HealthIndicatorsController.breakdownForRepo(r.name).url),
SearchTerm("leak", r.name, leakRoutes.LeakDetectionController.branchSummaries(r.name).url, 0.5f)))
serviceLinks = repos.filter(_.repoType == RepoType.Service)
Expand All @@ -122,6 +123,11 @@ object SearchIndex:
def normalizeTerm(term: String): String =
term.toLowerCase.replaceAll(" -_", "")

private[search] def repoTypeString(repoType: RepoType): String =
repoType match
case RepoType.Other => "Repository"
case _ => repoType.asString

private[search] def search(
query: Seq[String],
index: Map[String, Seq[SearchTerm]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h1 class="page-heading mt-4">Teams</h1>

<div id="teams-list">
<div class="row">
<form action="@teamsRoutes.TeamsController.allTeams" method="get">
<form action="@teamsRoutes.TeamsController.allTeams()" method="get">
<div class="row mb-3">
<label for="search" class="col-1 col-form-label fw-bold">Team:</label>
<div class="col-5">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ <h1 class="page-heading mt-4">Test Results</h1>
<th class="col-lg-4">
<button role="button" class="fw-bold sort no-border" data-sort="last-run">Last run</button>
</th>
<th class="visually-hidden"></td>
<th class="col-lg-1">
<button role="button" class="fw-bold sort no-border" data-sort="result">Result</button>
</th>
Expand All @@ -103,9 +104,12 @@ <h1 class="page-heading mt-4">Test Results</h1>
<td class="test-type" id="row@{i}_test_type">
@testJob.testType.fold("")(_.asString)
</td>
<td class="last-run" id="row@{i}_last_run">
<td class="font-monospace" id="row@{i}_last_run">
@testJob.latestBuild.fold("")(_.timestamp.displayFormat)
</td>
<td class="last-run visually-hidden" id="row@{i}_last_run_epochsecond">
@testJob.latestBuild.fold("")(_.timestamp.getEpochSecond)
</td>
<td class="result" id="row@{i}_result">
@defining(testJob.latestBuild.flatMap(_.result).getOrElse("NOT BUILT")){ result =>
@defining(result match {
Expand All @@ -118,10 +122,10 @@ <h1 class="page-heading mt-4">Test Results</h1>
}
}
</td>
<td class="accessibility" id="row@{i}_accessibility">
<td class="accessibility text-end pe-5" id="row@{i}_accessibility">
@testJob.latestBuild.flatMap(_.testJobResults).fold("")(_.numAccessibilityViolations)
</td>
<td class="security" id="row@{i}_security">
<td class="security text-end pe-5" id="row@{i}_security">
@testJob.latestBuild.flatMap(_.testJobResults).fold("")(_.numSecurityAlerts)
</td>
</tr>
Expand Down

0 comments on commit 399ee44

Please sign in to comment.