linagora / james-project

Mirror of Apache James Project
Apache License 2.0
72 stars 62 forks source link

Email/query Support sort by ReceivedAt #3712

Closed remk closed 4 years ago

remk commented 4 years ago

Why

With the new specification, The following value for the property field on the Comparator object MUST be supported for sorting:

receivedAt - The receivedAt date as returned in the Email object.

As an user, i want to be able to sort my emails by reception date.

HOW

sort: Comparator[]|null Lists the names of properties to compare between two Foo records, and how to compare them, to determine which comes first in the sort. If two Foo records have an identical value for the first comparator, the next comparator will be considered, and so on. If all comparators are the same (this includes the case where an empty array or null is given as the sort argument), the sort order is server dependent, but it MUST be stable between calls to Foo/query.

A Comparator has the following properties:

    property: String The name of the property on the Foo objects to compare.
    isAscending: Boolean (optional; default: true) If true, sort in ascending order. If false, reverse the comparator’s results to sort in descending order.

    collation: String (optional; default is server dependent) The identifier, as registered in the collation registry defined in [@!RFC4790], for the algorithm to use when comparing the order of strings. The algorithms the server supports are advertised in the capabilities object returned with the Session object (see Section 2).

    If omitted, the default algorithm is server-dependent, but:
        It MUST be unicode-aware.
        It MAY be selected based on an Accept-Language header in the request (as defined in [@!RFC7231], Section 5.3.5), or out-of-band information about the user’s language/locale.
        It SHOULD be case insensitive where such a concept makes sense for a language/locale. Where the user’s language is unknown, it is RECOMMENDED to follow the advice in Section 5.2.3 of [@!RFC8264].

    The “i;unicode-casemap” collation [@!RFC5051] and the Unicode Collation Algorithm (http://www.unicode.org/reports/tr10/) are two examples that fulfil these criterion and provide reasonable behaviour for a large number of languages.

    When the property being compared is not a string, the collation property is ignored, and the following comparison rules apply based on the type. In ascending order:
        Boolean: false comes before true.
        Number: A lower number comes before a higher number.
        Date/UTCDate: The earlier date comes first.

The Comparator object may also have additional properties as required for specific sort operations defined in a type’s /query method.

DOD

nvduc91 commented 4 years ago

https://issues.apache.org/jira/browse/JAMES-3374

chibenwa commented 4 years ago

IMO we should not create a JIRA ticket for each of the thirty-ish JIRA tickets regarding sorting.

We should have a meta-ticket for it.

nvduc91 commented 4 years ago

ok, if we already had one i will remove it or edit.