Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Sorting/Ordering reports by timestamp in Mongo is not working #1197

Open
Velcrow81 opened this issue Sep 4, 2019 · 1 comment
Open

Sorting/Ordering reports by timestamp in Mongo is not working #1197

Velcrow81 opened this issue Sep 4, 2019 · 1 comment
Projects

Comments

@Velcrow81
Copy link
Collaborator

Velcrow81 commented Sep 4, 2019

In reporting, it is not possible to order by date (timestamp) in an acending order. Only decending. Below is an example of reports ordered by timestamp ascending:
image

The same problem occurs if we run queries directly against Mongo in Studio 3T:
image

I got the timestamp from the top 5 documents and they have the same problem as in the frontend. Descending works but ascending is apparently random:

Ascending
637013082263970000
637012111923990000
637012506804020000
637019928394040000
637020792304050000

Descending
637041960614550000
637039299834670000
637035012714420000
637034735494500000
637033988174520000

The timestamp is stored as an array and that might be causing problems for the sorting, but I do not know why descending is working

Timestamp" : [
        637013082263970000, 
        0
    ]

Sorting should work on timestamp for both descending and ascending order

@Velcrow81 Velcrow81 created this issue from a note in Reporting (Ready for Implementation) Sep 4, 2019
@Velcrow81 Velcrow81 changed the title Sorting/Ordering by timestamp in Mongo is not working Sorting/Ordering reports by timestamp in Mongo is not working Sep 4, 2019
@gardnk
Copy link
Collaborator

gardnk commented Sep 5, 2019

From MongoDB docs:

With arrays, a less-than comparison or an ascending sort compares the smallest element of arrays, and a greater-than comparison or a descending sort compares the largest element of the arrays.

So the ascending sort doesn't work because the smallest element of the array is always 0 in this case.

MongoDB has it's own Timestamp type, but our timestamp is stored as an array of NumberLong.
My guess is this needs a fix from the dolittle framework @woksin @jakhog ? Or can we specify mongo types ourselves?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Reporting
  
Ready for Implementation
Development

No branches or pull requests

2 participants