mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-24 18:34:18 +00:00
First metadata addition
This commit is contained in:
parent
eb5e5c3253
commit
d54a3d3f33
@ -7,6 +7,7 @@ from ..events import connected_sessions
|
||||
from ..models import Corpus, User
|
||||
import cqi
|
||||
import math
|
||||
from app import logger
|
||||
|
||||
|
||||
'''
|
||||
@ -36,14 +37,27 @@ def corpus_analysis_get_meta_data(corpus_id):
|
||||
db_corpus = Corpus.query.get(corpus_id)
|
||||
# TODO: Check if current user is actually the creator of the corpus?
|
||||
metadata = {}
|
||||
metadata["corpus_name"] = db_corpus.title
|
||||
metadata["corpus_description"] = db_corpus.description
|
||||
metadata["corpus_creation_date"] = db_corpus.creation_date.isoformat()
|
||||
metadata['corpus_name'] = db_corpus.title
|
||||
metadata['corpus_description'] = db_corpus.description
|
||||
metadata['corpus_creation_date'] = db_corpus.creation_date.isoformat()
|
||||
metadata['corpus_last_edited_date'] = db_corpus.last_edited_date.isoformat()
|
||||
# get meta data from corpus in cqp server
|
||||
client = corpus_analysis_clients.get(request.sid)
|
||||
client_corpus = client.corpora.get('CORPUS')
|
||||
metadata["corpus_properties"] = client_corpus.attrs['properties']
|
||||
# metadata["corpus_properties"] = client.api.corpus_properties('CORPUS')
|
||||
metadata['corpus_properties'] = client_corpus.attrs['properties']
|
||||
metadata['corpus_size_tokens'] = client_corpus.attrs['size']
|
||||
|
||||
texts = {}
|
||||
text_attr = client_corpus.structural_attributes.get('text')
|
||||
for text_id in range(0, (text_attr.attrs['size'])):
|
||||
texts[text_id] = {}
|
||||
logger.warning('Text ID: {}'.format(text_id))
|
||||
struct_attrs = client_corpus.structural_attributes.list(filters={'part_of': text_attr})
|
||||
for struct_attr in struct_attrs:
|
||||
logger.warning(struct_attr)
|
||||
for struct_id in list(range(0, struct_attr.attrs['size'])):
|
||||
logger.warning(struct_attr.values_by_ids([struct_id]))
|
||||
|
||||
payload = metadata
|
||||
response = {'code': 200, 'desc': 'Corpus meta data', 'msg': 'OK', 'payload': payload}
|
||||
socketio.emit('corpus_analysis_send_meta_data', response, room=request.sid)
|
||||
|
@ -1,3 +1,4 @@
|
||||
from datetime import datetime
|
||||
from .. import db
|
||||
from ..decorators import background
|
||||
from ..models import Corpus, CorpusFile
|
||||
@ -45,6 +46,7 @@ def build_corpus(corpus_id, *args, **kwargs):
|
||||
master_element_tree.write(output_file, xml_declaration=True,
|
||||
encoding='utf-8')
|
||||
corpus.status = 'submitted'
|
||||
corpus.last_edited_date = datetime.utcnow()
|
||||
db.session.commit()
|
||||
|
||||
|
||||
|
@ -413,6 +413,7 @@ class Corpus(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
# Fields
|
||||
creation_date = db.Column(db.DateTime(), default=datetime.utcnow)
|
||||
last_edited_date = db.Column(db.DateTime(), default=datetime.utcnow)
|
||||
description = db.Column(db.String(255))
|
||||
status = db.Column(db.String(16))
|
||||
title = db.Column(db.String(32))
|
||||
|
@ -80,9 +80,11 @@ class ResultsJSON {
|
||||
class MetaDataJSON {
|
||||
// Sets empty object structure. Also usefull to delete old results.
|
||||
init() {
|
||||
this["corpus_name"] = "";
|
||||
this["corpus_description"] = "";
|
||||
this["corpus_creation_date"] = "";
|
||||
this["corpus_properties"] = "";
|
||||
this["corpus_name"] = undefined;
|
||||
this["corpus_description"] = undefined;
|
||||
this["corpus_creation_date"] = undefined;
|
||||
this["corpus_last_edited_date"] = undefined;
|
||||
this["corpus_properties"] = undefined;
|
||||
this["corpus_size_tokens"] = undefined;
|
||||
}
|
||||
}
|
@ -2,7 +2,9 @@ function recvMetaData(payload) {
|
||||
results.metaDataJSON.corpus_name = payload.corpus_name;
|
||||
results.metaDataJSON.corpus_description = payload.corpus_description;
|
||||
results.metaDataJSON.corpus_creation_date = payload.corpus_creation_date;
|
||||
results.metaDataJSON.corpus_last_edited_date = payload.corpus_last_edited_date;
|
||||
results.metaDataJSON.corpus_properties = payload.corpus_properties;
|
||||
results.metaDataJSON.corpus_size_tokens = payload.corpus_size_tokens;
|
||||
console.log(results.metaDataJSON);
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
<li>Username: {{ user.username }}</li>
|
||||
<li>Email: {{ user.email }}</li>
|
||||
<li>ID: {{ user.id }}</li>
|
||||
<li>Member sinse: {{ user.member_since.strftime('%m/%d/%Y, %H:%M:%S %p') }}</li>
|
||||
<li>Member since: {{ user.member_since.strftime('%m/%d/%Y, %H:%M:%S %p') }}</li>
|
||||
<li>Confirmed status: {{ user.confirmed }}</li>
|
||||
<li>Last seen: {{ user.last_seen.strftime('%m/%d/%Y, %H:%M:%S %p') }}</li>
|
||||
<li>Role ID: {{ user.role_id }}</li>
|
||||
|
@ -31,6 +31,12 @@
|
||||
<label for="creation-date">Creation date</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col s12 m6">
|
||||
<div class="input-field">
|
||||
<input disabled value="{{ corpus.last_edited_date.strftime('%m/%d/%Y, %H:%M:%S %p') }}" id="last_edited_date" type="text" class="validate">
|
||||
<label for="creation-date">Last edited</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-action right-align">
|
||||
|
28
migrations/versions/68772b6560c3_.py
Normal file
28
migrations/versions/68772b6560c3_.py
Normal file
@ -0,0 +1,28 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 68772b6560c3
|
||||
Revises: 49a42c69e523
|
||||
Create Date: 2020-04-28 07:47:40.495698
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '68772b6560c3'
|
||||
down_revision = '49a42c69e523'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('corpora', sa.Column('last_edited_date', sa.DateTime(), nullable=True))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('corpora', 'last_edited_date')
|
||||
# ### end Alembic commands ###
|
Loading…
Reference in New Issue
Block a user