Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

introduce order by

Cette révision appartient à :
Eliot Whalan 2017-05-02 23:50:18 +10:00
Parent daf5000507
révision c0ba0d8e75

Voir le fichier

@ -51,7 +51,7 @@ func apiHandler(w http.ResponseWriter, r *http.Request) {
page := vars["page"]
pagenum, _ := strconv.Atoi(html.EscapeString(page))
b := Record{Records: []Records{}}
rows, err := dbHandle.Query("select torrent_id, torrent_name, torrent_hash from torrents LIMIT 50 offset ?", 50*pagenum-1)
rows, err := dbHandle.Query("select torrent_id, torrent_name, torrent_hash from torrents ORDER BY torrent_id DESC LIMIT 50 offset ?", 50*pagenum-1)
for rows.Next() {
var id, name, hash, magnet string
rows.Scan(&id, &name, &hash)
@ -81,7 +81,7 @@ func singleapiHandler(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
id := vars["id"]
b := Record{Records: []Records{}}
rows, err := dbHandle.Query("select torrent_id, torrent_name, torrent_hash from torrents where torrent_id = ?", html.EscapeString(id))
rows, err := dbHandle.Query("select torrent_id, torrent_name, torrent_hash from torrents where torrent_id = ? ORDER BY torrent_id DESC", html.EscapeString(id))
for rows.Next() {
var id, name, hash, magnet string
rows.Scan(&id, &name, &hash)
@ -113,7 +113,7 @@ func searchHandler(w http.ResponseWriter, r *http.Request) {
pagenum, _ := strconv.Atoi(html.EscapeString(page))
param1 := r.URL.Query().Get("q")
b := Record{Records: []Records{}}
rows, err := dbHandle.Query("select torrent_id, torrent_name, torrent_hash from torrents where torrent_name LIKE ? LIMIT 50 offset ?", "%"+html.EscapeString(param1)+"%", 50*pagenum-1)
rows, err := dbHandle.Query("select torrent_id, torrent_name, torrent_hash from torrents where torrent_name LIKE ? ORDER BY torrent_id DESC LIMIT 50 offset ?", "%"+html.EscapeString(param1)+"%", 50*pagenum-1)
for rows.Next() {
var id, name, hash, magnet string
rows.Scan(&id, &name, &hash)
@ -140,7 +140,7 @@ func rootHandler(w http.ResponseWriter, r *http.Request) {
page := vars["page"]
pagenum, _ := strconv.Atoi(html.EscapeString(page))
b := Record{Records: []Records{}}
rows, err := dbHandle.Query("select torrent_id, torrent_name, torrent_hash from torrents LIMIT 50 offset ?", 50*pagenum-1)
rows, err := dbHandle.Query("select torrent_id, torrent_name, torrent_hash from torrents ORDER BY torrent_id DESC LIMIT 50 offset ?", 50*pagenum-1)
for rows.Next() {
var id, name, hash, magnet string
rows.Scan(&id, &name, &hash)