File size: 421 Bytes
961c20d
 
 
 
 
2ea1d46
961c20d
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from numpy import base_repr
from db import *


def get_post_by_tag(tag: Tag):
    id_str = f''"${base_repr(tag.id, 36)}#''"
    return (
        Post.select()
        .join(PostFTS, on=(Post.id == PostFTS.rowid))
        .where(PostFTS.tag_list.contains(id_str))
    )


def get_tag_by_name(name: str):
    return Tag.get(name=name)


def get_tags_by_popularity(n: int):
    return Tag.select().where(Tag.popularity >= n)