-
Notifications
You must be signed in to change notification settings - Fork 2
/
models.py
274 lines (226 loc) · 9.25 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
from django.db import models
from .constants import FOLLOW_STATE_FOLLOWING, FOLLOW_STATE_MUTE
class Account(models.Model):
name = models.CharField(unique=True, max_length=16)
created_at = models.DateTimeField()
reputation = models.FloatField()
display_name = models.CharField(max_length=20, blank=True, null=True)
about = models.CharField(max_length=160, blank=True, null=True)
location = models.CharField(max_length=30, blank=True, null=True)
website = models.CharField(max_length=100, blank=True, null=True)
profile_image = models.CharField(max_length=1024)
cover_image = models.CharField(max_length=1024)
followers = models.IntegerField()
following = models.IntegerField()
proxy = models.CharField(max_length=16)
post_count = models.IntegerField()
proxy_weight = models.FloatField()
vote_weight = models.FloatField()
kb_used = models.IntegerField()
rank = models.IntegerField()
active_at = models.DateTimeField()
cached_at = models.DateTimeField()
raw_json = models.TextField(blank=True, null=True)
class Meta:
managed = False
db_table = 'hive_accounts'
ordering = ['-pk']
@property
def follower_list(self):
follower_ids = Follow.objects.filter(
following=self.id, state=FOLLOW_STATE_FOLLOWING).values_list(
'follower', flat=True)
follower_names = Account.objects.filter(
id__in=follower_ids).values_list('name', flat=True)
return follower_names
@property
def following_list(self):
following_ids = Follow.objects.filter(
follower=self.id, state=FOLLOW_STATE_FOLLOWING).values_list(
'following', flat=True)
following_names = Account.objects.filter(
id__in=following_ids).values_list('name', flat=True)
return following_names
@property
def muter_list(self):
muter_ids = Follow.objects.filter(
following=self.id, state=FOLLOW_STATE_MUTE).values_list(
'follower', flat=True)
muter_names = Account.objects.filter(
id__in=muter_ids).values_list('name', flat=True)
return muter_names
@property
def muted_list(self):
muted_ids = Follow.objects.filter(
follower=self.id, state=FOLLOW_STATE_MUTE).values_list(
'following', flat=True)
muted_names = Account.objects.filter(
id__in=muted_ids).values_list('name', flat=True)
return muted_names
class Block(models.Model):
num = models.IntegerField(primary_key=True)
hash = models.CharField(unique=True, max_length=40)
prev = models.ForeignKey('self', models.DO_NOTHING, db_column='prev',
blank=True, null=True)
txs = models.SmallIntegerField()
ops = models.SmallIntegerField()
created_at = models.DateTimeField()
class Meta:
managed = False
db_table = 'hive_blocks'
ordering = ['-num']
class Community(models.Model):
name = models.OneToOneField(Account, models.DO_NOTHING, db_column='name',
primary_key=True)
title = models.CharField(max_length=32)
about = models.CharField(max_length=255)
description = models.CharField(max_length=5000)
lang = models.CharField(max_length=2)
settings = models.TextField()
type_id = models.SmallIntegerField()
is_nsfw = models.BooleanField()
created_at = models.DateTimeField()
class Meta:
managed = False
db_table = 'hive_communities'
class FeedCache(models.Model):
post_id = models.IntegerField()
account_id = models.IntegerField()
created_at = models.DateTimeField()
class Meta:
managed = False
db_table = 'hive_feed_cache'
unique_together = (('post_id', 'account_id'),)
class Flag(models.Model):
account = models.ForeignKey(Account, models.DO_NOTHING, db_column='account')
post = models.ForeignKey('Post', models.DO_NOTHING)
created_at = models.DateTimeField()
notes = models.CharField(max_length=255)
class Meta:
managed = False
db_table = 'hive_flags'
unique_together = (('account', 'post'),)
class Follow(models.Model):
follower = models.IntegerField()
following = models.IntegerField()
state = models.SmallIntegerField()
created_at = models.DateTimeField()
class Meta:
managed = False
db_table = 'hive_follows'
unique_together = (('following', 'follower'),)
class Member(models.Model):
community = models.ForeignKey(Community, models.DO_NOTHING,
db_column='community')
account = models.ForeignKey(Account, models.DO_NOTHING, db_column='account')
is_admin = models.BooleanField()
is_mod = models.BooleanField()
is_approved = models.BooleanField()
is_muted = models.BooleanField()
title = models.CharField(max_length=255)
class Meta:
managed = False
db_table = 'hive_members'
unique_together = (('community', 'account'),)
class Modlog(models.Model):
community = models.ForeignKey(Community, models.DO_NOTHING,
db_column='community')
account = models.ForeignKey(Account, models.DO_NOTHING, db_column='account')
action = models.CharField(max_length=32)
params = models.CharField(max_length=1000)
created_at = models.DateTimeField()
class Meta:
managed = False
db_table = 'hive_modlog'
class Payment(models.Model):
block_num = models.IntegerField()
tx_idx = models.SmallIntegerField()
post = models.ForeignKey('Post', models.DO_NOTHING)
from_account = models.ForeignKey(Account, models.DO_NOTHING,
db_column='from_account', related_name="from_acc")
to_account = models.ForeignKey(Account, models.DO_NOTHING,
db_column='to_account', related_name="to_acc")
amount = models.DecimalField(max_digits=10, decimal_places=3)
token = models.CharField(max_length=5)
class Meta:
managed = False
db_table = 'hive_payments'
class Post(models.Model):
parent = models.ForeignKey('self', models.DO_NOTHING, blank=True, null=True)
author = models.CharField(max_length=255)
permlink = models.CharField(max_length=255)
community = models.CharField(max_length=255)
category = models.CharField(max_length=255)
depth = models.SmallIntegerField()
created_at = models.DateTimeField()
is_deleted = models.BooleanField()
is_pinned = models.BooleanField()
is_muted = models.BooleanField()
is_valid = models.BooleanField()
promoted = models.DecimalField(max_digits=10, decimal_places=3)
class Meta:
managed = False
db_table = 'hive_posts'
unique_together = (('author', 'permlink'),)
ordering = ["-pk"]
class PostTag(models.Model):
post = models.ForeignKey(Post, on_delete=models.DO_NOTHING)
tag = models.CharField(max_length=32)
class Meta:
managed = False
db_table = 'hive_post_tags'
unique_together = (('tag', 'post'),)
class PostCache(models.Model):
post = models.ForeignKey(Post, primary_key=True, on_delete=models.DO_NOTHING)
author = models.CharField(max_length=16)
permlink = models.CharField(max_length=255)
category = models.CharField(max_length=255)
depth = models.SmallIntegerField()
children = models.SmallIntegerField()
author_rep = models.FloatField()
flag_weight = models.FloatField()
total_votes = models.IntegerField()
up_votes = models.IntegerField()
title = models.CharField(max_length=255)
preview = models.CharField(max_length=1024)
img_url = models.CharField(max_length=1024)
payout = models.DecimalField(max_digits=10, decimal_places=3)
promoted = models.DecimalField(max_digits=10, decimal_places=3)
created_at = models.DateTimeField()
payout_at = models.DateTimeField()
updated_at = models.DateTimeField()
is_paidout = models.BooleanField()
is_nsfw = models.BooleanField()
is_declined = models.BooleanField()
is_full_power = models.BooleanField()
is_hidden = models.BooleanField()
is_grayed = models.BooleanField()
rshares = models.BigIntegerField()
sc_trend = models.FloatField()
sc_hot = models.FloatField()
body = models.TextField(blank=True, null=True)
votes = models.TextField(blank=True, null=True)
json = models.TextField(blank=True, null=True)
raw_json = models.TextField(blank=True, null=True)
class Meta:
managed = False
db_table = 'hive_posts_cache'
ordering = ['-post_id',]
class Reblog(models.Model):
account = models.CharField(max_length=255)
post = models.ForeignKey(Post, models.DO_NOTHING)
created_at = models.DateTimeField()
class Meta:
managed = False
db_table = 'hive_reblogs'
unique_together = (('account', 'post'),)
class State(models.Model):
block_num = models.IntegerField(primary_key=True)
db_version = models.IntegerField()
steem_per_mvest = models.DecimalField(max_digits=8, decimal_places=3)
usd_per_steem = models.DecimalField(max_digits=8, decimal_places=3)
sbd_per_steem = models.DecimalField(max_digits=8, decimal_places=3)
dgpo = models.TextField()
class Meta:
managed = False
db_table = 'hive_state'