Skip to content

Commit

Permalink
fix remarks
Browse files Browse the repository at this point in the history
  • Loading branch information
kudzinp committed Nov 6, 2018
1 parent d62554e commit ad241f7
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions scripts/posting_script/posts.py
@@ -1,5 +1,6 @@
import dbs
import json
from datetime import datetime

def create_tags(metadata_tags):
tags = []
Expand All @@ -11,6 +12,16 @@ def create_tags(metadata_tags):

return tags

def level_post(parent_id):
if (parent_id):
cb_posts = dbs.cyberway_db["posttable"]
parent_post = cb_posts.find_one({"id": parent_id})
if not parent_post:
return 0

return parent_post["level"] + 1

return 0

def convert_posts():
golos_posts = dbs.golos_db['comment_object']
Expand All @@ -22,7 +33,6 @@ def convert_posts():
for doc in golos_posts.find():

try:

if (doc["removed"]):
continue

Expand All @@ -37,14 +47,14 @@ def convert_posts():
"id": dbs.convert_hash(doc["permlink"]),
"date": doc["last_update"],
"parentacc": doc["parent_author"],
"parent_id": 0,
"parent_id": dbs.convert_hash(doc["parent_permlink"]),
"tokenprop": 0,
"beneficiaries": "",
"rewardweight": doc["reward_weight"],
"state": messagestate,
"childcount": doc["children"],
"closed": "false",
"level": "",
"level": level_post(dbs.convert_hash(doc["parent_permlink"])),
"_SCOPE_": doc["author"],
"_PAYER_": "gls.publish",
"_SIZE_": 50
Expand All @@ -70,7 +80,7 @@ def convert_posts():

content = {
"id": dbs.convert_hash(doc["permlink"]),
"headermssg": "",
"headermssg": doc["title"],
"bodymssg": doc["body"],
"languagemssg": "",
"tags": tags,
Expand All @@ -83,8 +93,9 @@ def convert_posts():

i += 1
dbs.printProgressBar(i + 1, length, prefix = 'Progress:', suffix = 'Complete', length = 50)
except Exception:
except Exception as e:
print(doc)
print(traceback.format_exc())

return True

0 comments on commit ad241f7

Please sign in to comment.