Beispiel #1
0
class PostVote(MBase):
    """
    All upvotes/downvotes sent to a post
    """
    post_id = columns.BigInt(primary_key=True, partition_key=True)
    user_id = columns.Integer(primary_key=True)
    positive = columns.Boolean(default=True)
    created_at = columns.BigInt(default=unix_time(dt.utcnow()))
Beispiel #2
0
class GithubProject(MBase):
    id = columns.Integer(primary_key=True)
    full_name = columns.Text(index=True)
    description = columns.Text()
    homepage = columns.Text()
    fork = columns.Boolean()
    forks_count = columns.Integer()
    language = columns.Text()
    master_branch = columns.Text()
    name = columns.Text()
    network_count = columns.Integer()
    open_issues = columns.Integer()
    url = columns.Text()
    watchers_count = columns.Integer()
    is_py = columns.Boolean()
    owner = columns.Integer()
    hide = columns.Boolean(default=False)
Beispiel #3
0
class Topic(MBase):
    id = columns.Integer(primary_key=True)
    slug = columns.Text()
    name = columns.Text()
    description = columns.Text()
    last_message_id = columns.BigInt(required=False)
    last_message_time = columns.BigInt(default=unix_time(dt.utcnow()))
    main_topic = columns.Boolean(default=False)
    parent_topic = columns.Integer(required=False)
    subtopics = columns.Set(value_type=columns.Integer)

    def to_dict(self):
        return {
            'slug': self.slug,
            'name': self.name
        }
Beispiel #4
0
class User(Model):
    __table_name__ = "users"

    """
    Model for the User. Will be using this as the auth model.
    """
    username = columns.Text(primary_key=True)
    jiveuserid = columns.Integer(partition_key=True)
    creationdate = columns.DateTime()
    email = columns.Text(partition_key=True)
    firstlogin = columns.Boolean()
    firstname = columns.Text()
    lastloggedin = columns.DateTime()
    lastname = columns.Text()
    lastprofileupdate = columns.DateTime()
    password = columns.Text()
    userid = columns.UUID(default=uuid4())
Beispiel #5
0
class GithubUser(MBase):
    """
    Users that are part of the Github world.
    """
    nick = columns.Text(primary_key=True)
    id = columns.Integer(index=True)
    email = columns.Text()
    followers = columns.Integer()
    following = columns.Integer()
    image = columns.Text()
    blog = columns.Text()
    bio = columns.Text()
    company = columns.Text()
    location = columns.Text()
    name = columns.Text()
    url = columns.Text()
    utype = columns.Text()
    public_gists = columns.Integer()
    public_repos = columns.Integer()
    # Ref user info does not contain all the information.
    full_profile = columns.Boolean(default=True)
Beispiel #6
0
class TestModel(Model):
    id = columns.UUID(primary_key=True, default=lambda: uuid4())
    count = columns.Integer()
    text = columns.Text(required=False)
    a_bool = columns.Boolean(default=False)
Beispiel #7
0
class Post(MBase):
    id = columns.BigInt(index=True, primary_key=True)
    user_id = columns.Integer(required=True, index=True, partition_key=True)
    user_nick = columns.Text()
    text = columns.Text(required=True)
    html = columns.Text(required=False)

    reply_to_id = columns.BigInt()
    reply_to_uid = columns.Integer()
    reply_to_nick = columns.Text()

    ext_id = columns.Text()

    has_url = columns.Boolean()
    has_channel = columns.Boolean()

    # this post is either linked to a DISCUSSION or
    discussion_id = columns.BigInt()
    # CHANNEL or None
    channel_id = columns.Integer()

    spam = columns.Boolean(default=False)
    flagged = columns.Boolean(default=False)
    deleted = columns.Boolean(default=False)

    stats = columns.Map(columns.Ascii, columns.Integer)

    created_at = columns.BigInt(default=unix_time(dt.utcnow()))

    def to_dict(self):
        return {'id': unicode(self.id),
                'text': self.text,
                'html': self.html,
                'user_id': self.user_id,
                'reply_to_id': self.reply_to_id,
                'reply_to_uid': self.reply_to_uid,
                'reply_to_nick': self.reply_to_nick,
                'discussion_id': unicode(self.discussion_id) if self.discussion_id is not None else "",
                'discussion_name': unicode(self.discussion_name) if hasattr(self,"discussion_name") else "",
                'discussion_slug': unicode(self.discussion_slug) if hasattr(self,"discussion_slug") else "",
                'channel_id': self.channel_id,
                'spam': self.spam,
                'flagged': self.flagged,
                'deleted': self.deleted,
                'published_at': self.created_at,
                'ago': self.ago,
                'user': {'id': self.user_id, 'nick': self.user_nick},
                'stats': self.__dict__.get('statistics', {}),
                'upvoted': self.__dict__.get('upvoted', False)}

    @property
    def ago(self):
        if self.created_at is None:
            return "some time ago"
        result = int(int(int(time.time() - self.created_at)) / 60.0)
        abb = "m"

        if result > (60 * 24):
            result /= (60 * 24)
            abb = "d"

        if result > 60:
            result /= 60
            abb = "h"

        return "{}{} ago".format(result, abb)
class ExampleModel(Model):
    id = columns.BigInt(primary_key=True)
    created_at = columns.DateTime()
    deleted = columns.Boolean(default=False)
class TestModel(Model):
    __keyspace__ = 'db'

    id = columns.BigInt(primary_key=True)
    created_at = columns.DateTime()
    deleted = columns.Boolean(default=False)