Fetching Latest 2 records from Lookback API - rally

We are in situation where We Need to fetch last two records from Lookback API every time .
For the below case, we need the records highlighted in green,
We are doing the incremental fetch using the _ValidFrom Date in Lookback API.
We need last two records so that we can handle the updates happening to _ValidTo whenever new snapshot is created.

You should be able to get that data from just the most recent snapshot can't you? The _ValidFrom of the most recent should be equal to the _ValidTo of the second to last one.

Related

OpenWeatherMap Get data for today

I am trying to create something similar to what the weather apps have which show a graph of the temperatures from today.
I am currently using the onecall endpoint which returns the current weather along with forecasts for the next 48 hours but this doesn't cover my case of showing earlier data from the day.
Am I miss using this endpoint or is there a way to show the data for the current day (both historical from earlier and forecast for later)? Or do I need to use the historical data endpoints?

how do you reverse the data given from a REST API response?

I'm trying to read measurement data, and I get a large amount of data back. I can narrow down the items per page and get the last page, but is there a way to reverse the data so I get the most recent measurement POST?
For example, I to a:
GET: {{url}}/measurement/measurements?dateTo={{dateTo}}&dateFrom={{dateFrom}}&source={{deviceId}}
And I get get 100's of pages back, the list beginning from the first measurement. I want the last measurement first.
I found the answer, add revert=True
i.e.:
{{url}}/measurement/measurements?dateTo={{dateTo}}&dateFrom={{dateFrom}}&source={{deviceId}}&currentPage=1&pageSize=200&revert=True

How to get TeamCity builds statistics for last quarter(3 month) from API or DB(SQL)?

TeamCity issue tracker link https://youtrack.jetbrains.com/issue/TW-50234
I want to calc "builds" latency for last week and compare to avg. last month and avg. last quarter.
last month can be easelly fetch via REST API like so:
https://teamcity/app/rest/builds?locator=buildType:(id:<BUILD_ID>)&fields=count,build(number,status,queuedDate,finishDate)
Latest entrie from payload is 20170502T131511+0300
But how to fetch more data - for last 3 month?
I have access to SQL DB(We use PostgreSQL) and SQL is good solution.
You could come across paginaton of the response: try to include nextHref attribute of the response entity (builds) for items collections (i.e. use &fields=count,nextHref instead of just &fields=count and you'll probably get the link to the second page of the output).
It it is your case, following locator dimensions are available to control the number of the builds in response:
count:<number> - serve only the specified number of builds
start:<number> - list the builds from the list starting from the position specified (zero-based)
lookupLimit:<number> - limit processing to the latest N builds only (the default is 5000). If none of the latest N builds match the other specified criteria of the build locator, 404 response is returned
There should be no limitation of the output based on the date, but in case there're some clean up rules configured, there could be no data, obviously.

How combine data from Redis?

I use sorted sets type in Redis. Each user adds an event to Redis with a score - current timestamp and key: User:ID_USER
How I can get 10 latest events from redis store sorted by score(timestamp)?
For this there is a function ZREVRANGEBYSCORE, but if use it, I get a problem, because not every user have events at last time score.
Edited:
For example, I want to merge some sorted keys by score(timestamp) and selecting the latest data for last 4 hours for each users.
Problem is, that if user did not post data in Redis in this interval(4 hours) then does not show nothing for this user. But I need select latest data sorted by timestamp from each user. Maybe use any function?

Dealing with gaps in timeline

I'm looking for some assistance to sort out the logic for how I am going to deal with gaps in a feed timeline, pretty much like what you would see in various Twitter clients. I am not creating a Twitter client, however, so it won't be specific to that API. I'm using our own API, so I can possibly make some changes to the API as well to accomodate for this.
I'm saving each feed item in Core Data. For persistance, I'd like to keep the feed items around. Let's say I fetch 50 feed items from my server. The next time the user launches the app, I do a request for the latest feed items and I am returned with 50 feed items and do a fetch to display the feed items in a table view.
Enough time may have passed between the two server requests that a time gap exists between the two sets of feed items.
50 new feed items (request 2)
----- gap ------
50 older feed items (request 1)
* end of items in core data - just load more *
I keep track of whether a gap exists by comparing the oldest timestamp for the feed items in request 2 with the newest timestamp in set of feed items from request 1. If the oldest timestamp from request 2 is greater then the newest timestamp from request 1 I can assume that a gap exists and I should display a cell with a button to load 50 more. If the oldest timestamp from request 2 is less than or equal to the newest timestamp from request 1 the gap has been filled and there's no need to display the loader.
My first issue is the entire logic surrounding keeping track of whether or not to display the "Load more" cell. How would I know where to display this gap? Do I store it as the same NSManagedObject entity as my feed items with an extra bool + a timestamp that lies in between the two above and then change the UI accordingly? Would there be another, better solution here?
My second issue is related to multiple gaps:
50 new feed items
----- gap ------
174 older feed items
----- gap ------
53 older feed items
* end of items in core data - just load more *
I suppose it would help in this case to go with an NSManagedObject entity so I can just do regular fetches in my Core Data and if they show up amongst the objects, then display them as loading cells and remove them accordingly (if gaps no longer exist between any sets of gaps).
I'd ultimately want to wipe the objects after a certain time has passed as the user probably wouldn't go back in time that long and if they do I can always fetch them from my server if needed.
Any experiences and advice anybody has with this subject is be greatly appreciated!