Add curren ttoken and max token nr

This commit is contained in:
Stephan Porada 2020-05-04 12:08:43 +02:00
parent c49684611a
commit cb8f3faae0
4 changed files with 50 additions and 1 deletions

View File

@ -61,6 +61,11 @@ def corpus_analysis_get_meta_data(corpus_id):
metadata['corpus_cqi_py_version'] = cqi.version
metadata['corpus_cqpserver_version'] = 'CQPserver v3.4.22' # TODO: make this dynamically
# write some metadata to the db
db_corpus.current_nr_of_tokens = metadata['corpus_size_tokens']
db.session.commit()
# emit data
payload = metadata
response = {'code': 200, 'desc': 'Corpus meta data', 'msg': 'OK', 'payload': payload}
socketio.emit('corpus_analysis_send_meta_data', response, room=request.sid)

View File

@ -31,7 +31,7 @@ class Role(db.Model):
# Fields
default = db.Column(db.Boolean, default=False, index=True)
name = db.Column(db.String(64), unique=True)
permissions = db.Column(db.Integer)
permissions = db.Column(db.BigInteger)
# Relationships
users = db.relationship('User', backref='role', lazy='dynamic')
@ -443,8 +443,10 @@ class Corpus(db.Model):
user_id = db.Column(db.Integer, db.ForeignKey('users.id'))
# Fields
creation_date = db.Column(db.DateTime(), default=datetime.utcnow)
current_nr_of_tokens = db.Column(db.BigInteger, default=0)
description = db.Column(db.String(255))
last_edited_date = db.Column(db.DateTime(), default=datetime.utcnow)
max_nr_of_tokens = db.Column(db.BigInteger, default=2147483647)
status = db.Column(db.String(16))
title = db.Column(db.String(32))
# Relationships

View File

@ -37,6 +37,14 @@
<label for="creation-date">Last edited</label>
</div>
</div>
<div class="col s12 m6">
<div class="input-field">
<input disabled value="{{ corpus.current_nr_of_tokens }} / {{ corpus.max_nr_of_tokens }}" id="nr_of_tokens" type="text" class="validate">
<label for="creation-date">Nr. of tokens used
<i class="material-icons tooltipped" data-position="bottom" data-tooltip="Current number of tokens in this corpus. Updates after every analyze session.">help</i>
</label>
</div>
</div>
</div>
</div>
<div class="card-action right-align">

View File

@ -0,0 +1,34 @@
"""empty message
Revision ID: 62233e0cb2c7
Revises: 68772b6560c3
Create Date: 2020-05-04 09:42:25.408403
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '62233e0cb2c7'
down_revision = '68772b6560c3'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('corpora', sa.Column('current_nr_of_tokens', sa.BigInteger(), nullable=True))
op.add_column('corpora', sa.Column('max_nr_of_tokens', sa.BigInteger(), nullable=True))
op.drop_column('corpora', 'analysis_container_name')
op.drop_column('corpora', 'analysis_container_ip')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('corpora', sa.Column('analysis_container_ip', sa.VARCHAR(length=16), autoincrement=False, nullable=True))
op.add_column('corpora', sa.Column('analysis_container_name', sa.VARCHAR(length=32), autoincrement=False, nullable=True))
op.drop_column('corpora', 'max_nr_of_tokens')
op.drop_column('corpora', 'current_nr_of_tokens')
# ### end Alembic commands ###