Convert Puppeteers HttpResponse.timing().requestTime to real time - puppeteer

I'm using puppeteers page.on('requestFinished') event in my web scraper. Part of the project, I need to collect each request start time and the time it took to complete the request. I found httpResponse.timing() but I couldn't wrap my head around the requestTime fields value. It looks like it is in seconds with decimal place, but, it neither an epoch time nor it is the time elapsed since I start my crawler process (monotonic time). What time format is it? Can we convert it to human understandable time, so that I know when the request started?
Example of timing() output:
{
requestTime: 700151.9155,
proxyStart: -1,
proxyEnd: -1,
dnsStart: 1.646,
dnsEnd: 108.539,
connectStart: 108.539,
connectEnd: 218.554,
sslStart: 164.675,
sslEnd: 218.531,
workerStart: -1,
workerReady: -1,
workerFetchStart: -1,
workerRespondWithSettled: -1,
sendStart: 221.102,
sendEnd: 222.261,
pushStart: 0,
pushEnd: 0,
receiveHeadersEnd: 364.526
}
{
requestTime: 700152.313434,
proxyStart: -1,
proxyEnd: -1,
dnsStart: -1,
dnsEnd: -1,
connectStart: -1,
connectEnd: -1,
sslStart: -1,
sslEnd: -1,
workerStart: -1,
workerReady: -1,
workerFetchStart: -1,
workerRespondWithSettled: -1,
sendStart: 1.316,
sendEnd: 2.29,
pushStart: 700152.24554,
pushEnd: 700152.24558,
receiveHeadersEnd: 13.923
}

Related

Widget Refresh at 6AM and 6PM by calling the api

Hi Could you please help me out like to refresh the widget needs to be refreshed(need to hit the api and show the updated data) twice daily it at 6AM and 6PM. Right now am using the policy with .atEND But I could see the same data is rendering at 6AM and 6PM. and the refresh ie API call is happening after 6PM. But my requirement is like to hit the api before rendering the widget at 6AM and again needs to hit the api before rendering at 6PM.
if let At6AM = Calendar.current.date(bySettingHour: 6, minute: 0, second: 0, of: Date()) {
let refreshEntryFor6AM = RecommendedWidgetEntry(date: At6AM, recommedationData: items)
refreshEntries.append(refreshEntryFor6AM)
}
if let At6PM = Calendar.current.date(bySettingHour: 18, minute: 0, second: 0, of: Date()) {
let refreshEntryFor6PM = RecommendedWidgetEntry(date: At6PM, recommedationData: items)
refreshEntries.append(refreshEntryFor6PM)
}
let timeline = Timeline(entries: refreshEntries, policy: .atEnd)

Getting NaN and infinity value in ssrs

Here is my formula
Deviation=(Today- yesterday)/yesterday
Need the value in %
If today is 0, then the value should be -100%(negative deviation)
If yesterday is 0, then the value should be +100%(positive deviation)
Issue:
1.Getting NaN if both today and yesterday are 0. Expected -100%
2.And infinity if yesterday is zero. Expected +100%
Assuming your expression looks like that below
= (Fields!myvalue.Value-Previous(Fields!myvalue.Value)) / Previous(Fields!myvalue.Value)
You can use switch to customize the output based on conditions when current or previous value is 0
Adjust your expression to look like that below
= Switch(
Fields!myvalue.Value=0 AND Previous(Fields!myvalue.Value)=0, -1,
Previous(Fields!myvalue.Value)=0, 1,
True, (Fields!myvalue.Value-Previous(Fields!myvalue.Value)) / Previous(Fields!myvalue.Value)
)

Heap sort , about the implementation of method involving range

What does the -1, -1 in range(n, -1, -1) do, I have encountered this same pattern and implementation with various sorting algo, and it's confusing me so much. Any answers would be appreciated! thank you in advance - NewCoder
-SAMPLE CODE-
def build_max_heap(A):
n = len(A)
for i in range(n, -1,-1):
max_heapify(A,n, i)
for i in range(n-1,0,-1):
A[0],A[i]=A[i],A[0]
max_heapify(A,i,0)
A=[33,35,42,10,7,8,14,19,48]
build_max_heap(A)
print(A)
The signature for range is range(start, stop[, step]).
The range function in range(n, -1, -1) accept 3 argument:
'n' as the start index of the range object
the first '-1' as the end index of the range object
the second '-1' as the move step of the range object
So range(n, -1, -1) basic means construct a sequence of [n, n-1, ..., 1, 0].
For more you can refer to Python Doc

How to fetch archived history from Chrome API

I would like to list archived (90+ days) history URLs from Google Chrome using Chrome API.
I realised that it's probably impossible because the results have not been returned:
let urlAmount = 0;
chrome.history.search(
{
"text": "",
"startTime": new Date(2018, 5, 14, 11, 0, 0).getTime(),
"endTime": new Date(2018, 6, 14, 11, 0, 0).getTime()
},
function(historyItems)
{
for (var i = 0; i < historyItems.length; i++)
{
urlAmount++;
}
});
As you can see I'm checking (2018.05.14 - 2018.06.14) time interval (it's more that 90 days ago from now).
urlAmount is 0 but for example (2019.01.14 - 2019.01.20) it's 100 (default max value is 100).
Is it possible to fetch such archived history this way?
If not what about Selenium automation approach?
The urlAmount variable is incremented inside a callback. So you should move its initialization to the callback function(historyItems), right before the for loop.
The default value for maxResults is 100 if you don't use it, but you can set to it a higher value.

Multiple Or in an IIF function

Given this data: Complete Dataset
I only want to get the Total_AR of those TransactionYrMonth=ParameterPeriod so I produced it using this code:
=IIF(
IsNothing(Sum(Fields!Total_AR.Value)),0,
Sum(IIF(Cdate(Fields!TransactionYrMnth.Value)=Cdate(Parameters!Period.Value),
Fields!Total_AR.Value,0)
)
)
From there, I got this dataset:
Filtered Dataset
Now, what I need to do is to get the sum of the first 3 service months starting from January to March that is equal to the latest transaction month which is April.
So the sum should be equal to $204,329 + -$96,640 + -$259,008 = -$151,319
To make it possible, I tried to use a code like this:
=Sum(IIF(
Cdate(Fields!TransactionYrMnth.Value)=Cdate(Parameters!Period.Value) And (
Cdate(Fields!ServiceYrMnth.Value)=DateAdd(DateInterval.Month, -3, CDate(Parameters!Period.Value)) Or
Cdate(Fields!ServiceYrMnth.Value)=DateAdd(DateInterval.Month, -2, CDate(Parameters!Period.Value)) Or
Cdate(Fields!ServiceYrMnth.Value)=DateAdd(DateInterval.Month, -1, CDate(Parameters!Period.Value))), Fields!Total_AR.Value,0
))
I have no luck producing it. I even got an error saying
‘Textbox11.Paragraphs[0].TextRuns[0]’ contains an error: [BC30516] Overload resolution failed because no accessible 'IIf' accepts this number of arguments.
Anyone, please help?
I got a solution already using this code:
=Sum(IIF(
Cdate(Fields!TransactionYrMnth.Value)=Cdate(Parameters!Period.Value) And
CDate(Fields!ServiceYrMnth.Value) >= DateAdd(DateInterval.Month, -3, CDate(Parameters!Period.Value)) And
CDate(Fields!ServiceYrMnth.Value) <= DateAdd(DateInterval.Month, -1, CDate(Parameters!Period.Value)), Fields!Total_AR.Value, 0
)
)