-
Notifications
You must be signed in to change notification settings - Fork 192
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
Added command to export reviewer's votes #650
base: master
Are you sure you want to change the base?
Conversation
junction/proposals/management/commands/export_conf_proposals.py
Outdated
Show resolved
Hide resolved
@prasoonmayank Left some comments. Also, please lint your code before committing. You can do so by running |
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.
Hi @prasoonmayank Can you run the command you created locally to check if it is creating the required csv file and storing data into it? In doing so you can find these errors I mentioned.
junction/proposals/management/commands/export_conf_proposals.py
Outdated
Show resolved
Hide resolved
junction/proposals/management/commands/export_conf_proposals.py
Outdated
Show resolved
Hide resolved
Will be completing proper testing with corner cases by today |
@prasoonmayank, It looks like you have committed your env file? |
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 progress @prasoonmayank. I have left some comments have a look.
Also, I think it would be good to have different methods to do all the logic and let the command handler call those methods, instead of directly putting all the logic in the handler.
P.S. Try always to use a new development branch(other than master) to create a pull request. Have a look at our contributing guide. :)
junction/proposals/management/commands/export_conf_proposals.py
Outdated
Show resolved
Hide resolved
junction/proposals/management/commands/export_conf_proposals.py
Outdated
Show resolved
Hide resolved
@prasoonmayank Can you rebase your changes and run the linter again. There is a recent PR that has been merged with a change in the linting approach. |
Hey @ananyo2012 is there a way to run the lint code without nox? Since, earlier, nox was calling a flake8 command, and was able to lint it. Since, for some reason, nox is not working in Mac |
@prasoonmayank Why is nox not working for you? Could you share the error message? |
Also, yes, you can run the linters without nox, by running pre-commit directly ( |
I will try to run the latest linting changes locally. We also got a
report earlier regarding issues running test locally.
…On Sun, Apr 5, 2020 at 2:39 AM Pradyun Gedam ***@***.***> wrote:
Also, yes, you can run the linters without nox, by running pre-commit directly (pip install pre-commit and then pre-commit run --all-files).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
There were essentially two problems in my case:
|
@prasoonmayank There is an issue reported for Mac systems in #660 . What python versions do you have in your system ? Instead of using nox can you try running tests using pre-commit should be able to lint in all versions. Are you seeing any failures related to isort ? That's a known issue introduced recently. Except that other linting tests should work. |
I installed python3.6 for the pre-commit linter to work. |
@prasoonmayank If you click details on the failing check, you can see the CI runs, and then clicking on the specific job reveals the output of that job. In this case, the linters are failing for you. |
The isort fails are a valid one I mentioned in #663 cc: @pradyunsg |
Hey @prasoonmayank, could you file an issue describing why you aren't able to install nox (including the error messages if you see any)? If it's not working for a contributor, that's a bug in either our developer tools, or developer documentation. :) |
Other than that, please feel free to go ahead and merge master into this PR / rebase this PR on master. |
Before merging please make sure the commits are squashed. |
Hey @palnabarun Please review the pr. As it is in requested changes state right now |
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.
@prasoonmayank Left some comments.
Other than those, I think this should be good to go.
user = User.objects.get(id=options.get("user_id")) | ||
except User.DoesNotExist: | ||
self.stdout.write("Invalid user") | ||
return |
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.
Exception cases should be returned with a Non-Zero Exit Code.
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.
handled. though, just curious, what is the advantage?
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.
@palnabarun have made the changes, please rereview
return | ||
except Conference.DoesNotExist: | ||
self.stdout.write("Invalid conference") | ||
return |
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 as above.
|
||
if not is_conference_moderator(user=user, conference=conference): | ||
self.stdout.write("The user id is not a conference moderator") | ||
return |
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 as above.
help="Enter the conference slug where to export reviewer votes from", | ||
) | ||
|
||
parser.add_argument("--user_id", default=None, help="Enter your user 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.
What is the need of userid ? The command is supposed to be used by the admin from the console so the admin must be logged in to the application server.
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.
Not sure, but there are multiple admin users, right?
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.
Yes whoever has login access can use this command. No need to check for user id. Usually whoever is managing junction is also the one managing the server. Also user id's are not user friendly
parser.add_argument( | ||
"--conference_slug", | ||
default=None, | ||
help="Enter the conference slug where to export reviewer votes from", |
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.
Update the help text to Conference slug
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.
done
) | ||
vote_values_list = [v.vote_value for v in proposal_vote_values] | ||
vote_values_desc = tuple(i.description for i in proposal_vote_values) | ||
header = ( |
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.
Why is there an extra pair of brackets ?
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.
done
] | ||
) | ||
row = { | ||
header[0]: p.proposal_type.name, |
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.
I think instead of csv.DictWriter
you should simply use csv.writer
and use lists to write each row. This reduces this complexity of creating a dictionary in each iteration and makes the code simpler. e.g.
junction/junction/proposals/dashboard.py
Line 326 in e8cefd7
row = (p.proposal_type.name, p.title, p.get_reviewer_votes_sum(), |
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.
Using dictwriter would be a lot more accurate, right? Always ensuring which values go for which fields? Probably, never creating confusion for future devs on which key belongs to which key?
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.
Please rename the vote_details
variable to reviewer_votes_count
in that case
|
||
csv_contents.append(row) | ||
|
||
csv_file_name = "%s-%s.csv" % (user.username, conference.name) |
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.
There is no section name in the filename. This will overwrite the file each time as it is opened in w
mode.
@mpras97 are you still working on this? |
Yes. Willl resolve these comments |
Fix for: #553