Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2601)

Unified Diff: appengine/findit/util_scripts/iterator.py

Issue 2432203003: [Predator] Run predator. (Closed)
Patch Set: . Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: appengine/findit/util_scripts/iterator.py
diff --git a/appengine/findit/util_scripts/iterator.py b/appengine/findit/util_scripts/iterator.py
index c57809a0244c6e4141658b1699cb0400c8fbc059..0528f29993026d1f33096664f239c8de8752be5c 100644
--- a/appengine/findit/util_scripts/iterator.py
+++ b/appengine/findit/util_scripts/iterator.py
@@ -19,13 +19,13 @@ def ProjectEntity(entity, fields):
entity_info[field] = getattr(entity, field)
else:
entity_info[field] = None
- entity_info['id'] = entity.key.id()
+ entity_info['id'] = entity.key.urlsafe()
return entity_info
def Iterate(query,
- fields,
app_id,
+ fields=None,
filter_func=None,
batch_size=_DEFAULT_BATCH_SIZE,
batch_run=False):
@@ -33,10 +33,10 @@ def Iterate(query,
Args:
query (ndb.Query): The query to fetch entities.
+ app_id (str): App engine app id.
fields (list): Field names of an entity to be projected to a dict.
If a given field name is not available, it is set to None.
- 'id' is always added by default as an integer.
- app_id (str): App engine app id.
+ return complete entities.
wrengr 2016/11/01 22:07:52 What do you mean "return complete entities." ?
Sharu Jiang 2016/11/11 23:10:26 I mean model instead of a projected dict.
filter_func (function): A function that does in memory filtering.
batch_size (int): The number of entities to query at one time.
batch_run (bool): If True, iterate batches of entities, if
@@ -56,7 +56,9 @@ def Iterate(query,
if filter_func:
entities = filter_func(entities)
- entities = [ProjectEntity(entity, fields) for entity in entities]
+ if fields:
+ entities = [ProjectEntity(entity, fields) for entity in entities]
+
if batch_run:
yield entities
else:

Powered by Google App Engine
This is Rietveld 408576698