-
Notifications
You must be signed in to change notification settings - Fork 1
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
ENH: Store stats in mongo atlas #1
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,12 +32,18 @@ def cli(): | |
|
||
@cli.command() | ||
@click.option("-l", "--limit", type=click.IntRange(min=1), default=None) | ||
def get(limit): | ||
@click.option("--mongo-user", envvar="MONGO_USERNAME", type=str, default=None) | ||
@click.password_option( | ||
"--mongo-password", | ||
envvar="MONGO_PASSWORD", | ||
default=None, | ||
) | ||
def get(limit, mongo_password, mongo_user): | ||
from api import get_events | ||
|
||
# Get events | ||
for event in ("started", "success", "failed"): | ||
get_events(event, limit=limit) | ||
get_events(event, limit=limit, mongo_password=mongo_password, mongo_user=mongo_user) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently this function is called multiple times while initializing the database connection - I think it would be cleaner to isolate the client initialization within its own function. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. I hadn't thought of this. This is almost certainly a problem also in current main. |
||
|
||
|
||
if __name__ == "__main__": | ||
|
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.
Rather than calling
MongoClient
twice, what about having host default to"localhost"
and then updating it if user credentials are present?