def queryProblem(self, request):
     """Filter sessions by time of the day and type of session."""
     sessions = Session.query()
     sessions = sessions.filter(Session.startTime >= request.start_hour)
     sessions = sessions.filter(Session.startTime <= request.end_hour)
     sessions = sessions.order(Session.startTime)
     items = []
     for sess in sessions:
         if sess.typeOfSession not in request.not_type:
             items.append(process.sessions.copySessionToForm(sess))
     return SessionForms(
         items=items
     )
 def getSessionsByDuration(self, request):
     """List of sessions within the specified duration."""
     sessions = Session.query()
     sessions = sessions.filter(
         Session.duration >= request.min_duration
     )
     sessions = sessions.filter(
         Session.duration <= request.max_duration
     )
     sessions = sessions.order(Session.duration)
     sessions = sessions.order(Session.startTime)
     return SessionForms(
         items=[
             process.sessions.copySessionToForm(sess) for sess in sessions
         ]
     )
 def getSessionsByDate(self, request):
     """List of sessions on the selected date."""
     sessions = Session.query()
     sessions = sessions.filter(
         Session.date == datetime.strptime(
             request.date[:10], "%Y-%m-%d"
         ).date()
     )
     sessions.order(Session.startTime)
     return SessionForms(
         items=[
             process.sessions.copySessionToForm(sess) for sess in sessions
         ]
     )
 def getConferenceSessionsByType(self, request):
     """List all the sessions of the selected Type."""
     c_key = ndb.Key(urlsafe=request.websafeConferenceKey)
     if not c_key.get():
         raise endpoints.NotFoundException(
             (
                 'No conference found with key: %s'
             ) % request.websafeConferenceKey
         )
     sessions = Session.query(ancestor=c_key)
     sessions = sessions.filter(
         Session.typeOfSession == request.typeOfSession
     )
     sessions = sessions.order(Session.startTime)
     return SessionForms(
         items=[
             process.sessions.copySessionToForm(sess) for sess in sessions
         ]
     )