diff --git a/app/corpora/events.py b/app/corpora/events.py index 7683d7b9..99b8f656 100644 --- a/app/corpora/events.py +++ b/app/corpora/events.py @@ -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) diff --git a/app/models.py b/app/models.py index db6d8640..973c7a84 100644 --- a/app/models.py +++ b/app/models.py @@ -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 diff --git a/app/templates/corpora/corpus.html.j2 b/app/templates/corpora/corpus.html.j2 index b07cad0a..f8604b81 100644 --- a/app/templates/corpora/corpus.html.j2 +++ b/app/templates/corpora/corpus.html.j2 @@ -37,6 +37,14 @@ +
+
+ + +
+
diff --git a/migrations/versions/62233e0cb2c7_.py b/migrations/versions/62233e0cb2c7_.py new file mode 100644 index 00000000..d8700503 --- /dev/null +++ b/migrations/versions/62233e0cb2c7_.py @@ -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 ###