<commit_before>import sys
import logging

from model.base import db_session, init_db
from model.user import User
from model.queue import Queue
from management import PulseManagementAPI, PulseManagementException

logging.basicConfig()
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)

pulse_management = PulseManagementAPI()

def init_and_clear_db():
    # Initializing the database schema
    init_db()

    # Removing all pulse users created by the web app
    for user in User.query.all():
        try:
            pulse_management.delete_user(user.username)
        except PulseManagementException:
            pass

    # Clearing the database from old data
    Queue.query.delete()
    User.query.delete()

    logger.info('Finished initializing database')


def dummy_data():
    # Dummy test user
    dummy_user = User.new_user(
        email='<EMAIL>', username='dummy', password='<PASSWORD>')
    dummy_user.activate(pulse_management)
    db_session.add(dummy_user)
    db_session.commit()

    # And a dummy queue
    dummy_queue = Queue(name='iamadummyqueue', size=2, owner=dummy_user)
    db_session.add(dummy_queue)
    db_session.commit()

    # Test admin user
    admin = User.new_user(
        email='<EMAIL>', username='admin', password='<PASSWORD>', admin=True)
    admin.activate(pulse_management)
    db_session.add(admin)
    db_session.commit()

    logger.info('Finished generating dummy data')

if __name__ == '__main__':
    init_and_clear_db()<commit_msg>Better dummy data (with different users and queues in different states)<commit_after>import sys
import logging

from model.base import db_session, init_db
from model.user import User
from model.queue import Queue
from management import PulseManagementAPI, PulseManagementException
import config

logging.basicConfig()
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)

pulse_management = PulseManagementAPI()

def init_and_clear_db():
    # Initializing the database schema
    init_db()

    # Removing all pulse users created by the web app
    for user in User.query.all():
        try:
            pulse_management.delete_user(user.username)
        except PulseManagementException:
            pass

    # Clearing the database from old data
    Queue.query.delete()
    User.query.delete()

    logger.info('Finished initializing database')


def dummy_data():
    # Dummy test users
    for i in xrange(4):
        dummy_user = User.new_user(
            email='<EMAIL>(i), username='dummy{}'.format(i),
            password='<PASSWORD>')
        dummy_user.activate(pulse_management)
        db_session.add(dummy_user)
    db_session.commit()

    users = User.query.all()

    # And some dummy queues
    dummy_queue = Queue(name='dummy-empty-queue', size=0, owner=users[0])
    db_session.add(dummy_queue)
    db_session.commit()

    dummy_queue = Queue(name='dummy-non-empty-queue', size=config.warn_queue_size/5, owner=users[0])
    db_session.add(dummy_queue)
    db_session.commit()

    dummy_queue = Queue(name='dummy-warning-queue', size=config.warn_queue_size + 1, owner=users[1])
    db_session.add(dummy_queue)
    db_session.commit()

    dummy_queue = Queue(name='dummy-deletion-queue', size=config.del_queue_size + 10000, owner=users[2])
    db_session.add(dummy_queue)
    db_session.commit()


    # Test admin user
    admin = User.new_user(
        email='<EMAIL>', username='admin', password='<PASSWORD>', admin=True)
    admin.activate(pulse_management)
    db_session.add(admin)
    db_session.commit()

    logger.info('Finished generating dummy data')

if __name__ == '__main__':
    init_and_clear_db()
{'fraction_non_alphanumeric': 0.10375034218450589, 'fraction_numerical': 0.0038324664659184233, 'mean_word_length': 3.782722513089005, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6459155', 'n_tokens_mistral': 1129, 'n_tokens_neox': 1097, 'n_words': 251}