search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Pass Json to controller.js without using backend

Asked by Matthew Trefz
11 years ago.

We are currently pulling time records, validating those records. Then we call the "Backend" method in the Calendar controller in order to generate the daily calendars. I would like to by pass the Calendar controller and push the json data we already have to controller.js to generate the calendars.

Not iterating through the records twice I believe will greatly improve our performance.

Is this possible?

Comment posted by Steve M.
11 years ago.

This question parallels some of my own requirements, and I agree that not hitting the DB twice for the same data is beneficial... But I do have some questions on your implementation:

1) Assuming your query returns the data already sorted by the event date/times... Do you really have to validate ALL of the records prior to showing only the current/selected date(s) in the calendar control? Or could you simply validate the few records on-or-around the desired event date(s)?
2) Why not limit your return resultset to just a range around the desired date(s)?
3) Could your validation logic be separated out to another function that only returns the records that do not pass validation?

Comment posted by Matthew Trefz
11 years ago.

To answer your questions:
1) We only show one day at a time, but have a calendar built for each person returned. (we now limit this to 6 at a time). The validation is not so much on the date but all the metrics that go with each event. We number of units associated, total time of the event and other various checks that are required. We could have as few as 5 events per calendar to 20 events per calendar.

2) We only returns events for the date and people selected.

3) These can be separated to a point, but then need to be merged back together for the final display.

I have manged to go from a 20 second page load to a 10 second page load, so progress still needs to be made. having the ability to insert dates into a calendar via javascript in the client side would be a big win.

Comment posted by Steve M.
11 years ago.

"1) We only show one day at a time, but have a calendar built for each person returned. (we now limit this to 6 at a time). The validation is not so much on the date but all the metrics that go with each event. We number of units associated, total time of the event and other various checks that are required. We could have as few as 5 events per calendar to 20 events per calendar."

"2) We only returns events for the date and people selected."

Ok, this helps clarify certain details. So I'm going to re-iterate your description, just to ensure that I understand what you are doing:
1. Page has (up to) six Calendar controls.
2. Page loads, and you do a data fetch for the first person. (Let's assume you are not returning an obscene amount of data.)
3. You perform some server-side validation on the returned data.
4. Assuming the validation in Step 2 passes, the page continues to load and initialize the Calendar object -- which has its own callback to fetch data (also assuming there is not an obscene amount of data).

At this point, you've done two database hits. Then you multiply that by (up to) five times for the additional people, because each has their own two-hit logic.

Couple of thoughts:
1. Use a profiler tool to look at the query time and execution plan of your fetch logic. Could that be refactored or tuned?
2. How wide and tall is each data call? Are you bringing back more data than what is needed or could be shown?
3. Does the performance improve when the fetch is abstracted to a stored proc, a view, or some other cached/optimized call?

HOWEVER... There is this comment:
"3) These can be separated to a point, but then need to be merged back together for the final display."

So now it sounds like you don't have (up to) six individual Calendar controls, but one. So if that is the case, and you know the date and people to display, are you just doing too many hits solely because the number of people you are evaluating? This is starting to sound like an exponential performance degradation, instead of a linear performance degradation.

"having the ability to insert dates into a calendar via javascript in the client side would be a big win."
Do you mean to add new events to the calendar, or update the calendar's display date? If it's the latter, then I had the same question answered here:
http://forums.daypilot.org/Topic.aspx/1735/asp-net-mvc3----how-to-update-startdate-field-from-jquery-d

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.