2DU 8 éve
szülő
commit
3e4674c6b8
1 módosított fájl, 31 hozzáadás és 25 törlés
  1. 31 25
      app.py

+ 31 - 25
app.py

@@ -2178,9 +2178,9 @@ def title_index(num = 100, page = 1):
         sql_num = 0
 
     if(num != 0):
-        all_list = [sql_num + 1, 0, 0, 0, 0, 0]
+        all_list = sql_num + 1
     else:
-        all_list = [1, 0, 0, 0, 0, 0]
+        all_list = 0
 
     if(num > 1000):
         return(re_error('/error/3'))
@@ -2199,31 +2199,37 @@ def title_index(num = 100, page = 1):
     title_list = curs.fetchall()
 
     for list_data in title_list:
-        data += '<li>' + str(all_list[0]) + '. <a href="/w/' + url_pas(list_data[0]) + '">' + list_data[0] + '</a></li>'
-
-        if(num == 0):
-            if(re.search('^분류:', list_data[0])):
-                all_list[1] += 1
-            elif(re.search('^사용자:', list_data[0])):
-                all_list[2] += 1
-            elif(re.search('^틀:', list_data[0])):
-                all_list[3] += 1
-            elif(re.search('^파일:', list_data[0])):
-                all_list[4] += 1
-            else:
-                all_list[5] += 1
-        
-        all_list[0] += 1
+        data += '<li>' + str(all_list) + '. <a href="/w/' + url_pas(list_data[0]) + '">' + list_data[0] + '</a></li>'        
+        all_list += 1
 
-    if(num == 0):
-        if(title_list):        
-            data += '<br><br><li>이 위키에는 총 ' + str(all_list[0]) + '개의 문서가 있습니다.</li><br><br> \
-                    <li>틀 문서는 총 ' + str(all_list[3]) + '개의 문서가 있습니다.</li> \
-                    <li>분류 문서는 총 ' + str(all_list[1]) + '개의 문서가 있습니다.</li> \
-                    <li>사용자 문서는 총 ' + str(all_list[2]) + '개의 문서가 있습니다.</li> \
-                    <li>파일 문서는 총 ' + str(all_list[4]) + '개의 문서가 있습니다.</li> \
-                    <li>나머지 문서는 총 ' + str(all_list[5]) + '개의 문서가 있습니다.</li>'
+    count_end = []
+    curs.execute("select count(title) from data")
+    count = curs.fetchall()
+    if(count):
+        count_end += [count[0][0]]
     else:
+        count_end += [0]
+
+    sql_list = ['틀:', '분류:', '사용자:', '파일:']
+
+    for sql in sql_list:
+        curs.execute("select count(title) from data where title like ?", [sql + '%'])
+        count = curs.fetchall()
+        if(count):
+            count_end += [count[0][0]]
+        else:
+            count_end += [0]
+
+    count_end += [count_end[0] - count_end[1]  - count_end[2]  - count_end[3]  - count_end[4]]
+
+    data += '<br><br><li>이 위키에는 총 ' + str(count_end[0]) + '개의 문서가 있습니다.</li><br><br>'
+    data += '<li>틀 문서는 총 ' + str(count_end[1]) + '개의 문서가 있습니다.</li>'
+    data += '<li>분류 문서는 총 ' + str(count_end[2]) + '개의 문서가 있습니다.</li>'
+    data += '<li>사용자 문서는 총 ' + str(count_end[3]) + '개의 문서가 있습니다.</li>'
+    data += '<li>파일 문서는 총 ' + str(count_end[4]) + '개의 문서가 있습니다.</li>'
+    data += '<li>나머지 문서는 총 ' + str(count_end[5]) + '개의 문서가 있습니다.</li>'
+
+    if(num != 0):
         data += '</ul><br><a href="/title_index/' + str(num) + '/' + str(page - 1) + '">(이전)</a> <a href="/title_index/' + str(num) + '/' + str(page + 1) + '">(이후)</a>'
     
     return(