I have a question model and a response model whos parent is set to a specific question like such:
class Question(db.Model):
myQuestion = db.StringProperty()
class Response(db.Model):
responder = db.ReferenceProperty(reference_class = User, collection_name = 'my_responses')
myResponse = db.StringProperty()
def createQuestion(self, user, question):
Question(myQuestion = question, parent = user).put()
def respond(self, user, question, response):
Response(responder = user, myResponse = response, parent = question).put()
Given a user how do I get all the questions the user has not responded to?
One solution would be to keep a list of questions the user has responded to. You could Keep these lists in the user’s entity group, and use the current month (for example) as the key name.
Set QuestionsAnswered entity’s key-names to the current month (I like ‘201106’, for instnace), and put them in the user’s entity group. This will make fetching the needed seen lists easy.
To get the list of unseen questions, you could do something like this:
You can extend this to check for the oldest month in the returned questions. You can also extend this to fetch again if not enough questions were returned.