Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
time zone correction script in initialize executing multiple times
abhiallen
Hello All,
I am working on optimizing some reports which have time zone correction scripts in the initialize event in the report, which by definition initialize script would execute multiple times for every page. I tried putting time zone script in before factory but it didnt . where does the timezone related script go for efficient and optimized execution of the report.
Thanks
Abhishek
Code:
startDate = reportContext.getParameterValue("startDate");
endDate = reportContext.getParameterValue("endDate");
endDate = DateTimeSpan.addTime(endDate,23,59,59);
var tz = reportContext.getAppContext().get("AppRuntimeTimeZone");
if ( tz == null ) {
zone = "America/New_York";
tz = java.util.TimeZone.getTimeZone(zone);
}
else {
zone = tz.getID();
}
offset = tz.getOffset(new java.util.Date().getTime());
offset /= 60000;
offset = -offset;
var today = BirtDateTime.today();
if (offset != 0) {
startDate = BirtDateTime.addHour(startDate,offset/60);
startDate = BirtDateTime.addMinute(startDate,offset % 60);
endDate = BirtDateTime.addHour(endDate,offset/60);
endDate = BirtDateTime.addMinute(endDate,offset % 60);
}
dateRange = DateTimeSpan.days(startDate,endDate);
if (dateRange < 3) {
chartType = "hours";
}
else if (dateRange > 60) {
chartType = "weeks";
}
else {
chartType = "days";
}
startDate=Formatter.format(startDate,"yyyy-MM-dd HH:mm:ss");
endDate=Formatter.format(endDate,"yyyy-MM-dd HH:mm:ss");
Find more posts tagged with
Comments
kclark
Are you trying to keep this script more than once? If that's what your trying to do then you could wrap that in a if-then to check if the code has already been executed using a persistent global variable.
abhiallen
<blockquote class='ipsBlockquote' data-author="'kclark'" data-cid="112160" data-time="1354834589" data-date="06 December 2012 - 03:56 PM"><p>
Are you trying to keep this script more than once? If that's what your trying to do then you could wrap that in a if-then to check if the code has already been executed using a persistent global variable.<br /></p></blockquote>
<br />
Yes this script in initialize is probably executing more than once. I tried putting this in beforefactory but it didnt get executed. I will try using global variable and limit its execution to one. thanks for your reply.