Exemple #1
0
 def __init__(self, name: str, categId: str):
     self._id = gen.nextId(Topic)
     self.name = name
     self.slug = util.normalizeId(name)
     self.categId = categId
     self.createdAt = util.timeSinceDaysAgo(180)
     self.updatedAt = self.updatedAtTroll = self.createdAt
     self.nbPosts = self.nbPostsTroll = 0
     self.troll = False
     self.hidden = False
     self.closed = util.chance(0.1)
     self.userId = gen.randomUid()
Exemple #2
0
 def __init__(self, name: str):
     self._id = util.normalizeId(name)
     self.name = name
     self.description = gen.randomTopic()
     self.descPrivate = "All of our dads could beat up YOUR dad."
     self.nbMembers = 1
     self.enabled = True
     self.open = util.chance(0.5)
     self.createdAt = util.timeSinceDaysAgo(1440)
     self.leaders = list(random.sample(gen.uids, (rrange(1, 4))))
     self.createdBy = self.leaders[0]
     self.chat = 20  # of course chat and forum are equal to 20.
     self.forum = 20  # wtf else would they possibly be??
Exemple #3
0
 def __init__(self, uid: str):
     self._id = gen.nextId(UBlogPost)
     self.blog = f"user:{uid}"
     self.title = gen.randomTopic()
     self.intro = gen.randomTopic()
     self.markdown = (
         f"![image]({gen.randomImageLink()})\n{gen.randomParagraph()}\n"
         f"![image]({gen.randomImageLink()})\n{gen.randomParagraph()}\n"
         f"![image]({gen.randomImageLink()})\n{gen.randomParagraph()}")
     self.language = "en-US"
     self.live = True
     self.topics = random.sample(_blogTopics, 3)
     self.created = {"by": uid, "at": util.timeSinceDaysAgo(365)}
     self.lived = self.created
     self.updated = self.created
     self.rank = self.created["at"] - timedelta(days=30)  # wtf is this?
     self.views = rrange(10, 100)
     self.likes = rrange(3, 10)
     self.likers = random.sample(gen.uids, self.likes)
Exemple #4
0
 def __init__(self, game: dict, white: str, black: str):
     self._id = game["_id"]
     self.us = [white, black]
     self.__dict__["is"] = _nextPid(True) + _nextPid(False)
     self.p0 = game["p0"]
     self.p1 = game["p1"]
     self.s = game["s"]
     self.t = game["t"]
     self.v = 1
     self.ra = game["ra"]
     self.ca = util.timeSinceDaysAgo(730)
     self.ua = util.timeShortlyAfter(self.ca)
     self.so = game["so"]
     self.hp = bson.binary.Binary(game["hp"])
     self.an = game["an"]
     if "c" in game:
         self.c = bson.binary.Binary(game["c"])
     if "cw" in game:
         self.cw = bson.binary.Binary(game["cw"])
     if "cb" in game:
         self.cb = bson.binary.Binary(game["cb"])
     if "w" in game:
         self.w = game["w"]
         self.wid = white if game["w"] else black
Exemple #5
0
    def __init__(self,
                 name: str,
                 marks: list[str] = [],
                 roles: list[str] = [],
                 withPerfs: bool = True):
        self._id = util.normalizeId(name)
        self.username = name.capitalize()
        self.email = f"lichess.waste.basket+{name}@gmail.com"
        self.bpass = bson.binary.Binary(
            base64.b64decode(
                "E11iacfUn7SA1X4pFDRi+KkX8kT2XnckW6kx+w5AY7uJet8q9mGv"))
        self.enabled = True
        self.createdAt = util.timeSinceDaysAgo(365)
        self.seenAt = util.timeSince(self.createdAt)
        self.lang = "en-US"
        self.time = {"total": rrange(10000, 20000), "tv": 0}
        self.roles = ["ROLE_VERIFIED"]
        self.roles.extend(roles)
        self.marks = marks
        self.kid = util.chance(0.05)
        if util.chance(0.1):
            self.title = random.choice(_titles)
        self.plan = {
            "months": 1,
            "active": util.chance(0.2),
            "since": util.timeSinceDaysAgo(30),
        }
        rating = min(3000, max(int(random.normalvariate(1700, 300)), 400))
        self.profile = {
            "country": gen.randomCountry(),
            "location": self.username + " City",
            "bio": gen.randomParagraph(),
            "firstName": self.username,
            "lastName": self.username + "bertson",
            "fideRating": rating,
            "uscfRating": rrange(rating - 200, rating + 200),
            "ecfRating": rrange(rating - 200, rating + 200),
            "rcfRating": rrange(rating - 200, rating + 200),
            "cfcRating": rrange(rating - 200, rating + 200),
            "dsbRating": rrange(rating - 200, rating + 200),
            "links": "\n".join(gen.randomSocialMediaLinks()),
        }
        totalGames = rrange(2000, 10000)
        totalWins = totalLosses = totalDraws = 0
        if withPerfs:
            self.perfStats = {}  # we'll detach this later
            self.perfs = {}
            perfGames: list[int] = util.randomPartition(
                totalGames, len(perf.types), 0)

            for [index, perfName,
                 drawRatio], numGames in zip(perf.types, perfGames):
                if numGames == 0:
                    continue
                p = perf.Perf(self._id, index, numGames, drawRatio, rating)

                totalWins = totalWins + p.count["win"]
                totalLosses = totalLosses + p.count["loss"]
                totalDraws = totalDraws + p.count["draw"]
                self.perfStats[perfName] = p
                self.perfs[perfName] = {
                    "nb": p.count["all"],
                    "la": util.timeSinceDaysAgo(30),
                    "re": [rrange(-32, 32) for _ in range(12)],
                    "gl": {
                        "r": p.r,
                        "d": random.uniform(0.5, 120),
                        "v": random.uniform(0.001, 0.1),
                    },
                }
        else:
            totalGames = 0

        self.count = {
            "game": totalGames,
            "ai": 0,
            "rated": int(totalGames * 0.8),
            "win": totalWins,
            "winH": totalWins,
            "loss": totalLosses,
            "lossH": totalLosses,
            "draw": totalDraws,
            "drawH": totalDraws,
        }
Exemple #6
0
 def __init__(self, userId: str, teamId: str):
     self._id = userId + "@" + teamId
     self.team = teamId
     self.user = userId
     self.date = util.timeSinceDaysAgo(720)