mirror of
https://github.com/ditatompel/xmr-remote-nodes.git
synced 2025-01-08 05:52:10 +07:00
chore: Stick with old SortDirection
This commit is contained in:
parent
f0a10208e2
commit
6e7eccc6b3
4 changed files with 13 additions and 25 deletions
|
@ -102,8 +102,7 @@ func (s *fiberServer) remoteNodesHandler(c *fiber.Ctx) error {
|
||||||
Limit: c.QueryInt("limit", 10), // rows per page
|
Limit: c.QueryInt("limit", 10), // rows per page
|
||||||
Page: c.QueryInt("page", 1),
|
Page: c.QueryInt("page", 1),
|
||||||
SortBy: c.Query("sort_by", "id"),
|
SortBy: c.Query("sort_by", "id"),
|
||||||
SortDir: c.Query("sort_dir", "desc"),
|
SortDirection: c.Query("sort_direction", "desc"),
|
||||||
SortDirection: c.Query("sort_direction", "desc"), // deprecated
|
|
||||||
Refresh: c.QueryInt("refresh", 0),
|
Refresh: c.QueryInt("refresh", 0),
|
||||||
},
|
},
|
||||||
Host: c.Query("host"),
|
Host: c.Query("host"),
|
||||||
|
@ -156,8 +155,7 @@ func Nodes(c *fiber.Ctx) error {
|
||||||
Limit: c.QueryInt("limit", 10), // rows per page
|
Limit: c.QueryInt("limit", 10), // rows per page
|
||||||
Page: c.QueryInt("page", 1),
|
Page: c.QueryInt("page", 1),
|
||||||
SortBy: c.Query("sort_by", "id"),
|
SortBy: c.Query("sort_by", "id"),
|
||||||
SortDir: c.Query("sort_dir", "desc"),
|
SortDirection: c.Query("sort_direction", "desc"),
|
||||||
SortDirection: c.Query("sort_direction", "desc"), // deprecated
|
|
||||||
Refresh: c.QueryInt("refresh", 0),
|
Refresh: c.QueryInt("refresh", 0),
|
||||||
},
|
},
|
||||||
Host: c.Query("host"),
|
Host: c.Query("host"),
|
||||||
|
|
|
@ -131,13 +131,8 @@ func (q *QueryNodes) toSQL() (args []interface{}, where string) {
|
||||||
q.SortBy = "last_checked"
|
q.SortBy = "last_checked"
|
||||||
}
|
}
|
||||||
|
|
||||||
// deprecated: Use SortDir instead
|
|
||||||
if q.SortDirection != "asc" {
|
if q.SortDirection != "asc" {
|
||||||
q.SortDir = "DESC"
|
q.SortDirection = "DESC"
|
||||||
}
|
|
||||||
|
|
||||||
if q.SortDir != "asc" {
|
|
||||||
q.SortDir = "DESC"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return args, where
|
return args, where
|
||||||
|
@ -183,7 +178,7 @@ func (r *moneroRepo) Nodes(q QueryNodes) (Nodes, error) {
|
||||||
%s
|
%s
|
||||||
%s
|
%s
|
||||||
LIMIT ?
|
LIMIT ?
|
||||||
OFFSET ?`, where, q.SortBy, q.SortDir)
|
OFFSET ?`, where, q.SortBy, q.SortDirection)
|
||||||
err = r.db.Select(&nodes.Items, query, args...)
|
err = r.db.Select(&nodes.Items, query, args...)
|
||||||
|
|
||||||
return nodes, err
|
return nodes, err
|
||||||
|
|
|
@ -54,8 +54,7 @@ func TestQueryNodes_toSQL(t *testing.T) {
|
||||||
Limit: 10,
|
Limit: 10,
|
||||||
Page: 1,
|
Page: 1,
|
||||||
SortBy: "last_checked",
|
SortBy: "last_checked",
|
||||||
SortDir: "desc",
|
SortDirection: "desc",
|
||||||
SortDirection: "desc", // deprecated
|
|
||||||
},
|
},
|
||||||
Host: "",
|
Host: "",
|
||||||
Nettype: "any",
|
Nettype: "any",
|
||||||
|
@ -76,8 +75,7 @@ func TestQueryNodes_toSQL(t *testing.T) {
|
||||||
Limit: 10,
|
Limit: 10,
|
||||||
Page: 1,
|
Page: 1,
|
||||||
SortBy: "last_checked",
|
SortBy: "last_checked",
|
||||||
SortDir: "desc",
|
SortDirection: "desc",
|
||||||
SortDirection: "desc", // deprecated
|
|
||||||
},
|
},
|
||||||
Host: "test",
|
Host: "test",
|
||||||
Nettype: "any",
|
Nettype: "any",
|
||||||
|
@ -104,8 +102,8 @@ func TestQueryNodes_toSQL(t *testing.T) {
|
||||||
if tt.query.SortBy != tt.wantSortBy {
|
if tt.query.SortBy != tt.wantSortBy {
|
||||||
t.Errorf("QueryNodes.toSQL() gotSortBy = %v, want %v", tt.query.SortBy, tt.wantSortBy)
|
t.Errorf("QueryNodes.toSQL() gotSortBy = %v, want %v", tt.query.SortBy, tt.wantSortBy)
|
||||||
}
|
}
|
||||||
if tt.query.SortDir != tt.wantSortDir {
|
if tt.query.SortDirection != tt.wantSortDir {
|
||||||
t.Errorf("QueryNodes.toSQL() gotSortDir = %v, want %v", tt.query.SortDir, tt.wantSortDir)
|
t.Errorf("QueryNodes.toSQL() gotSortDir = %v, want %v", tt.query.SortDirection, tt.wantSortDir)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -119,8 +117,7 @@ func Benchmark_QueryNodes_toSQL(b *testing.B) {
|
||||||
Limit: 10,
|
Limit: 10,
|
||||||
Page: 1,
|
Page: 1,
|
||||||
SortBy: "last_checked",
|
SortBy: "last_checked",
|
||||||
SortDir: "desc",
|
SortDirection: "desc",
|
||||||
SortDirection: "desc", // deprecated
|
|
||||||
},
|
},
|
||||||
Host: "test",
|
Host: "test",
|
||||||
Nettype: "any",
|
Nettype: "any",
|
||||||
|
|
|
@ -10,9 +10,7 @@ type Paging struct {
|
||||||
Limit int `url:"limit,omitempty"` // rows per page
|
Limit int `url:"limit,omitempty"` // rows per page
|
||||||
Page int `url:"page"`
|
Page int `url:"page"`
|
||||||
SortBy string `url:"sort_by,omitempty"`
|
SortBy string `url:"sort_by,omitempty"`
|
||||||
SortDir string `url:"sort_dir,omitempty"`
|
SortDirection string `url:"sort_direction,omitempty"`
|
||||||
|
|
||||||
SortDirection string `url:"sort_direction,omitempty"` // DEPRECATED: use SortDir
|
|
||||||
|
|
||||||
// Refresh interval
|
// Refresh interval
|
||||||
Refresh int `url:"refresh,omitempty"`
|
Refresh int `url:"refresh,omitempty"`
|
||||||
|
|
Loading…
Reference in a new issue