<commit_before>package app

import util._
import service._
import jp.sf.amateras.scalatra.forms._

class SearchController extends SearchControllerBase
with RepositoryService with AccountService with SystemSettingsService with ActivityService
with RepositorySearchService with IssuesService
with ReferrerAuthenticator

trait SearchControllerBase extends ControllerBase { self: RepositoryService
  with SystemSettingsService with ActivityService with RepositorySearchService
  with ReferrerAuthenticator =>

  val searchForm = mapping(
    "query"      -> trim(text(required)),
    "owner"      -> trim(text(required)),
    "repository" -> trim(text(required))
  )(SearchForm.apply)

  case class SearchForm(query: String, owner: String, repository: String)

  post("/search", searchForm){ form =>
    redirect(s"${form.owner}/${form.repository}/search?q=${StringUtil.urlEncode(form.query)}")
  }

  get("/:owner/:repository/search")(referrersOnly { repository =>
    val query  = params("q").trim
    val target = params.getOrElse("type", "code")
    val page   = try {
      val i = params.getOrElse("page", "1").toInt
      if(i <= 0) 1 else i
    } catch {
      case e: NumberFormatException => 1
    }

    target.toLowerCase match {
      case "issue" => search.html.issues(
        searchIssues(repository.owner, repository.name, query),
        countFiles(repository.owner, repository.name, query),
        query, page, repository)

      case _ => search.html.code(
        searchFiles(repository.owner, repository.name, query),
        countIssues(repository.owner, repository.name, query),
        query, page, repository)
    }
  })

}
<commit_msg>Bug fix.<commit_after>package app

import util._
import service._
import jp.sf.amateras.scalatra.forms._

class SearchController extends SearchControllerBase
with RepositoryService with AccountService with SystemSettingsService with ActivityService
with RepositorySearchService with IssuesService
with ReferrerAuthenticator

trait SearchControllerBase extends ControllerBase { self: RepositoryService
  with SystemSettingsService with ActivityService with RepositorySearchService
  with ReferrerAuthenticator =>

  val searchForm = mapping(
    "query"      -> trim(text(required)),
    "owner"      -> trim(text(required)),
    "repository" -> trim(text(required))
  )(SearchForm.apply)

  case class SearchForm(query: String, owner: String, repository: String)

  post("/search", searchForm){ form =>
    redirect(s"/${form.owner}/${form.repository}/search?q=${StringUtil.urlEncode(form.query)}")
  }

  get("/:owner/:repository/search")(referrersOnly { repository =>
    val query  = params("q").trim
    val target = params.getOrElse("type", "code")
    val page   = try {
      val i = params.getOrElse("page", "1").toInt
      if(i <= 0) 1 else i
    } catch {
      case e: NumberFormatException => 1
    }

    target.toLowerCase match {
      case "issue" => search.html.issues(
        searchIssues(repository.owner, repository.name, query),
        countFiles(repository.owner, repository.name, query),
        query, page, repository)

      case _ => search.html.code(
        searchFiles(repository.owner, repository.name, query),
        countIssues(repository.owner, repository.name, query),
        query, page, repository)
    }
  })

}

{'fraction_non_alphanumeric': 0.11406155703077851, 'fraction_numerical': 0.0024140012070006035, 'mean_word_length': 3.8323615160349855, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4772749', 'n_tokens_mistral': 931, 'n_tokens_neox': 915, 'n_words': 227}