GetStream - aggregated-feed time ordered - getstream-io

I have created a setup with GetStream, where i have some flat-feeds that contains data and an aggregated-feed that follows the flat-feeds.
I'm now uploading data to the flat-feeds from my database, with my own timestamp added to the activity. Which make my flat-feed ordered by time.
Here is my problem: When i'm following the flat-feeds with my aggregated-feed, the aggregated-feed seems to be sorted by last updated activity. Which i want to be sorted by my timestamp.
My question: Is i possible to sort the aggregated-feed by my own timestamp?

Stream aggregated feeds are sorted by the updated_at field of the aggregated activity.
At the moment there is no way to change this behaviour.
You can sort the activity groups on the client side before presenting the data to users.
Default aggregation format for aggregated feeds is {{ verb }}_{{ time.strftime('%Y-%m-%d') }}
You can change your aggregation format to {{ <name-of-your-custom-timestamp-field> }} and sort aggregated feed content retrieval results on group attribute.

Thanks for responding.
My solution on this problem was to sort the lists, before i uploaded them to GetStream.
But i still see a potential issue, if i have to upload "older" items later on...

Related

How to get #servestamp firestore after add new Document

I add some data to firestore which contain #serverstamp, but after I add data , I need to get #serverstamp for other progress
If you're using server side generated timestamps you'll need to query the created document to read the actual timestamp value. Nonetheless, if you need the timestamp maybe it would be more practical to generate the timestamp client side, so the document read isn't needed.

get all docs from couchDB updated in a specific time range

I would like to get all the docs in couchDb updated in a specific time range.
I'm using the below API but I don't get any result.
/_all_docs?startkey="2019-01-01T00:00:00Z"&endkey="2020-01-01T00:00:00Z"
Any suggestions are welcome.
Andrea
_all_docs's key is the document ID, not timestamp. For your query to be useful, you'll need to create a custom view based on a timestamp (and ensure the timestamp is updated by your code).

BigQuery - How to paginate over result

I have the following problem:
We have a table (partitioned by timestamp) that saves data from IoT devices (a lot of data, the expected ratio for new incoming data is about every 30sec each device).
The problem is that we will serving a query service and users can set a "since" and "until" filters over a "ts" field (the timestamp), but I want to paginate the results by 10,20,... (wherever the user sets "pageSize").
How I can do this? since saving the whole result in a temp table (and using Tabledata.list API) is not an option 'cause I would have a temp table for each different request (different in terms of filters...)
Thanks in advance!!!
For Nodejs the library automatically paginates using the token from previous request for you as described here https://cloud.google.com/bigquery/docs/paging-results#bigquery-paging-nodejs
on the other hand you have some options for manual pagination if you read the implementation code here: https://github.com/googleapis/nodejs-bigquery/blob/master/src/index.ts

How to get last created document in couchdb?

How can I get last created document in couchdb? Maybe some how I can use _changes feature of couchdb? But documentation says, that I only can get list of document, ordered by first created document, ant there is no way to change order.
So how can I get last created document?
You can get the changes feed in descending order as it's also a view.
GET /dbname/_changes?descending=true
You can use limit= as well, so;
GET /dbname/_changes?descending=true&limit=1
will give the latest update.
Your only surefire way to get the last created document is to include a timestamp (created_at or something) with your document. From there, you just need a simple view to output all the docs by their creation date.
I was going to suggest using the last_seq information from the database, but the sequence number changes with every single write, and replication also complicates the matter further.

CouchDB views - Multiple join... Can it be done?

I have three document types MainCategory, Category, SubCategory... each have a parentid which relates to the id of their parent document.
So I want to set up a view so that I can get a list of SubCategories which sit under the MainCategory (preferably just using a map function)... I haven't found a way to arrange the view so this is possible.
I currently have set up a view which gets the following output -
{"total_rows":16,"offset":0,"rows":[
{"id":"11098","key":["22056",0,"11098"],"value":"MainCat...."},
{"id":"11098","key":["22056",1,"11098"],"value":"Cat...."},
{"id":"33610","key":["22056",2,"null"],"value":"SubCat...."},
{"id":"33989","key":["22056",2,"null"],"value":"SubCat...."},
{"id":"11810","key":["22245",0,"11810"],"value":"MainCat...."},
{"id":"11810","key":["22245",1,"11810"],"value":"Cat...."},
{"id":"33106","key":["22245",2,"null"],"value":"SubCat...."},
{"id":"33321","key":["22245",2,"null"],"value":"SubCat...."},
{"id":"11098","key":["22479",0,"11098"],"value":"MainCat...."},
{"id":"11098","key":["22479",1,"11098"],"value":"Cat...."},
{"id":"11810","key":["22945",0,"11810"],"value":"MainCat...."},
{"id":"11810","key":["22945",1,"11810"],"value":"Cat...."},
{"id":"33123","key":["22945",2,"null"],"value":"SubCat...."},
{"id":"33453","key":["22945",2,"null"],"value":"SubCat...."},
{"id":"33667","key":["22945",2,"null"],"value":"SubCat...."},
{"id":"33987","key":["22945",2,"null"],"value":"SubCat...."}
]}
Which QueryString parameters would I use to get say the rows which have a key that starts with ["22945".... When all I have (at query time) is the id "11810" (at query time I don't have knowledge of the id "22945").
If any of that makes sense.
Thanks
The way you store your categories seems to be suboptimal for the query you try to perform on it.
MongoDB.org has a page on various strategies to implement tree-structures (they should apply to Couch and other doc dbs as well) - you should consider Array of Ancestors, where you always store the full path to your node. This makes updating/moving categories more difficult, but querying is easy and fast.

Resources