-
Notifications
You must be signed in to change notification settings - Fork 67
API server code health pass - misc. refactors #1059
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
if we are gonna push the IntRange
thing through, we might as well include it in other similar type variations... so like replace Union[str, Tuple[int, int], int]
with Union[str, IntRange]
too.
kw_order = [f"{self.alias}.{k} {to_asc(v)}" for k, v in kwargs.items()] | ||
self.order = args_order + kw_order | ||
return self | ||
self.order = [f"{self.alias}.{k} ASC" for k in args] |
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.
self.order = [f"{self.alias}.{k} ASC" for k in args] | |
self.order = [f"{self.alias}.{k} ASC" for k in args] | |
return self |
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.
This is actually one of the refactors I wanted to apply to query.py
- the return self
is intended to be used for method cascading:
q.apply_issues_filter().apply_lag_filter().apply_as_of_filter()
but it is not used that way anywhere in the codebase, so the statements serve no purpose. Do we still need to keep the return self
for some other reason? (Or perhaps start using that style of cascading after all?)
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 can allow method cascading without requiring it. the rest of the methods of QueryBuilder
do return self
, and its best to keep that consistent especially in case someone does eventually choose to write something with cascading. its also not bad form to return self
on mutator methods from a functional programming perspective.
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.
Got it! I actually wanted to remove return self
from those other methods too but you make a great point about the functional programming angle.
Partially addresses #998.
Prerequisites:
dev
branchdev
Summary
Fixes a set of issues in the server code as described here.
_handle_lag_issues_as_of()
into three separate methods, removes no-op usage.set_order()
method to remove unneeded sorting complexity, renames toset_sort_order
.get_related_signals()
method._db.py
, moves the SQLAlchemy engine definition from it to_common.py
.IntValues
type alias.