<commit_before>from peewee import *
from pprint import pprint
from time import time

db = MySQLDatabase('sentinel', host='127.0.0.1', user='dashdrive', passwd='<PASSWORD>')

# === models ===

class BaseModel(Model):
    def get_dict(self):
      dikt = {}
      for field_name in self._meta.sorted_field_names:
        dikt[ field_name ] = self.__getattribute__( field_name )
      return dikt

    class Meta:
      database = db

class PeeWeeAction(BaseModel):
    id = IntegerField(primary_key = True)
    governance_object_id = IntegerField(unique=True)
    absolute_yes_count = IntegerField()
    yes_count = IntegerField()
    no_count = IntegerField()
    abstain_count = IntegerField()
    class Meta:
      db_table = 'action'

class PeeWeeEvent(BaseModel):
    id = IntegerField(primary_key = True)
    governance_object_id = IntegerField(unique=True)
    start_time = IntegerField(default=int(time()))
    prepare_time = IntegerField()
    submit_time = IntegerField()
    error_time = IntegerField()
    error_message = CharField()
    class Meta:
      db_table = 'event'

class User(BaseModel):
    username = CharField(primary_key = True)
    userkey  = CharField()
    email    = CharField()
    created_at = DateTimeField()
    updated_at = DateTimeField()
    class Meta:
      db_table = 'users'

class Setting(BaseModel):
    id = IntegerField(primary_key = True)
    datetime = IntegerField()
    setting  = CharField()
    name     = CharField()
    value    = CharField()
    class Meta:
      db_table = 'setting'

class PeeWeeProposal(BaseModel):
    id = IntegerField(primary_key = True)
    governance_object_id = IntegerField(unique=True)
    proposal_name = CharField(unique=True)
    start_epoch = IntegerField()
    end_epoch = IntegerField()
    payment_address = CharField()
    payment_amount = DecimalField(max_digits=16, decimal_places=8)
    class Meta:
      db_table = 'proposal'

class PeeWeeSuperblock(BaseModel):
    id = IntegerField(primary_key = True)
    governance_object_id = IntegerField(unique=True)
    superblock_name      = CharField() # unique?
    event_block_height   = IntegerField()
    payment_addresses    = TextField()
    payment_amounts      = TextField()
    class Meta:
      db_table = 'superblock'

class PeeWeeGovernanceObject(BaseModel):
    id = IntegerField(primary_key = True)
    parent_id = IntegerField()
    object_creation_time = IntegerField()
    object_hash = CharField()
    object_parent_hash = CharField()
    object_name = CharField()
    object_type = IntegerField()
    object_revision = IntegerField()
    object_data = TextField()
    object_fee_tx = CharField()

    class Meta:
      db_table = 'governance_object'

    @classmethod
    def object_with_name_exists(self, name):
        count = self.select().where(self.object_name == name).count()
        return count > 0

# === /models ===

db.connect()

#for e in Event.select():
#    print e.id
#    e.prepare_time = int(time())
#    e.save()
#    pprint(vars(e))
<commit_msg>remove old test data from models file<commit_after>from peewee import *
from pprint import pprint
from time import time

db = MySQLDatabase('sentinel', host='127.0.0.1', user='dashdrive', passwd='<PASSWORD>')

# === models ===

class BaseModel(Model):
    def get_dict(self):
      dikt = {}
      for field_name in self._meta.sorted_field_names:
        dikt[ field_name ] = self.__getattribute__( field_name )
      return dikt

    class Meta:
      database = db

class PeeWeeAction(BaseModel):
    id = IntegerField(primary_key = True)
    governance_object_id = IntegerField(unique=True)
    absolute_yes_count = IntegerField()
    yes_count = IntegerField()
    no_count = IntegerField()
    abstain_count = IntegerField()
    class Meta:
      db_table = 'action'

class PeeWeeEvent(BaseModel):
    id = IntegerField(primary_key = True)
    governance_object_id = IntegerField(unique=True)
    start_time = IntegerField(default=int(time()))
    prepare_time = IntegerField()
    submit_time = IntegerField()
    error_time = IntegerField()
    error_message = CharField()
    class Meta:
      db_table = 'event'

class User(BaseModel):
    username = CharField(primary_key = True)
    userkey  = CharField()
    email    = CharField()
    created_at = DateTimeField()
    updated_at = DateTimeField()
    class Meta:
      db_table = 'users'

class Setting(BaseModel):
    id = IntegerField(primary_key = True)
    datetime = IntegerField()
    setting  = CharField()
    name     = CharField()
    value    = CharField()
    class Meta:
      db_table = 'setting'

class PeeWeeProposal(BaseModel):
    id = IntegerField(primary_key = True)
    governance_object_id = IntegerField(unique=True)
    proposal_name = CharField(unique=True)
    start_epoch = IntegerField()
    end_epoch = IntegerField()
    payment_address = CharField()
    payment_amount = DecimalField(max_digits=16, decimal_places=8)
    class Meta:
      db_table = 'proposal'

class PeeWeeSuperblock(BaseModel):
    id = IntegerField(primary_key = True)
    governance_object_id = IntegerField(unique=True)
    superblock_name      = CharField() # unique?
    event_block_height   = IntegerField()
    payment_addresses    = TextField()
    payment_amounts      = TextField()
    class Meta:
      db_table = 'superblock'

class PeeWeeGovernanceObject(BaseModel):
    id = IntegerField(primary_key = True)
    parent_id = IntegerField()
    object_creation_time = IntegerField()
    object_hash = CharField()
    object_parent_hash = CharField()
    object_name = CharField()
    object_type = IntegerField()
    object_revision = IntegerField()
    object_data = TextField()
    object_fee_tx = CharField()

    class Meta:
      db_table = 'governance_object'

    @classmethod
    def object_with_name_exists(self, name):
        count = self.select().where(self.object_name == name).count()
        return count > 0

# === /models ===

db.connect()


{'fraction_non_alphanumeric': 0.10196539559885771, 'fraction_numerical': 0.0033596505963379808, 'mean_word_length': 3.503782148260212, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '7168594', 'n_tokens_mistral': 1869, 'n_tokens_neox': 1850, 'n_words': 398}