You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
1.8 KiB
Python
72 lines
1.8 KiB
Python
2 years ago
|
#!/usr/bin/env python3
|
||
|
|
||
|
# export suchwow data for the purpose of importing into new model definitions
|
||
|
|
||
|
import pickle
|
||
|
|
||
|
from suchwow.models import Post, Moderator, Profile, Ban, AuditEvent
|
||
|
from suchwow import wownero
|
||
|
|
||
|
wallet = wownero.Wallet()
|
||
|
if not wallet.connected:
|
||
|
print('Wallet not connected')
|
||
|
exit()
|
||
|
|
||
|
all_posts = Post.select()
|
||
|
all_mods = Moderator.select()
|
||
|
all_profiles = Profile.select()
|
||
|
all_bans = Ban.select()
|
||
|
all_audits = AuditEvent.select()
|
||
|
all_data = {
|
||
|
'posts': list(),
|
||
|
'moderators': list(),
|
||
|
'profiles': list(),
|
||
|
'bans': list(),
|
||
|
'auditevents': list()
|
||
|
}
|
||
|
|
||
|
|
||
|
for post in all_posts:
|
||
|
all_data['posts'].append({
|
||
|
'id': post.id,
|
||
|
'title': post.title,
|
||
|
'text': post.text,
|
||
|
'submitter': post.submitter,
|
||
|
'image_name': post.image_name,
|
||
|
'readonly': post.readonly,
|
||
|
'hidden': post.hidden,
|
||
|
'account_index': post.account_index,
|
||
|
'address_index': post.address_index,
|
||
|
'timestamp': post.timestamp,
|
||
|
'reddit_url': post.reddit_url,
|
||
|
'to_reddit': post.to_reddit,
|
||
|
'to_discord': post.to_discord,
|
||
|
'approved': post.approved,
|
||
|
'txes': wallet.transfers(post.account_index)
|
||
|
})
|
||
|
|
||
|
for mod in all_mods:
|
||
|
all_data['moderators'].append(mod.username)
|
||
|
|
||
|
for profile in all_profiles:
|
||
|
all_data['profiles'].append({
|
||
|
'username': profile.username,
|
||
|
'address': profile.address
|
||
|
})
|
||
|
|
||
|
for ban in all_bans:
|
||
|
all_data['bans'].append({
|
||
|
'username': ban.user.username,
|
||
|
'reason': ban.reason,
|
||
|
'timestamp': ban.timestamp
|
||
|
})
|
||
|
|
||
|
for event in all_audits:
|
||
|
all_data['auditevents'].append({
|
||
|
'username': event.user.username,
|
||
|
'timestamp': event.timestamp,
|
||
|
'action': event.action
|
||
|
})
|
||
|
|
||
|
with open('data/migrate_data.pkl', 'wb') as f:
|
||
|
f.write(pickle.dumps(all_data))
|