Exemplo n.º 1
0
def pushData():

	# find object from configuration
	objId = request.args.get("obj")

	# key data
	keyData = processArgs(request.args)

	# data specifying how to increment
	incrData = request.args.get("d")
	
	# amount to increment/decrement
	amt = request.args.get("amt") or 1
	try:
		amt = int(amt)
	except ValueError:
		amt = 1

	return returnJSON(statsdb.pushData(objId, keyData, incrData, amt))
Exemplo n.º 2
0
	return votes

# runtime
count = 0
countProcessed = 0
timestart = time.time()
newhowmany = 1000000
print "%s **************** mode: %s, stat field: %s, stat val: %s, amount: %d" % (datetime.now(), run_mode, statField, markVal, amt)
while numVotes > 0:
	count += 1
	howmany = batchsize if batchsize < numVotes else numVotes
	numVotes -= howmany

	votes = doQuery(howmany)
        #votes = doQuery(newhowmany)
	if len(votes) == 0:
		break

	inserted = 0
	for vote in votes:
		result = statsdb.pushData("vote", vote, vote["choices"], amt=amt)
		if "incremented" in result:
			collection.update({ "_id": ObjectId(vote["_id"]) }, { "$set": { statField: markVal } })
			inserted += 1

	countProcessed += inserted

print "Finished! Took: %d seconds. Processed %d votes." % ((time.time() - timestart), countProcessed)