diff --git a/app/corpora/views.py b/app/corpora/views.py index 096e8957..2cc907d5 100644 --- a/app/corpora/views.py +++ b/app/corpora/views.py @@ -54,12 +54,14 @@ def corpus(corpus_id): def corpus_analysis(corpus_id): logger = logging.getLogger(__name__) corpus = Corpus.query.get_or_404(corpus_id) + corpus.status = 'start analysis' query = request.args.get('query') logger.warning('Query first: {}'.format(query)) hits_per_page = request.args.get('hits_per_page', 30) context = request.args.get('context', 10) dl_form = QueryDownloadForm() form = QueryForm(hits_per_page=hits_per_page, context=context, query=query) + db.session.commit() if form.validate_on_submit(): logger = logging.getLogger(__name__) logger.warning('Data has been sent!') diff --git a/app/models.py b/app/models.py index 4ccdd2ba..c7d5563a 100644 --- a/app/models.py +++ b/app/models.py @@ -442,6 +442,7 @@ class Corpus(db.Model): status = db.Column(db.String(16)) title = db.Column(db.String(32)) user_id = db.Column(db.Integer, db.ForeignKey('users.id')) + analysis_ip = db.Column(db.String(16)) # Relationships files = db.relationship('CorpusFile', backref='corpus', diff --git a/app/static/js/CorpusList.js b/app/static/js/CorpusList.js index 5c52edf3..489e90a7 100644 --- a/app/static/js/CorpusList.js +++ b/app/static/js/CorpusList.js @@ -83,4 +83,6 @@ CorpusList.STATUS_COLORS = {"unprepared": "grey", "preparable": "orange", "preparing": "yellow", "prepared": "green", - "default": "red"}; + "start analysis": "yellow", + "analysing": "green", + "stop analysis": "red", "default": "red"}; diff --git a/app/templates/corpora/corpus.html.j2 b/app/templates/corpora/corpus.html.j2 index a686aac2..5362bf38 100644 --- a/app/templates/corpora/corpus.html.j2 +++ b/app/templates/corpora/corpus.html.j2 @@ -61,11 +61,13 @@ statusElement.classList.remove(...Object.values(CorpusList.STATUS_COLORS)); statusElement.classList.add(CorpusList.STATUS_COLORS[status] || CorpusList.STATUS_COLORS['default']); statusElement.innerText = status; - if (status === 'prepared') { + if (status === 'prepared' || status === 'start analysis' || status === 'analysing') { var analyseBtn = document.getElementById('analyse'); analyseBtn.classList.remove('hide'); + } + if (status === 'prepared' || status === 'start analysis' || status === 'analysing') { var prepareBtn = document.getElementById('prepare'); - prepareBtn.classList.add('hide') + prepareBtn.classList.add('hide'); } } } diff --git a/migrations/versions/0aa38a7973c5_.py b/migrations/versions/0aa38a7973c5_.py new file mode 100644 index 00000000..d242aaf5 --- /dev/null +++ b/migrations/versions/0aa38a7973c5_.py @@ -0,0 +1,28 @@ +"""empty message + +Revision ID: 0aa38a7973c5 +Revises: 1210adfe1e34 +Create Date: 2019-11-06 09:33:46.296653 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '0aa38a7973c5' +down_revision = '1210adfe1e34' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('corpora', sa.Column('analysis_ip', sa.String(length=16), nullable=True)) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('corpora', 'analysis_ip') + # ### end Alembic commands ###