aboutsummaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorrr-2016-05-28 11:44:16 +0200
committerrr-2016-05-29 12:40:36 +0200
commit658b95aad7c22c5bb67494cc9e6f57c2332a6252 (patch)
tree14f1512c1bee7dffb5dcedfcf400c75dfa7a2893 /server
parentd7e46e23ab1261304a3c4c73a65fb133279927a0 (diff)
server/tools: fix note importing
Diffstat (limited to 'server')
-rwxr-xr-xserver/migrate-v125
1 files changed, 14 insertions, 11 deletions
diff --git a/server/migrate-v1 b/server/migrate-v1
index 54cf0fd..eafd3e2 100755
--- a/server/migrate-v1
+++ b/server/migrate-v1
@@ -19,6 +19,19 @@ def read_file(path):
with open(path, 'rb') as handle:
return handle.read()
+def translate_note_polygon(row):
+ x, y, w, h = row['x'], row['y'], row['width'], row['height']
+ x /= 100.0
+ y /= 100.0
+ w /= 100.0
+ h /= 100.0
+ return [
+ (x, y ),
+ (x + w, y ),
+ (x + w, y + h),
+ (x, y + h),
+ ]
+
def get_v1_session(args):
dsn = '{schema}://{user}:{password}@{host}:{port}/{name}?charset=utf8'.format(
schema='mysql+pymysql',
@@ -259,20 +272,10 @@ def import_post_notes(unused_post_ids, v1_session, v2_session):
for row in exec_query(v1_session, 'SELECT * FROM postNotes'):
if row['postId'] in unused_post_ids:
continue
- x, y, w, h = row['x'], row['y'], row['width'], row['height']
- x /= 100
- y /= 100
- w /= 100
- h /= 100
post_note = db.PostNote()
post_note.post_id = row['postId']
post_note.text = row['text']
- post_note.polygon = [
- (x, y ),
- (x + w, y ),
- (x + w, y + w),
- (x, y + w),
- ]
+ post_note.polygon = translate_note_polygon(row)
v2_session.add(post_note)
v2_session.commit()

© 2015 - 2026 Jakob L. Kreuze