I'm working with a multi-user calendar where each user has associated events.
There is a week view and a day view.
The user can choose (from a list) which users calendars they want to view at any given time.
So I may choose to view the schedules of users A, B and D, go to the next week, select user C and deselect user A. Etc.
How might I implement caching for this so I don't have to send a new request for each user for each day/week view.
Currently I'm making one request with the selected users each time the calendar is navigated. I'm thinking maybe I could make a new request for each user for each day/week and cache those somehow so that no matter which set of users is selected, it can build the users array from individual caches?
I'm using Rails 3 and JQuery.
Any ideas?
Thanks.
As your views do not seem to be easily broken down into cachable fragments, you could build the entire view with jquery und just pull in the different calendars via AJAX. Have a look at the jquery template plugin which is a huge help. You could then cache the json responses which actually deliver the individual calendars.
Related
I've created form in google sheet, so that multiple users can add data, modify & delete.
However, it is not working properly when multiple users are working on it simultaneously.
For an example, two people are working on the sheet. User A and User B. If user A is typing something user B is also able to see and user B will be able to enter the detail, but it will change the details which are being entered by user A. Technically same sheet is opened for both the users and details keeps on changing what users are changing.
Ideally, if user A is entering some details user B should not be able to see it and form should be blank or unique for user B, so that both the data won't clash. I want it to be like the way google form is there wherein form will be blank when any user is opening it. (I have tried google form for my work, but as there are too many drop downs google form takes time to load and work gets slow that the reason I am trying to find the option in google sheet).
google sheet link
Above is the google sheet which you can open and check the form and coding. Also, please test it with a different id to test for multiple users.
Let me know if there is any workaround for this. Also, let me know if you need any other details.
Answer:
This just isn't possible. Sheets is meant to be a collaborative tool; what's edited by one person will always show up for others. You need to use a different tool, for example like a Google form for data entry, but having data not being edited in other open versions is just not workaroundable.
I've built, maintain and continually improve a website for an insanely complex fantasy football league I'm in where GMs have $130 of salary cap a year, players all have a starting salary value and may be signed to longterm deals using that initial salary amount as a starting point for subsequent years.
There's a lot more to it, but that's enough for what I need info on. Each GM has a team page that shows all the players he has on his team/signed to longterm deals along with some other roster breakdowns, historical payout information, draft rosters (basically a drag-and-drop sortable "shopping list" of players to keep an eye on), pending/completed/rejected trade requests, and private messages along with a lot of other information:
As you might imagine, this is an INSANE amount of information to load for each team. Upgrading to Ruby 2.1.2 alleviated a LOT of issues (page load times dropped from ~7 seconds to ~3 seconds on average), but there's still more that could be done.
Is there any way to make my 93-line teams#show action load lazily? So, like, for instance, the Roster and all associated variables would load when going to a team page since that's the first/default tab. But then the Payouts, Draft Rosters, Trades and Messages variables wouldn't fire their queries to set the variables until each of their tabs was activated? I've been trying to find anything I can about Rails lazy loading but I've had no luck at all finding anything even remotely close to what I want to do.
You can create one controller action per tab.
So you have something like this. The main page would be the users#show action. That would render the main layout and the tabpanel (with the roster tab).
Then create one action per tab. So you would have:users#payouts, users#draft_rosters, users#trades users#mailbox
Those actions can be loaded via ajax only when the tab is clicked for the first time: http://jqueryui.com/tabs/#ajax
Each tab would have it's own html.erb file. This file is the content of the page.
This way each tab has it's own instance variables that are only loaded when the tab is clicked.
I need to integrate my rails 3 application with google calendar. The following are requirements of the application:
Within my application I can create calendar events and invite people (pretty much most of the google calendar features).
I want to be able to pull a users existing google calendars and sync? (potentially).
I need to ability to show the calendar in different forms (daily, weekly, monthly) and put additional graphics in the calendar.
I need to use items created in the calendar for other features and functions. Specifically I need to keep track of a calendar item with something in my database. For example, the ID of a new appointment is tied to a user's foo in my database.
At first I was thinking that I should just bring in google calendar into my application (directly into a div) but then with #4 I really need much more than that.
I found the following
http://cookingandcoding.com/docs/gcal4ruby/ (for API integration)
and
http://www.web-delicious.com/jquery-plugins-demo/wdCalendar/sample.php (for the visual display of calendars)
Before I go down this path I wanted to see if others had input on this. I'm mostly concerned about how to architect this solution, specifically:
let's assume I use the api listed above to create a calendar specifically for my application in google calendar and I interface with this single calendar.
let's also assume that I can create events in that calendar, get the ID back from google calendar and place that ID of each event in my database (where I need to store it and make reference to specific events I've created).
I also want to bring in existing calendars from the user (and resync them). Can this API do that?
Are these the right tools for this architecture?
Also I think I need to use omniauth so that I don't have to store the users google calendar user name and password.
Another JQuery Calendar plugin you might want to look at is Full Calendar. There is even a demo project that provides code to integrate it with Rails 3 available on GitHub
I'm once again looking into the world of tabbed browsing and Sessions. Looking over a few google searches it seems that there isn't a nice way of supporting this.
Does anyone know of a method that allows Bookmarking without stealing a session (cookieless) (and this doesn't work in MVC2 for dataannotations).
Supporting tabs in such a way that it's per use case (like Windows Workflow), going through two workflows at once.
I'm thinking a url in the query string might support this, but I'm wondering if anybody else has done a similar implementation.
[Edit] Use Case: Say I'm writing an application that uses something like Windows Workflow. Each UI workflow may do an action such as collect settings of a page and execute some external process. I may wish to do two of these workflows at once (not necessarily the same UI workflow). As such if I saved in session I would get:
a) Different tabs interfering with the workflow
b) Previous/Next buttons would be extremely difficult to work out, due to a).
I would like it so either, a user cannot open another tab to a url (don't think there is a 100% method of preventing this), or allow a user to use a UI workflow in isolation without one affecting another (much like running two workflows in two different browsers).
Hopefully that gives an indication of what I'm attempting to do.
Regards,
J
It sounds like you might be trying to do the following:
For example, let's say you have a two page questionaire, the first page has first name on it and the second page has last name on it. You desire that the user can open two tabs, and be at different pages in the questionaire while entering different data in the questionaire in each tab.
So in Tab A, you have entered Mark as the first name and submitted and you are at page two now in Tab A. You decide you are going to do a questionairre for your friend also, so you open up a new Tab, Tab B. In Tab B you enter Tom and submit the page.
Currently in the browser you have Tab A, which is at page 2 of the questionaire with firstname = "Mark" and Tab B which is at page 2 of the questionaire with first name = "Tom". Assuming you wanted to maintain both of these in session on the server here is an approach that i think will work for you.
When a web browser requests page 1 of your form, on a GET request(no posted questionaire data to the server), you supply a hidden field in the the response html and generate a random number to store in that field. When this form is submitted you do the following on the server:
Look in session using the random number as a key "var questionaire = session[Request.Form["questionaire_rnumber"]]
if the questionaire is not in session you create a new questionaire and update it's properties and stick it in session
var questionaire = new Questionaire();
questionaire.FirstName = Request.Form["firstName"]
session[Request.Form["questionaire_rnumber"]] = questionaire;
if the questionaire was in the session you simply update the object, and display the next page, however when you display the next page you will want to supply the hidden random number field in the html again, using the same random number you used on page 1.
This way you can hold any number of questionaires in a single session. With MVC.NET it should be straight forward for you to add the random number field to your view model and add the logic for looking in session for an existing questionaire or creating a new one and I think you'll be good to go.
You should keep in mind the possible issues with the approach also, like back button issues, security issues, and performance issues.
One example of a security and a performance issue would be that an attacker realizes your application works like this and the attacker requests page 1 of your form 10,000 times and submit the page 1 each time. You would have 10,000 questionaire objects in that one user session. If the attacker deleted his session ID cookie 10,000 times and for each session id cookie he created 10,000 requests for page 1 and submitted the page 1 form, you would have 100,000 questionaire objects cumulatively across 10,000 sessions on your server. So you should put some constraints on it also to protect your application, for example:
Any individual session can only have X questionaires in session
Any individual IP address can only have Y concurrent sessions (this you would probably need to track in the Application object)
ADDITIONAL RESPONSE TO ADDED USE CASE
Thanks for the use case. My solution should still work for you. You have two options.
If you want to ensure there is only one tab working with your workflow, then when the random number is passed to the server from a new tab you will be able to detect that there is another workflow in progress and that the random number from the new tab does not match the random number from the first, so you will throw an exception and show the user some messaging that says they can't start a new workflow until they finish the first one, and ask if they want to cancel the first. You have to ask if they want to cancel it because if they close their browser on the first workflow they started they will be stuck until their session expires. Which won't happen if they keep trying to start a new workflow.
Secondly, you could allow them to do multiple, but segment the context of each workflow by the random number, as suggested in the first answer. The whole point is that you are making little mini-sessions in your session, but keyed of a value that is only stored in the client. So since each tab has a different random number when the form posts to the server, it's easy to correlate that random number with an entry in your session that has all the information about the workflow initiated from that tab.
Hope this helps.
You need to store wizard state information in the client in some way, via query string or form values. As you've intuited, Session will not work. Nor will anything else that relies solely on what is on the server.
We are going to port a legacy windows app to a large web application for a vertical market. Looking at MVC. Each implementation may have 50 to 5000 users. Looking at putting navigation in Master Page. The application will contain 200 to 300 menu items, resulting in over 500 views. We want to display a trimmed navigation menu for each user based on their application permissions. A user may see only 20 items, or all available.
Most posts I have seen suggest passing navigation items to Master Page through viewdata, established in a base controller class. I understand this.
Each of the potentially 10's to 1000's of users will have a different set of permissions.
Does anyone have any solutions that will avoid hitting the database to get the users menu items on every controller request that inherits from the base controller?
Is there a caching scheme that will work for each user?
Should the navigation be handled in a frame (not my choice)?
Is this just a price we will pay for this approach to navigation?
Thanks for any input!
You could start by caching linq queries which would be a nice way to tackle this at the DB tier.
Doing this in MVC using an action filter wouldn't be too hard either.
I implemented something like this in PHP a year ago but the general idea is the same. Firstly, you'll need to assign each menu configuration a unique id. This way when user A and user X request the same menu configuration, it resolves to the same cache file.
The first time a menu needs to be loaded for the user, it is loaded from the database and passed to the user. Simultaneously, it is saved to a cache file with the unique id in its name. On subsequent requests the action filter can load the data from the cache file if it exists and bypass the database.
Some ideas:
1.) You could have your nav bar html come from a Html.RenderAction (MVC Futures) and use the Output cache on that.
2.) You could generate the html for the nav bar per user then save that to the DB and regenerate if their user permissions change. So all you would need to do is pull the html from the DB against each users record.