Exemplo n.º 1
0
    def increase_hackathon_stat(self, hackathon, stat_type, increase):
        """Increase or descrease the count for certain hackathon stat

        :type hackathon: Hackathon
        :param hackathon: instance of Hackathon to be counted

        :type stat_type: str|unicode
        :param stat_type: type of stat that defined in constants.py#HACKATHON_STAT

        :type increase: int
        :param increase: increase of the count. Can be positive or negative
        """
        stat = HackathonStat.objects(hackathon=hackathon,
                                     type=stat_type).first()
        if stat:
            stat.count += increase
        else:
            stat = HackathonStat(hackathon=hackathon,
                                 type=stat_type,
                                 count=increase)

        if stat.count < 0:
            stat.count = 0
        stat.update_time = self.util.get_now()
        stat.save()
Exemplo n.º 2
0
    def update_hackathon_stat(self, hackathon, stat_type, count):
        """Increase or descrease the count for certain hackathon stat

        :type hackathon: Hackathon
        :param hackathon: instance of Hackathon to be counted

        :type stat_type: str|unicode
        :param stat_type: type of stat that defined in constants.py#HACKATHON_STAT

        :type count: int
        :param count: the new count for this stat item
        """
        stat = HackathonStat.objects(hackathon=hackathon,
                                     type=stat_type).first()
        if stat:
            stat.count = count
            stat.update_time = self.util.get_now()
        else:
            stat = HackathonStat(hackathon=hackathon,
                                 type=stat_type,
                                 count=count)

        if stat.count < 0:
            stat.count = 0
        stat.save()
Exemplo n.º 3
0
    def increase_hackathon_stat(self, hackathon, stat_type, increase):
        """Increase or descrease the count for certain hackathon stat

        :type hackathon: Hackathon
        :param hackathon: instance of Hackathon to be counted

        :type stat_type: str|unicode
        :param stat_type: type of stat that defined in constants.py#HACKATHON_STAT

        :type increase: int
        :param increase: increase of the count. Can be positive or negative
        """
        stat = HackathonStat.objects(hackathon=hackathon, type=stat_type).first()
        if stat:
            stat.count += increase
        else:
            stat = HackathonStat(hackathon=hackathon, type=stat_type, count=increase)

        if stat.count < 0:
            stat.count = 0
        stat.update_time = self.util.get_now()
        stat.save()
Exemplo n.º 4
0
    def update_hackathon_stat(self, hackathon, stat_type, count):
        """Increase or descrease the count for certain hackathon stat

        :type hackathon: Hackathon
        :param hackathon: instance of Hackathon to be counted

        :type stat_type: str|unicode
        :param stat_type: type of stat that defined in constants.py#HACKATHON_STAT

        :type count: int
        :param count: the new count for this stat item
        """
        stat = HackathonStat.objects(hackathon=hackathon, type=stat_type).first()
        if stat:
            stat.count = count
            stat.update_time = self.util.get_now()
        else:
            stat = HackathonStat(hackathon=hackathon, type=stat_type, count=count)

        if stat.count < 0:
            stat.count = 0
        stat.save()