Skip to content

Commit

Permalink
Sort search by default group sort (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
edemaine committed Nov 21, 2023
1 parent 65e8605 commit 73d27f0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
14 changes: 8 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ instead of version numbers.

* Only cluster by leading tags in the sort order, so if you click to sort by
e.g. Updated then there's no longer awkward clustering by repeated tags.
* Search no longer supports quoting phrases with single quotes, so that it's
easier to search for possessives (e.g. `Erik's`).
[[#638](https://github.com/edemaine/coauthor/issues/638)]
* Fix escaping search queries with backslash: `\:`, `\"`, `\|`, `\(`, `\)`, `\\`
* Newly allow escaping of `*` with `\*`
[[#29](https://github.com/edemaine/coauthor/issues/29)]
* Search improvements: [[#29](https://github.com/edemaine/coauthor/issues/29)]
* Search no longer supports quoting phrases with single quotes, so that it's
easier to search for possessives (e.g. `Erik's`).
[[#638](https://github.com/edemaine/coauthor/issues/638)]
* Search now sorts by the group's default sort, instead of by title.
* Fix escaping search queries with backslash:
`\:`, `\"`, `\|`, `\(`, `\)`, `\\`
* Newly allow escaping of `*` with `\*`

## 2023-11-17

Expand Down
16 changes: 9 additions & 7 deletions client/search.coffee
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {groupDefaultSort} from '/lib/groups'
import {findMessageRoot, messagesSortedBy} from '/lib/messages'
import {formatSearch, parseSearch} from '/lib/search'

Template.search.onCreated ->
Expand All @@ -18,13 +20,13 @@ topMessagesSearch = (group, search) ->
msgs = messagesSearch group, search
return [] unless msgs?
msgs = msgs.fetch()
## xxx should use default sort, not title sort?
msgs = _.sortBy msgs, (msg) ->
msg.group + '/' +
if msg.root
titleSort (Messages.findOne(msg.root)?.title ? '')
else
titleSort msg.title
## Least significant: sort by group's default sort order --
## applying sort to message root, not the message
msgs = messagesSortedBy msgs, groupDefaultSort(group), findMessageRoot
## Middle significant: sort roots before their descendants
msgs = _.sortBy msgs, (msg) -> msg.root?
## Most significant: sort by group name
msgs = _.sortBy msgs, 'group'
## Form a set of all message IDs in match
byId = {}
for msg in msgs
Expand Down

0 comments on commit 73d27f0

Please sign in to comment.