is there a way to cut of the query and return back the results.. preset time to take to get all images from the given url .. i.e. query half of the webpage ? or job time not greater than 5 seconds, so therefore, it will get everything it can in 5 seconds.....
my xpath code:
$xpath = new DOMXPath( $htmlget);
$nodelist = $xpath->query( "//img/#src" );
Related
I'm practicing with XQuery and I've reached a point where I have to get the maximum values of each day of an xml file.
My file deals with the maximum temperatures that a city has throughout the days. And it appears the same day several times but with different hours throughout the day. I will give you an example of how the data appear in the XML file:
<hour>
<date>2019-2-18</date>
<data_hour>12:00</data_hour>
<temperature>17</temperature>
</hour>
<hour>
<date>2019-2-18</date>
<data_hour>13:00</data_hour>
<temperature>18</temperature>
</hour>
<hour>
<date>2019-2-19</date>
<data_hour>14:00</data_hour>
<temperature>20</temperature>
</hour>
<hour>
<date>2019-2-19</date>
<data_hour>15:00</data_hour>
<temperature>19</temperature>
</hour>
The idea would be to take out the maximum hour of each day, any idea of how to solve it?
If XQuery 3.0 is available, you could use the group by clause to group the hour elements together for each day, then apply the max function to select the highest temperature. In this code, I assume you've bound the hour elements to a variable $hours:
for $hour in $hours
group by $date := $hour/date
return
$date || ": " || max($hour/temperature)
This returns two items given your source data:
"2019-2-19: 20",
"2019-2-18: 18"
I will leave it as an exercise for you to sort the results by date. In the process, you will likely hit the limits of the current formatting of your dates, so you will need to convert the dates to values that conform to the xs:date data type, which is reliably sortable.
If you are limited to XQuery 1.0, then see XQuery 3.0 equivalent group by in xquery 1.0 version.
Try this, add an additional parent tag like I've added
let $body := doc("1.xml")
for $i in distinct-values($body//hour/date)
return <Day value = "{data($i)}"> {
let $hours := (for $row in $body//hour
for $j in $row/date where xs:string(data($j)) = xs:string(data($i))
return fn:substring($row/data_hour, 1, 2))
return fn:max($hours)
}
</Day>
Tell me if minutes are also considered.
I have the results as:
but need the results to appear as:
ie. where the last value with data will fill up the entire horizon for that year, each month defaulting to the last month with data.
Attempting to use the DAX as:
[Land Dev YTD]:= VAR LastNoneblankDate = CALCULATE(max('Date'[Date]),FILTER(Hyperion,[Land Dev] > 0)) return IF([Land Dev] = 0,CALCULATE([Land Dev],FILTER(ALL('Date'),'Date'[Date]=LastNoneblankDate)),[Land Dev])
Should in theory be sufficient, ie. supplant the result, where 0, to the value whereby the data is last present. However, the result is:
as it blows away all the other dates where there is not data.
How can I get this resolved?
I have the following eloquent query
$raw = Model::select('out', 'in')->orderBy('created_at', 'DESC')->first();
That returns a collection of a single item, where Out = 0.0 and In = 90.0.
If I then do this:
$sumO = $raw->sum('out');
$sumI = $raw->sum('in');
I get $sumO = 13,651.41 and $sumI = 13371.69
I don't understand, because those sums don't even equal the sum of my entire table for those colums.
But it seems like->sum() is being called on the entire table/query instead of just the first result like I thought it would.
Now, I know sum of a single row is weird, and I'm not actually doing this in production. I just want to know what it is doing.
Shouldn't it still just sum the 1 number to equal itself?
It's just one row when using ->first(), so there's no need to use ->sum() just use $raw->in and $raw->out.
Also, ->sum() used with a single column at a time.
I have a BIRT report that displays some statistics of calls to a certain line on certain days. Now I have to add a new measeure called "call handling time". The data is collected from a MySQL DB:
TIME_FORMAT(SEC_TO_TIME(some calculations on the duration of calls in seconds),'%i:%s') AS "CHT"
I fail to display the duration in my crosstab in a "mm:ss"-format even when not converting to String. I can display the seconds by not converting them to a time/string but that's not very human readable.
Also I am supposed to add a "grand total" which calculates the average over all days. No problem when using seconds but I have no idea how to do that in a time format.
Which data types/functoins/expressions/settings do I have to use in the query, Data Cube definition and the cross tab cell to make it work?
Time format is not a duration measure, it cannot be summarized or used for an average. A solution is to keep "seconds" as measure in the datacube to compute aggregations, and create a derived measure for display.
In your datacube, select this "seconds" measure and click "add" to create a derived measure. I would use BIRT math functions to build this expression:
BirtMath.round(measure["seconds"]/60)+":"+BirtMath.mod(measure["seconds"],60)
Here are some things to watch out for: seconds are displayed as single digit values (if <10). The "seconds" values this is based on is not an integer, so I needed another round() for the seconds as well, which resulted in seconds sometimes being "60".
So I had to introduce some more JavaScript conditions to display the correct formatting, including not displaying at all if "0:00".
For the "totals" column I used the summary total of the seconds value and did the exact same thing as below.
This is the actual script I ended up using:
if (measure["seconds"] > 0)
{
var seconds = BirtMath.round(BirtMath.mod(measure["seconds"],60));
var minutes = BirtMath.round(measure["seconds"]/60);
if(seconds == 60)
{
seconds = 0;
}
if (seconds < 10)
{
minutes + ":0" + seconds;
}
else
{
minutes + ":" + seconds;
}
}
I have an xml document in which I want to extract every 10 elements. I used this code to extract the last 10 elements, but the idea is to get the next 10 ones just before them, I can't use pagination with linq since I get the whole document:
slideView.ItemsSource =
(from channel in xmlItems.Descendants("album")
orderby (int)channel.Element("catid") descending
select new onair
{
title = (string)channel.Element("name"),
photo = (string)channel.Element("picture")
}).Take(10);
any ideas please?
Thanks
Try .Skip(10).Take(10) towards the end of your query.