Ejemplo n.º 1
0
 async def list_tags(self, ctx: commands.Context):
     paginator = commands.Paginator()
     for tag in Tag.select(Tag.tag, Tag.title):
         paginator.add_line(f"{tag.tag} - {tag.title}")
     for page_number, page in enumerate(paginator.pages):
         await ctx.author.send(embed=Embed(
             title=f"Tags Page #{page_number}", description=page))
     await ctx.message.delete()
Ejemplo n.º 2
0
 def get(self, *args, **kwargs):
     tag = args[0]
     tag_query = Tag.select().where(Tag.content == tag).first()
     if tag_query:
         archives2tag_query = Archive2Tag.select(Archive2Tag.archive_id).where(Archive2Tag.tag_id == tag_query.id)
         archive_ids = [one.archive_id for one in archives2tag_query]
         archives = Archive.select().where(
             (Archive.id << archive_ids) & (Archive.status == 1) & (Archive.type == 0)).order_by(
             Archive.published_time.desc())
         archives_groups = [{'year': year, 'archives': list(archives)}
                            for year, archives in groupby(archives, key=lambda a: humantime(a.published_time, "%Y"))]
         self.render("timeline.html", archives_groups=archives_groups, first_title="Tag: %s" % tag)
Ejemplo n.º 3
0
def regen_cache():
    tag_id_cache.clear()
    for t in Tag.select(Tag.tag):
        tag_id_cache.add(t.tag)