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 7b5c0822ff
commit 2053e116a4
2 changed files with 6 additions and 10 deletions

View file

@ -3,8 +3,8 @@
from peewee import Model from peewee import Model
from peewee import CharField from peewee import CharField
from peewee import TextField
from peewee import DateTimeField from peewee import DateTimeField
from peewee import IntegerField
from peewee import ForeignKeyField from peewee import ForeignKeyField
from app.models.site import Site from app.models.site import Site
from app.services.database import get_db from app.services.database import get_db
@ -12,12 +12,11 @@ from app.services.database import get_db
class Comment(Model): class Comment(Model):
url = CharField() url = CharField()
date = DateTimeField() published = DateTimeField()
rel_index = IntegerField()
author_name = CharField() author_name = CharField()
author_email = CharField(default='') author_email = CharField(default='')
author_site = CharField() author_site = CharField(default='')
content = CharField() content = TextField()
site = ForeignKeyField(Site, related_name='site') site = ForeignKeyField(Site, related_name='site')
class Meta: class Meta:

View file

@ -53,8 +53,6 @@ def convert_comment(db, site, filename):
else: else:
continue continue
content = content + line content = content + line
logger.debug(d)
logger.debug(content)
# create DB record # create DB record
comment = Comment(site=site, author_name=d['author'], content=content) comment = Comment(site=site, author_name=d['author'], content=content)
@ -67,7 +65,7 @@ def convert_comment(db, site, filename):
# else: # else:
# comment.url = d['article'] # comment.url = d['article']
if 'date' in d: if 'date' in d:
comment.date = d['date'] comment.published = d['date']
comment.save() comment.save()
@ -86,14 +84,13 @@ def convert(db, site_name, url, comment_dir):
site = Site.create(name=site_name, url=url, token='') 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 dirpath, dirs, files in os.walk(comment_dir):
for filename in files: for filename in files:
if filename.endswith(('.md',)): if filename.endswith(('.md',)):
comment_file = '/'.join([dirpath, filename]) comment_file = '/'.join([dirpath, filename])
convert_comment(db, site, comment_file) convert_comment(db, site, comment_file)
else: else:
logger.debug('ignore file %s' % filename) logger.warn('ignore file %s' % filename)
@clize @clize