relative index is not useful. Peewee has paging capability built-in

This commit is contained in:
Yax 2015-05-01 19:29:26 +02:00
parent 7441a80217
commit a116d5bc01
2 changed files with 6 additions and 10 deletions

View file

@ -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:

View file

@ -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