summaryrefslogtreecommitdiff
path: root/cgi-bin/tags.py
diff options
context:
space:
mode:
Diffstat (limited to 'cgi-bin/tags.py')
-rw-r--r--cgi-bin/tags.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/cgi-bin/tags.py b/cgi-bin/tags.py
index e69de29..4e018f6 100644
--- a/cgi-bin/tags.py
+++ b/cgi-bin/tags.py
@@ -0,0 +1,41 @@
+#!C:\Python364\python3.exe
+# -*- coding: utf-8 -*-
+import sys, codecs
+import cgi, cgitb
+import pymysql
+import issuedb
+import config
+from issuedb import IssueDBFactory
+from config import Config
+
+sys.stdout = codecs.getwriter('utf8')(sys.stdout.buffer)
+
+tag_unit_html_file = open("tag_unit.html", 'r', encoding='utf8')
+tag_html_file = open("tags.html", 'r', encoding='utf8')
+tag_unit_html = tag_unit_html_file.read()
+tag_html = tag_html_file.read()
+
+db = IssueDBFactory.produce()
+cursor = db.cursor()
+
+tagslist = ""
+cursor.execute("SELECT tag.tagId, tagName, COUNT(*) FROM tag, relation WHERE \
+ tag.tagId = relation.tagId GROUP BY tag.tagId;")
+tags_rows = cursor.fetchall()
+for tag_row in tags_rows:
+ tag = tag_unit_html.format(\
+ tagid = tag_row[0], \
+ tag_name = tag_row[1], \
+ tag_count = '(' + str(tag_row[2]) + ')' \
+ )
+ tagslist += tag
+
+print("Content-type:text/html\n")
+print(tag_html.format(tags = tagslist))
+
+db.commit()
+cursor.close()
+db.close()
+issue_unit_html_file.close()
+page_html_file.close()
+