Skip to content
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

Open
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

the-xperimentalist
Copy link

Fix for: #553

@coveralls
Copy link

coveralls commented Mar 22, 2020

Coverage Status

Coverage decreased (-0.05%) to 67.308% when pulling b3470b5 on prasoonmayank:master into b8309fb on pythonindia:master.

@palnabarun
Copy link
Member

@prasoonmayank Left some comments.

Also, please lint your code before committing. You can do so by running nox -s lint

Copy link
Contributor

@sks444 sks444 left a 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.

requirements.txt Outdated Show resolved Hide resolved
@the-xperimentalist
Copy link
Author

Will be completing proper testing with corner cases by today

@sks444
Copy link
Contributor

sks444 commented Mar 25, 2020

@prasoonmayank, It looks like you have committed your env file?

Copy link
Contributor

@sks444 sks444 left a 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. :)

@ananyo2012 ananyo2012 closed this Mar 26, 2020
@ananyo2012 ananyo2012 reopened this Mar 26, 2020
@ananyo2012
Copy link
Contributor

@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.

@the-xperimentalist
Copy link
Author

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

@pradyunsg
Copy link
Contributor

@prasoonmayank Why is nox not working for you? Could you share the error message?

@pradyunsg
Copy link
Contributor

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).

@ananyo2012
Copy link
Contributor

ananyo2012 commented Apr 5, 2020 via email

@pradyunsg pradyunsg changed the title Added command Added command to export reviewer's votes Apr 5, 2020
@the-xperimentalist
Copy link
Author

@prasoonmayank Why is nox not working for you? Could you share the error message?

There were essentially two problems in my case:

  1. pipx wasn't installing nox.
  2. For some reason, nox command in Mac was setup in a different folder, since there are multiple python versions installed probably?
  3. Regarding linting, with the latest changes, we are able to lint with the pre-commit command only with the python version being 3.6

@ananyo2012
Copy link
Contributor

@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 pytest --cov -v --tb=native.

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.

@the-xperimentalist
Copy link
Author

#660

I installed python3.6 for the pre-commit linter to work.
Regarding the test coverage. All the test cases have been passing, but the build is failing for some reason. Can you suggest some probable reason for the same?

@pradyunsg
Copy link
Contributor

@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.

@ananyo2012
Copy link
Contributor

The isort fails are a valid one I mentioned in #663 cc: @pradyunsg

@pradyunsg
Copy link
Contributor

pradyunsg commented Apr 6, 2020

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. :)

@pradyunsg
Copy link
Contributor

Other than that, please feel free to go ahead and merge master into this PR / rebase this PR on master.

@sayanchowdhury
Copy link
Member

Before merging please make sure the commits are squashed.

@the-xperimentalist
Copy link
Author

Hey @palnabarun Please review the pr. As it is in requested changes state right now

Copy link
Member

@palnabarun palnabarun left a 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
Copy link
Member

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.

Copy link
Author

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?

Copy link
Author

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
Copy link
Member

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
Copy link
Member

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")
Copy link
Contributor

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.

Copy link
Author

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?

Copy link
Contributor

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",
Copy link
Contributor

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

Copy link
Author

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 = (
Copy link
Contributor

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 ?

Copy link
Author

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,
Copy link
Contributor

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.

row = (p.proposal_type.name, p.title, p.get_reviewer_votes_sum(),

Copy link
Author

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?

Copy link
Contributor

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)
Copy link
Contributor

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.

@aniruddha2000
Copy link

@mpras97 are you still working on this?

@the-xperimentalist
Copy link
Author

@mpras97 are you still working on this?

Yes. Willl resolve these comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants