Skip to content

Commit 8561721

Browse files
authored
Prepare for v0.0.5 (#23)
Fix type search results ordering for BrowserEngine
1 parent 480f3bd commit 8561721

File tree

5 files changed

+19
-20
lines changed

5 files changed

+19
-20
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [Unreleased]
8+
## [0.0.5 - 2019-09-21]
99

1010
New features:
1111
- Render docs as markdown (#15)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "purescript-docs-search",
3-
"version": "0.0.4",
3+
"version": "0.0.5",
44
"description": "Search frontend for the documentation generated by the PureScript compiler.",
55
"directories": {
66
"test": "test"

src/Docs/Search/Engine.purs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module Docs.Search.Engine where
22

33
import Docs.Search.PackageIndex (PackageIndex, PackageResult)
4-
import Docs.Search.SearchResult (SearchResult)
5-
import Docs.Search.TypeQuery (TypeQuery(..), parseTypeQuery)
4+
import Docs.Search.SearchResult (SearchResult, typeOfResult)
5+
import Docs.Search.TypeQuery (TypeQuery(..), parseTypeQuery, penalty)
66

77
import Prelude
88

@@ -95,7 +95,7 @@ query engine state input =
9595

9696
response <- engine.queryTypeIndex state.typeIndex typeQuery
9797

98-
pure { results: response.results <#> TypeResult
98+
pure { results: sortByDistance typeQuery (response.results) <#> TypeResult
9999
, index: state { typeIndex = response.index }
100100
}
101101

@@ -104,3 +104,11 @@ isValuableTypeQuery :: TypeQuery -> Maybe TypeQuery
104104
isValuableTypeQuery (QVar _) = Nothing
105105
isValuableTypeQuery (QConst _) = Nothing
106106
isValuableTypeQuery other = Just other
107+
108+
109+
sortByDistance
110+
:: TypeQuery
111+
-> Array SearchResult
112+
-> Array SearchResult
113+
sortByDistance typeQuery =
114+
Array.sortWith (map (penalty typeQuery) <<< typeOfResult)

src/Docs/Search/Main.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ main = do
2727
case fromMaybe defaultCommands args of
2828
BuildIndex cfg -> IndexBuilder.run cfg
2929
Search cfg -> Interactive.run cfg
30-
Version -> log "0.0.4"
30+
Version -> log "0.0.5"
3131

3232

3333
getArgs :: Effect (Maybe Commands)

src/Docs/Search/NodeEngine.purs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ module Docs.Search.NodeEngine where
33

44
import Docs.Search.Extra (stringToList)
55
import Docs.Search.PackageIndex as PackageIndex
6-
import Docs.Search.Engine (Engine, Query, Index)
7-
import Docs.Search.SearchResult (SearchResult, typeOfResult)
8-
import Docs.Search.TypeQuery (TypeQuery, penalty)
6+
import Docs.Search.Engine (Engine, Query, Index, sortByDistance)
7+
import Docs.Search.SearchResult (SearchResult)
8+
import Docs.Search.TypeQuery (TypeQuery)
99

1010
import Prelude
1111

@@ -41,15 +41,6 @@ queryIndex index input =
4141
queryTypeIndex
4242
:: Query Identity (Array SearchResult) TypeQuery SearchResult
4343
queryTypeIndex index typeQuery =
44-
pure { index, results:
45-
Array.take 100 $
46-
sortByDistance typeQuery index
44+
pure { index
45+
, results: Array.take 100 $ sortByDistance typeQuery index
4746
}
48-
49-
50-
sortByDistance
51-
:: TypeQuery
52-
-> Array SearchResult
53-
-> Array SearchResult
54-
sortByDistance typeQuery =
55-
Array.sortWith (map (penalty typeQuery) <<< typeOfResult)

0 commit comments

Comments
 (0)