diff --git a/backend/api/internal/database/user_queries.go b/backend/api/internal/database/user_queries.go index 0d2a94f..68a7e66 100644 --- a/backend/api/internal/database/user_queries.go +++ b/backend/api/internal/database/user_queries.go @@ -233,7 +233,7 @@ func SearchUsers(prefix string, limit int) ([]*ApiUser, error) { query := ` SELECT id, username, picture, bio, links, settings, creation_date FROM users - WHERE LOWER(username) LIKE LOWER($1) + WHERE LOWER(username) LIKE LOWER($1) AND id > 0 ORDER BY username ASC LIMIT $2; ` diff --git a/backend/api/internal/tests/user_test.go b/backend/api/internal/tests/user_test.go index 79f5214..2d9cf22 100644 --- a/backend/api/internal/tests/user_test.go +++ b/backend/api/internal/tests/user_test.go @@ -212,13 +212,13 @@ var user_tests = []TestCase{ Method: http.MethodGet, Endpoint: "/users/search?q=dev", ExpectedStatus: http.StatusOK, - ExpectedBody: `[{"bio":"Full-stack developer passionate about open-source projects.","creation_date":"2023-12-13T00:00:00Z","id":1,"links":["https://github.com/dev_user1","https://devuser1.com"],"picture":"https://example.com/dev_user1.jpg","settings":{"accentColor":"","backgroundRefreshEnabled":false,"compactMode":false,"refreshIntervalMs":120000,"zenMode":false},"username":"dev_user1"}]`, + ExpectedBody: `[{"bio":"Updated developer bio.","creation_date":"2023-12-13T00:00:00Z","id":1,"links":["https://github.com/dev_user1","https://devuser1.com"],"picture":"https://example.com/dev_user1.jpg","settings":{"accentColor":"","backgroundRefreshEnabled":false,"compactMode":false,"refreshIntervalMs":120000,"zenMode":false},"username":"dev_user1"}]`, }, // search users – count is capped at 20 { Method: http.MethodGet, Endpoint: "/users/search?q=d&count=100", ExpectedStatus: http.StatusOK, - ExpectedBody: `[{"bio":"Data scientist with a passion for machine learning.","creation_date":"2023-06-13T00:00:00Z","id":3,"links":["https://github.com/data_scientist3","https://datascientist3.com"],"picture":"https://example.com/data_scientist3.jpg","settings":{"accentColor":"","backgroundRefreshEnabled":false,"compactMode":false,"refreshIntervalMs":120000,"zenMode":false},"username":"data_scientist3"},{"bio":"Full-stack developer passionate about open-source projects.","creation_date":"2023-12-13T00:00:00Z","id":1,"links":["https://github.com/dev_user1","https://devuser1.com"],"picture":"https://example.com/dev_user1.jpg","settings":{"accentColor":"","backgroundRefreshEnabled":false,"compactMode":false,"refreshIntervalMs":120000,"zenMode":false},"username":"dev_user1"}]`, + ExpectedBody: `[{"bio":"Data scientist with a passion for machine learning.","creation_date":"2023-06-13T00:00:00Z","id":3,"links":["https://github.com/data_scientist3","https://datascientist3.com"],"picture":"https://example.com/data_scientist3.jpg","settings":{"accentColor":"","backgroundRefreshEnabled":false,"compactMode":false,"refreshIntervalMs":120000,"zenMode":false},"username":"data_scientist3"},{"bio":"Updated developer bio.","creation_date":"2023-12-13T00:00:00Z","id":1,"links":["https://github.com/dev_user1","https://devuser1.com"],"picture":"https://example.com/dev_user1.jpg","settings":{"accentColor":"","backgroundRefreshEnabled":false,"compactMode":false,"refreshIntervalMs":120000,"zenMode":false},"username":"dev_user1"}]`, }, }