Skip to content

Instantly share code, notes, and snippets.

Created October 7, 2013 18:22
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
A technique for storing a JSON-serializable datetime as a computed property so that mapreduce can filter against it.
class UserData(db.Model):
birthdate = db.DateProperty(indexed=False)
def compute_birthdate_str(self):
if self.birthdate:
return self.birthdate.isoformat()
return self.birthdate
# You will probably need to add this to index.yaml
# - kind: UserData
# properties:
# - name: birthdate_str
# - name: __scatter__
birthdate_str = db.ComputedProperty(compute_birthdate_str, indexed=True)
def run_mapreduce():
mapreduce_id = mapreduce.control.start_map(
"input_reader": {
"entity_kind": "UserData",
# NOTE: You can only use "=" as the second argument
"filters": [("birthdate_str", "=", "2013-05-16")]
return "MapReduce job launched: %s" % mapreduce_id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment