From a116d5bc01db915aa19f72c9b13c7ee1aa6d1b45 Mon Sep 17 00:00:00 2001 From: Yax Date: Fri, 1 May 2015 19:29:26 +0200 Subject: [PATCH] relative index is not useful. Peewee has paging capability built-in --- app/models/comment.py | 9 ++++----- tools/pecosys2stacosys.py | 7 ++----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/app/models/comment.py b/app/models/comment.py index f86d4e1..910597a 100644 --- a/app/models/comment.py +++ b/app/models/comment.py @@ -3,8 +3,8 @@ from peewee import Model from peewee import CharField +from peewee import TextField from peewee import DateTimeField -from peewee import IntegerField from peewee import ForeignKeyField from app.models.site import Site from app.services.database import get_db @@ -12,12 +12,11 @@ from app.services.database import get_db class Comment(Model): url = CharField() - date = DateTimeField() - rel_index = IntegerField() + published = DateTimeField() author_name = CharField() author_email = CharField(default='') - author_site = CharField() - content = CharField() + author_site = CharField(default='') + content = TextField() site = ForeignKeyField(Site, related_name='site') class Meta: diff --git a/tools/pecosys2stacosys.py b/tools/pecosys2stacosys.py index dcca732..c06e098 100644 --- a/tools/pecosys2stacosys.py +++ b/tools/pecosys2stacosys.py @@ -53,8 +53,6 @@ def convert_comment(db, site, filename): else: continue content = content + line - logger.debug(d) - logger.debug(content) # create DB record comment = Comment(site=site, author_name=d['author'], content=content) @@ -67,7 +65,7 @@ def convert_comment(db, site, filename): # else: # comment.url = d['article'] if 'date' in d: - comment.date = d['date'] + comment.published = d['date'] comment.save() @@ -86,14 +84,13 @@ def convert(db, site_name, url, comment_dir): site = Site.create(name=site_name, url=url, token='') - logger.info('Comment directory %s' % comment_dir) for dirpath, dirs, files in os.walk(comment_dir): for filename in files: if filename.endswith(('.md',)): comment_file = '/'.join([dirpath, filename]) convert_comment(db, site, comment_file) else: - logger.debug('ignore file %s' % filename) + logger.warn('ignore file %s' % filename) @clize