-
Notifications
You must be signed in to change notification settings - Fork 2
/
models.py
65 lines (55 loc) · 2.18 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
from google.appengine.ext import db
# Copyright (C) 2010-2012 vvoody <[email protected]>
# Souce codes licensed under GPLv3, see LICENSE.
class Members(db.Model):
user = db.UserProperty() # users.get_current_user()
username = db.StringProperty() # unique in this site, immutable(/signup)
fullname = db.StringProperty() # editable later(/setting)
bio = db.StringProperty()
following = db.StringListProperty(indexed=False)
followers = db.StringListProperty(indexed=False)
# ancestor(Members)
class Tweets(db.Model):
content = db.StringProperty()
bywho = db.StringProperty()
when = db.DateTimeProperty(auto_now_add=True)
reply_to_tweet = db.IntegerProperty()
reply_to = db.StringProperty()
# used for get the tweet directly not set the ancestor
tid = db.IntegerProperty()
# ancestor(Members)
class Counters(db.Model):
tweets_counter = db.IntegerProperty(default=0)
favorites_counter = db.IntegerProperty(default=0)
following_counter = db.IntegerProperty(default=0)
followers_counter = db.IntegerProperty(default=0)
# ancestor(Members)
class Replies(db.Model):
# t = Replies(parent=some_user.key(), tweet = some_tweet.key())
tweet = db.ReferenceProperty(Tweets)
# ancestor(Members)
class Favorites(db.Model):
# f = Favorites(parent=some_user.key(), tweet = some_tweet.key())
tweet = db.ReferenceProperty(Tweets)
# ancestor(Members)
# GET my timeline:
# TimelineQueue.all().ancestor(user).filter('active', True).order('-when')
# UNFOLLOW someone
# TimelineQueue.all().ancestor(user).filter('bywho', sb_unfollowed).active = False
class TimelineQueue(db.Model):
tweet = db.ReferenceProperty(Tweets)
bywho = db.StringProperty()
active = db.BooleanProperty(default=True) # remove from timeline
faved = db.BooleanProperty(default=False)
when = db.DateTimeProperty()
# auto increment_counter of tweet id
class SysCounters(db.Model):
counter = db.IntegerProperty(default=0)
# key_name -> username+size like 'katenormal'
class Avatars(db.Model):
content = db.BlobProperty()
# Directs
class Directs(db.Model):
sender = db.StringProperty()
receiver = db.StringProperty()
content = db.StringProperty()