def get(self, number):
        if not isAdmin():
            return self.redirect("/")

        if isMasterDB():
            return self.redirect("/")

        number = int(number)
        q = taskqueue.Queue("populate")

        def enqueue(start, end):
            params = {"start": start, "end": end}
            q.add(taskqueue.Task(url="/dashboard/__db_populate/worker", params=params))

        start = 0
        end = 0
        batchSize = 40  # just copying nate

        for i in range(batchSize, number, batchSize):
            end = i
            enqueue(start, end)
            start = end

        if end < number:
            enqueue(end, number)

        self.response.write("Enqueued {0} hackers.".format(number))
    def get(self, number):
        if not isAdmin(): return self.redirect('/')

        if isMasterDB():
            return self.redirect('/')

        number = int(number)
        q = taskqueue.Queue('populate')

        def enqueue(start, end):
            params = {"start": start, "end": end}
            q.add(
                taskqueue.Task(url='/dashboard/__db_populate/worker',
                               params=params))

        start = 0
        end = 0
        batchSize = 40  #just copying nate

        for i in range(batchSize, number, batchSize):
            end = i
            enqueue(start, end)
            start = end

        if end < number:
            enqueue(end, number)

        self.response.write("Enqueued {0} hackers.".format(number))
    def get(self, number):
        if not isAdmin(): return self.redirect('/')

        if isMasterDB():
            return self.redirect('/')

        number = int(number)

        ndb.delete_multi(Hacker.query().fetch(limit=number, keys_only=True))
        self.response.write("Eliminated {0} hackers.".format(number))
    def post(self):
        if isMasterDB():
            return self.redirect("/")

        start = int(self.request.get("start"))
        end = int(self.request.get("end"))
        hackers = []
        for i in range(start, end):
            hackers.append(createTestHacker(i))

        ndb.put_multi(hackers)
    def get(self, number):
        if not isAdmin():
            return self.redirect("/")

        if isMasterDB():
            return self.redirect("/")

        number = int(number)

        ndb.delete_multi(Hacker.query().fetch(limit=number, keys_only=True))
        self.response.write("Eliminated {0} hackers.".format(number))
    def post(self):
        if isMasterDB():
            return self.redirect('/')

        start = int(self.request.get('start'))
        end = int(self.request.get('end'))
        hackers = []
        for i in range(start, end):
            hackers.append(createTestHacker(i))

        ndb.put_multi(hackers)