This is an automated email from the git hooks/post-receive script. New commit to branch bow-v2-go in repository bow. See https://gitlab.nuiton.org/chorem/bow.git commit fedbb6aec4f9ea99c8dba443438bdc2ccb2a2b91 Author: Benjamin <poussin@codelutin.com> Date: Sun May 24 23:09:18 2020 +0200 ordre par defaut desc (les plus recent d'abord) --- pkg/constant/const.go | 4 ++-- pkg/http/bookmarkResource.go | 6 +++--- pkg/repository/bookmarkRepository.go | 8 ++++---- web/src/main.js | 4 ++-- web/src/router/index.js | 2 +- web/src/views/Home.vue | 8 ++++---- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/pkg/constant/const.go b/pkg/constant/const.go index 2f870f9..28ed36d 100644 --- a/pkg/constant/const.go +++ b/pkg/constant/const.go @@ -82,9 +82,9 @@ OrderBy query parameter name for select order sorting const OrderBy = "orderby" /* -OrderDesc query parameter name for select order sorting direction descending +OrderAsc query parameter name for select order sorting direction descending */ -const OrderDesc = "orderdesc" +const OrderAsc = "orderasc" /* First query parameter name first result diff --git a/pkg/http/bookmarkResource.go b/pkg/http/bookmarkResource.go index 3ce52a8..da2c34b 100644 --- a/pkg/http/bookmarkResource.go +++ b/pkg/http/bookmarkResource.go @@ -25,16 +25,16 @@ func getBookmarks(w http.ResponseWriter, r *http.Request) { log.Println("query: ", queryParams) orderBy := queryParams.Get(constant.OrderBy) - orderDesc, err := strconv.ParseBool(queryParams.Get(constant.OrderDesc)) + orderAsc, err := strconv.ParseBool(queryParams.Get(constant.OrderAsc)) if err != nil { - orderDesc = false + orderAsc = false } first, err := strconv.ParseInt(queryParams.Get(constant.First), 10, 16) if err != nil { first = 0 } - json, err := repository.BookmarkJSON(currentUser, id, uri, tags, fulltext, orderBy, orderDesc, int(first)) + json, err := repository.BookmarkJSON(currentUser, id, uri, tags, fulltext, orderBy, orderAsc, int(first)) if err != nil { if utils.Is404(err) { // on a rien retrouve, on renvoie une collection vide diff --git a/pkg/repository/bookmarkRepository.go b/pkg/repository/bookmarkRepository.go index 0782cfc..5c16873 100644 --- a/pkg/repository/bookmarkRepository.go +++ b/pkg/repository/bookmarkRepository.go @@ -19,7 +19,7 @@ si id est non vide alors fait une recherche exact sur l'id si uri est non vide alors fait une recherche exact sur l'uri sinon fait une recherche sur les critères: tags, fulltext */ -func BookmarkJSON(currentUser model.BowUser, id string, uri string, tags []string, fulltext string, orderBy string, orderDesc bool, first int) (string, error) { +func BookmarkJSON(currentUser model.BowUser, id string, uri string, tags []string, fulltext string, orderBy string, orderAsc bool, first int) (string, error) { var result string var err error @@ -35,11 +35,11 @@ func BookmarkJSON(currentUser model.BowUser, id string, uri string, tags []strin } orderDirection := "" - if orderDesc { + if !orderAsc { orderDirection = "desc" } - log.Printf("search bookmark id: %v, uri: %v, tags: '%v', fulltext: '%v', orderBy: %v, orderDesc: %v, first:%v", id, uri, tags, fulltext, orderBy, orderDesc, first) + log.Printf("search bookmark id: %v, uri: %v, tags: '%v', fulltext: '%v', orderBy: %v, orderAsc: %v, first:%v", id, uri, tags, fulltext, orderBy, orderAsc, first) if id != "" { q := &query{sql: `WITH __all AS (select * from bookmark where id=$1) SELECT json_agg(__all.*) as j FROM __all`} result, err = q.QueryString(currentUser, id) @@ -50,7 +50,7 @@ func BookmarkJSON(currentUser model.BowUser, id string, uri string, tags []strin tagsJoined := strings.Join(tags, ",") q := &query{sql: fmt.Sprintf(`WITH __query AS (select * from bookmark where tags @> string_to_array($1, ',')), - __info AS (select %[3]d as first, %[4]d as limit, count(id) as total, '%[1]s' as orderby, to_json('%[2]s' = 'desc') as orderdesc, string_to_array($1, ',') as tags, $2::TEXT as fulltext from __query), + __info AS (select %[3]d as first, %[4]d as limit, count(id) as total, '%[1]s' as orderby, to_json('%[2]s' = 'asc') as orderasc, string_to_array($1, ',') as tags, $2::TEXT as fulltext from __query), __infoJson AS (select row_to_json(i.*) as info from __info i), __allTags AS (select unnest(tags) as tag from __query), __tags AS (select tag, count(tag) from __allTags group by tag order by 2 desc), diff --git a/web/src/main.js b/web/src/main.js index 35dc0bd..cb2bc37 100644 --- a/web/src/main.js +++ b/web/src/main.js @@ -32,7 +32,7 @@ Vue.mixin({ query.fulltext = this.queryInfo.fulltext query.query = this.queryInfo.query query.orderby = this.queryInfo.orderby - query.orderdesc = this.queryInfo.orderdesc + query.orderasc = this.queryInfo.orderasc query.first = this.queryInfo.first return query }, @@ -112,7 +112,7 @@ Vue.mixin({ fulltext: i.fulltext, query: i.query, orderby: i.orderby, - orderdesc: i.orderdesc + orderasc: i.orderasc } }, queryInfo: function() { diff --git a/web/src/router/index.js b/web/src/router/index.js index 29185ad..ad2c665 100644 --- a/web/src/router/index.js +++ b/web/src/router/index.js @@ -34,7 +34,7 @@ const routes = [ fulltext: route.query.fulltext, query: route.query.query, orderby: route.query.orderby, - orderdesc: route.query.orderdesc, + orderasc: route.query.orderasc, first: route.query.first }) }, diff --git a/web/src/views/Home.vue b/web/src/views/Home.vue index 8650ff5..fdcaf72 100644 --- a/web/src/views/Home.vue +++ b/web/src/views/Home.vue @@ -24,7 +24,7 @@ import CloudTags from '@/components/CloudTags' @Component({ name: 'Home', - props: ['id', 'tags', 'fulltext', 'query', 'orderby', 'orderdesc', 'first'], + props: ['id', 'tags', 'fulltext', 'query', 'orderby', 'orderasc', 'first'], components: { CloudTags, Bookmark } }) class Home extends Vue { @@ -33,14 +33,14 @@ class Home extends Vue { @Prop fulltext @Prop query @Prop orderby - @Prop orderdesc + @Prop orderasc @Prop first mTags = this.forceArrayTags(this.tags) mFulltext = this.fulltext || '' mQuery = this.query || '' mOrderby = this.orderby || '' - mOrderdesc = this.orderdesc || false + mOrderasc = this.orderasc || false mFirst = this.first || 0 errorMsg = '' @@ -71,7 +71,7 @@ class Home extends Vue { this.mFulltext && searchParams.append('fulltext', this.mFulltext) this.mQuery && searchParams.append('query', this.mQuery) this.mOrderby && searchParams.append('orderby', this.mOrderby) - this.mOrderdesc && searchParams.append('orderdesc', this.mOrderdesc) + this.mOrderasc && searchParams.append('orderasc', this.mOrderasc) this.mFirst && searchParams.append('first', this.mFirst) this.$fetch.get(`/bookmarks?${searchParams.toString()}`).then( -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.