App Engine application project for the Udacity web developer course.
- Python
- Update the value of
application
inapp.yaml
to the app ID you have registered in the App Engine admin console and would like to use to host your instance of this sample. - Update the values at the top of
settings.py
to reflect the respective client IDs you have registered in the Developer Console. - Update the value of CLIENT_ID in
static/js/app.js
to the Web client ID - (Optional) Mark the configuration files as unchanged as follows:
$ git update-index --assume-unchanged app.yaml settings.py static/js/app.js
- Run the app with the devserver using
dev_appserver.py DIR
, and ensure it's running by visiting your local server's address (by default localhost:8080.) - (Optional) Generate your client library(ies) with the endpoints tool.
- Deploy your application.
It's a class containing basic information about a session. Properties include:
- name: Each session must have a name(title), so we should use ndb.StringProperty(required=True)
- highlights: It can be keywords, descriptor or abstraction, so use ndb.StringProperty()
- speaker: we also want to know the name of the speaker, but so far we don't need to know more about a speaker, so use ndb.StringProperty()
- duration: It's how long the session last, so use ndb.IntegerProperty()
- typeOfSession: we have different kinds of sessions, but if the user does not specify which type, we can let it be "Unknown", so use ndb.StringProperty(default='Unknown')
- date: Similar to conference date, we need to have a date for the session, so use ndb.DateProperty()
- startTime: To inform people to attend the session at the right time, we also need to have a property indicating the start time of the session, so use ndb.TimeProperty()
- getConferenceSessions(websafeConferenceKey) -- Given a conference, return all sessions
- getConferenceSessionsByType(websafeConferenceKey, typeOfSession) Given a conference, return all sessions of a specified type (eg lecture, keynote, workshop)
- getSessionsBySpeaker(speaker) -- Given a speaker, return all sessions given by this particular speaker, across all conferences
- createSession(SessionForm, websafeConferenceKey) -- open only to the organizer of the conference
Since each session does not particularly belong to a user, we don't want each user to have an entity copy for each session in his/her wishlist. Instead, we just need to save a list of keys that can represent sessions in the wishlist.
To do this, we add a sessionWishList property into Profile kind. This property is string and repeated, which takes less space than storing the whole session infomation. When we want to retrieve session information, we just need to get the key first and then fetch information using the key.
We don't want to force people to register for the meeting in order to add sessions to wishlist, so everyone can add sessions into their wishlist.
- addSessionToWishlist(SessionKey) -- adds the session to the user's list of sessions they are interested in attending
- getSessionsInWishlist() -- query for all the sessions in a conference that the user is interested in
- deleteSessionInWishlist(SessionKey) -- removes the session from the user’s list of sessions they are interested in attending
- getOngoingConferences() -- get all conferences that are ongoing, this might be helpful for people to search for meeting they can attend for their current time.
- getSessionsByDateRange(startDate, endDate) -- get all sessions that are held for a given date range. This can help people plan their schedule more efficiently before they go to the meeting.
Let’s say that you don't like workshops and you don't like sessions after 7 pm. How would you handle a query for all non-workshop sessions before 7 pm? What is the problem for implementing this query? What ways to solve it did you think of?
This problem is a query that requires two inequality (not workspace and before 7 pm). Usually we can not do two inequality in one datastore query, but luckily, the kinds of sessions that are available is not unlimited so we can transform the inequality into equality. Notice that of all the operators in datastore query, there is a "IN" operator which can represent member of (equal to any of the values in a specified list), so we can make the allowed type of sessions in a list and query for session type IN allowed type list.
The endpoint API for this query is getPreferredSessions()
The endpoint API implemented here is getFeaturedSpeaker(), what is does is that it will first query the Memcache for current featured speaker, if there's no featured speaker for now, it will try to find a featured speaker from all sessions.
For each one hour, the server will run the function that sets the featured speaker in Memcache. This can help reduce traffic and improve response because cache is faster and featured speaker does not need to be stored in the database.