def increase(counter_name): """ Increase the counter value in the database. If the counter does not exist, yet, create the counter. :param counter_name: The name/identifier of the counter :return: the new integer value of the counter """ counter = EventCounter.query.filter_by(counter_name=counter_name).first() if not counter: counter = EventCounter(counter_name, 0) counter.save() counter.increase() return counter.counter_value
def increase(counter_name): """ Increase the counter value in the database. If the counter does not exist yet, create the counter. :param counter_name: The name/identifier of the counter :return: None """ # If there is no table row for the current node, create one. node = get_privacyidea_node() counter = EventCounter.query.filter_by(counter_name=counter_name, node=node).first() if not counter: counter = EventCounter(counter_name, 0, node=node) counter.save() counter.increase()