aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2018-05-10 16:33:25 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2018-05-10 16:33:25 +0200
commite45c64a5ace2637a9ff290a42cde89e2403ae53d (patch)
tree0810fcbac31803d66c5f553dd174b4a3fc00bec9
parent5321200c05b3b693581ec4238c74eb02e0b715d7 (diff)
downloadTrader-e45c64a5ace2637a9ff290a42cde89e2403ae53d.tar.gz
Trader-e45c64a5ace2637a9ff290a42cde89e2403ae53d.tar.zst
Trader-e45c64a5ace2637a9ff290a42cde89e2403ae53d.zip
Fetch only enabled market
-rw-r--r--main.py4
-rw-r--r--tests/test_main.py4
2 files changed, 4 insertions, 4 deletions
diff --git a/main.py b/main.py
index ee25182..1c65e56 100644
--- a/main.py
+++ b/main.py
@@ -71,9 +71,9 @@ def fetch_markets(user):
71 cursor = dbs.psql.cursor() 71 cursor = dbs.psql.cursor()
72 72
73 if user is None: 73 if user is None:
74 cursor.execute("SELECT id,config,user_id FROM market_configs") 74 cursor.execute("SELECT id,config,user_id FROM market_configs WHERE status='enabled'")
75 else: 75 else:
76 cursor.execute("SELECT id,config,user_id FROM market_configs WHERE user_id = %s", user) 76 cursor.execute("SELECT id,config,user_id FROM market_configs WHERE status='enabled' AND user_id = %s", user)
77 77
78 for row in cursor: 78 for row in cursor:
79 yield row 79 yield row
diff --git a/tests/test_main.py b/tests/test_main.py
index 1864c06..298e29e 100644
--- a/tests/test_main.py
+++ b/tests/test_main.py
@@ -325,7 +325,7 @@ class MainTest(WebMockTestCase):
325 with self.subTest(user=None): 325 with self.subTest(user=None):
326 rows = list(main.fetch_markets(None)) 326 rows = list(main.fetch_markets(None))
327 327
328 cursor_mock.execute.assert_called_once_with("SELECT id,config,user_id FROM market_configs") 328 cursor_mock.execute.assert_called_once_with("SELECT id,config,user_id FROM market_configs WHERE status='enabled'")
329 329
330 self.assertEqual(["row_1", "row_2"], rows) 330 self.assertEqual(["row_1", "row_2"], rows)
331 331
@@ -333,7 +333,7 @@ class MainTest(WebMockTestCase):
333 with self.subTest(user=1): 333 with self.subTest(user=1):
334 rows = list(main.fetch_markets(1)) 334 rows = list(main.fetch_markets(1))
335 335
336 cursor_mock.execute.assert_called_once_with("SELECT id,config,user_id FROM market_configs WHERE user_id = %s", 1) 336 cursor_mock.execute.assert_called_once_with("SELECT id,config,user_id FROM market_configs WHERE status='enabled' AND user_id = %s", 1)
337 337
338 self.assertEqual(["row_1", "row_2"], rows) 338 self.assertEqual(["row_1", "row_2"], rows)
339 339