I have a standard Python App Engine service, and a flexible service (in the same project) written in node.js. The flexible service is an admin dashboard.
I'm trying to filter on a datetime property field, and I know I can do it on the Python side and get valid results, but it fails in the node.js service.
Python:
endTime = datetime.today().replace(hour=0, minute=0, second=0, microsecond=0)
startTime = endTime - timedelta(1)
newusers = SVCUser.query(SVCUser.created_at >= startTime,
SVCUser.created_at < endTime).count(keys_only=True)
Node.js:
const startTime = moment().utc().subtract(1, 'days').startOf('day').toDate();
const endTime = moment().utc().startOf('day').toDate();
const query = ds.createQuery('SVCUser')
.filter('created_at', '>=', startTime)
.filter('created_at', '<', endTime);
return ds.runQuery(query)
.catch((err) => {
return logging.error(err);
})
.then((results) => {
const data = {
event_date: endTime,
new_users: results[0].length > 0 ? results[0].length : 0
};
return bigquery.dataset('stats').table('newusers').insert(data);
});
The result of my query is always nonsense: either zero entries, or if I move the date range around a bit, one or two entries. I've verified with the GAE console that I should have 100+ a day, which is also what the Python code returns.
The field in question is indexed, so I don't know what's going on here.
class SVCUser(ndb.Model):
[...]
created_at = ndb.DateTimeProperty(auto_now_add=True)
via Faried Nawaz
No comments:
Post a Comment