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

Add printing adjustments #182

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

Add printing adjustments #182

wants to merge 3 commits into from

Conversation

glee-
Copy link

@glee- glee- commented Jun 15, 2019

Depended on by ocf/utils#114

Allows staff members to adjust users' paper quotas in a more flexible manner.

We add the following functionality to the paper script:
forward: increases a user's daily quota for the day only

This is intended to be used to give users some degree of freedom when printing documents.

For example, if the daily print limit was set at 10 pages and a user wanted to print 12 pages, this would not be possible with the current way things are configured. forward provides the way to increase the daily print limit without increasing the amount of pages a user can print in a semester.

Copy link
Member

@abizer abizer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trusting this works since I'm too tired to parse the SQL right now, lgtm otherwise

@glee-
Copy link
Author

glee- commented Jun 15, 2019

The associated quota tests need to be updated as well before merging this in

Copy link
Member

@dkess dkess left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gonna assume this gets tested a lot before next semester starts. Still, you shouldn't use a varchar where an enum belongs.

@@ -117,6 +118,6 @@ def add_job(c, job):
c.execute(*_namedtuple_to_query('INSERT INTO jobs ({}) VALUES ({})', job))


def add_refund(c, refund):
def add_adjustment(c, payload):
"""Add a new refund to the database."""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this docstring

`id` int NOT NULL AUTO_INCREMENT,
`user` varchar(255) NOT NULL,
`time` datetime NOT NULL,
`action` varchar(255) NOT NULL,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should either be an enum (refund or forward), or you should leave this table alone and make a new forwards table. Personally I think the latter is a better option, since every time you use this table you have to check action anyways. But either is fine.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was initially considering to go with the latter option that you proposed, but I ultimately decided to continue with this current implementation to introduce less complexity for the next person who decides to work on this section of the code.

Performance-wise, I believe that the latter option will be better off as well due to locality, but it is hard to tell for certain because of how SQL operates on the lower layers.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to care about performance for this. Why do you think your current solution introduces less complexity? It's slightly less verbose but I would argue needing to put if statements everywhere to check for refund/forward makes things more complicated for anyone working on this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually think one table is logically and conceptually simpler. We never interact with this table directly anyways on the read, we do it through the views, which introduce the two table abstraction you're looking for. My conception of this problem is that the difference between refunds and adjustments is whether they permanently increase semesterly quota when increasing daily quota, and given that that is an application-code level concern that just requires a binary switch in the database to decide, it suggests they should continue to live in the same table.

Would switch the column for a enum, or better yet, a boolean, though. eg is_adjustment or is_refund

Copy link
Member

@cg505 cg505 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on this!

I'd generally agree with @dkess that I think it would make sense to add a new table. In my opinion that would make it clearer what's going on, (and in a sense, decrease complexity).

ON jobs_semester.user = refunds_semester.user
FROM refunds_semester
LEFT OUTER JOIN jobs_semester
ON refunds_semester.user = jobs_semester.user
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was this change made?

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

Successfully merging this pull request may close these issues.

5 participants