révision
3fc99b50d2
2 fichiers modifiés avec 23 ajouts et 6 suppressions
|
@ -18,10 +18,8 @@ that anyone will be able to deploy locally or remotely.
|
||||||
## TODO
|
## TODO
|
||||||
* RSS feeds(work in progress)
|
* RSS feeds(work in progress)
|
||||||
* torrent sorting (work in progress)
|
* torrent sorting (work in progress)
|
||||||
* Merge 5th of april dump with animetosho dump
|
|
||||||
* API improvement
|
* API improvement
|
||||||
* Site theme
|
* Site theme
|
||||||
* improve search by making it less strict
|
|
||||||
* Torrent view and description page(work in progress)
|
* Torrent view and description page(work in progress)
|
||||||
* accounts?
|
* accounts?
|
||||||
* Adding new torrents
|
* Adding new torrents
|
||||||
|
|
27
main.go
27
main.go
|
@ -42,7 +42,7 @@ func checkErr(err error) {
|
||||||
func unZlib(description []byte) string {
|
func unZlib(description []byte) string {
|
||||||
if len(description) > 0 {
|
if len(description) > 0 {
|
||||||
b := bytes.NewReader(description)
|
b := bytes.NewReader(description)
|
||||||
log.Println(b)
|
//log.Println(b)
|
||||||
z, err := zlib.NewReader(b)
|
z, err := zlib.NewReader(b)
|
||||||
checkErr(err)
|
checkErr(err)
|
||||||
defer z.Close()
|
defer z.Close()
|
||||||
|
@ -125,7 +125,6 @@ func searchHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
// need this to prevent out of index panics
|
// need this to prevent out of index panics
|
||||||
var searchCatId, searchSubCatId string
|
var searchCatId, searchSubCatId string
|
||||||
if len(catsSplit) == 2 {
|
if len(catsSplit) == 2 {
|
||||||
|
|
||||||
searchCatId = html.EscapeString(catsSplit[0])
|
searchCatId = html.EscapeString(catsSplit[0])
|
||||||
searchSubCatId = html.EscapeString(catsSplit[1])
|
searchSubCatId = html.EscapeString(catsSplit[1])
|
||||||
}
|
}
|
||||||
|
@ -141,8 +140,28 @@ func searchHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
b := []TorrentsJson{}
|
b := []TorrentsJson{}
|
||||||
|
|
||||||
parameters := createWhereParams("torrent_name LIKE ? AND status_id LIKE ? AND category_id LIKE ? AND sub_category_id LIKE ?",
|
parameters := WhereParams{}
|
||||||
"%"+searchQuery+"%", stat+"%", searchCatId+"%", searchSubCatId+"%")
|
conditions := []string{}
|
||||||
|
if searchCatId != "" {
|
||||||
|
conditions = append(conditions, "category_id = ?")
|
||||||
|
parameters.params = append(parameters.params, searchCatId)
|
||||||
|
}
|
||||||
|
if searchSubCatId != "" {
|
||||||
|
conditions = append(conditions, "sub_category_id = ?")
|
||||||
|
parameters.params = append(parameters.params, searchSubCatId)
|
||||||
|
}
|
||||||
|
if stat != "" {
|
||||||
|
conditions = append(conditions, "status_id = ?")
|
||||||
|
parameters.params = append(parameters.params, stat)
|
||||||
|
}
|
||||||
|
searchQuerySplit := strings.Split(searchQuery, " ")
|
||||||
|
for i, _ := range searchQuerySplit {
|
||||||
|
conditions = append(conditions, "torrent_name LIKE ?")
|
||||||
|
parameters.params = append(parameters.params, "%"+searchQuerySplit[i]+"%")
|
||||||
|
}
|
||||||
|
|
||||||
|
parameters.conditions = strings.Join(conditions[:], " AND ")
|
||||||
|
log.Printf("SQL query is :: %s\n", parameters.conditions)
|
||||||
torrents, nbTorrents := getTorrentsOrderBy(¶meters, order_by, maxPerPage, maxPerPage*(pagenum-1))
|
torrents, nbTorrents := getTorrentsOrderBy(¶meters, order_by, maxPerPage, maxPerPage*(pagenum-1))
|
||||||
|
|
||||||
for i, _ := range torrents {
|
for i, _ := range torrents {
|
||||||
|
|
Référencer dans un nouveau ticket