Created
September 12, 2011 22:58
-
-
Save stevenschlansker/1212714 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ness.rating import RatingClient, RatingClientModule | |
from ness.user import UserClient, UserClientModule | |
shell.setEnvironment("staging/DEPLOY-83/json-api") | |
shell.registerModule(UserClientModule()) | |
shell.registerModule(RatingClientModule()) | |
shell.reload() | |
uc = injector.getInstance(UserClient) | |
rc = injector.getInstance(RatingClient) | |
from ness.query.util import CallbackCollector | |
from ness.user.query import AccountQuery | |
users = CallbackCollector() | |
uc.query(AccountQuery().withSource("TRUMPET"), users) | |
from ness.user import NessAccounts | |
ids = list(NessAccounts.getNessIds(users.getItems())) | |
users = None | |
ratings = rc.query(rc.getQueryFactory().query().build()) | |
targetIds = list([rating.getTargetId() for rating in ratings]) | |
ratings = None | |
import random | |
def getAccountIds(num=1000): | |
return [random.choice(ids) for i in xrange(0, num)] | |
def getTargetIds(num=1000): | |
return [random.choice(targetIds) for i in xrange(0, num)] | |
rc.query(rc.getQueryFactory().query().byAccounts(getAccountIds(1000)).aboutTargetIds(getTargetIds(1000)).build()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment