-
Notifications
You must be signed in to change notification settings - Fork 4
Update the Web API after the data/table/tasks refactoring #26
Conversation
pytest, ipython, etc. just do: pip install -e ."[dev]" to install these dependencies.
After the data and tasks refactoring, the table names have beed modified. * update some web api unit tests * remove useless functions which were so city-specific
* add two more unit tests
* remove the useless suffix '_route' * some renaming * remove unused variables
* rename 'nom' to 'name' * update the dedicated unit test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice PR! Good for me, except a specific point: I guess it will be better to fix a few occurrences of unautomated table names. We should refer to {city}.stations
and {city}.timeseries
from config["database"]
configuration section.
jitenshea/controller.py
Outdated
,nb_stations as nb_bikes | ||
,st_x(geom) as x | ||
,st_y(geom) as y | ||
FROM {schema}.stations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could recover the stations
table name from config file, as in the previous PR.
jitenshea/controller.py
Outdated
FROM {schema}.daily_transaction AS X | ||
LEFT JOIN {schema}.{table} AS Y ON X.id=Y.{idcol}::int | ||
LEFT JOIN {schema}.stations AS Y using(id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same remark as previously.
jitenshea/controller.py
Outdated
FROM station AS S | ||
LEFT JOIN {schema}.daily_transaction AS D ON (S.id=D.id) | ||
LEFT JOIN {schema}.{table} AS Y ON S.id=Y.{idcol}::int | ||
LEFT JOIN {schema}.stations AS Y ON S.id=Y.id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idem
jitenshea/controller.py
Outdated
query = """SELECT T.* | ||
,S.name as name | ||
FROM {schema}.timeseries AS T | ||
LEFT JOIN {schema}.stations AS S using(id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two new occurrences of table names there (timeseries
and stations
).
jitenshea/controller.py
Outdated
table, idcol = station_city_table(city) | ||
query = ("SELECT {id} FROM {schema}.{table}" | ||
";").format(id=idcol, schema=config[city]["schema"], table=table) | ||
query = ("SELECT id FROM {schema}.stations" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stations
table could be automatized as well.
jitenshea/controller.py
Outdated
"citystation.geom AS geom, " | ||
"rank() OVER (ORDER BY stop DESC) AS rank " | ||
"FROM {schema}.{cluster} AS cs " | ||
"JOIN {schema}.{table} AS citystation " | ||
"ON citystation.{idcol} = cs.station_id::varchar " | ||
"JOIN {schema}.stations AS citystation " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here comes a new occurrence.
thanks for the review. I updated the controller.py with your remarks. |
Fine for me, ready for merging! |
depend on #24