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

Small fixes for Python 3.9 and requesting all records instead of only 100 #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions weclapp/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ def call(self, command, method, query = {}, body = None, expected_status_code =
kwargs = {}
if len(cts) > 1 and cts[1].startswith('charset'):
enc = cts[1].split("=")
if len(enc) > 1:
kwargs['encoding'] = enc[1]
#if len(enc) > 1:
# kwargs['encoding'] = enc[1]

try:
data = json.loads(data, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion weclapp/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def __repr__(self):


@classmethod
def load(cls, sort=None, pageSize=100, serializeNulls=True):
def load(cls, sort=None, pageSize=-1, serializeNulls=True):
"""
Fetches the data from the public API

Expand Down
2 changes: 1 addition & 1 deletion weclapp/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def print(self, indent='', with_color=True, file=sys.stdout):
print(msg.format(indent, self.projectNumber, self.name, self.id, billable))

@classmethod
def load(cls, tasks=True, time_records=100, **kwargs):
def load(cls, tasks=True, time_records=-1, **kwargs):
"""
Loads projects

Expand Down
9 changes: 9 additions & 0 deletions weclapp/models/timeRecord.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ def dict_for_upload(self):
for field in ['billable', 'projectId', 'projectTaskId', 'durationSeconds' ]:
ret[field] = getattr(self, field)

# Necessary fix because variable is set to false somewhere
ret['billable'] = bool(True)

# Necessary fix since weclapp needs this vaule to be != 0 or billable will be set to false
ret['billableDurationSeconds'] = ret['durationSeconds']

ret['startDate'] = int(self.startDate.timestamp() * 1000)

if isinstance(self.description, str) and self.description.strip() != '':
Expand Down Expand Up @@ -90,6 +96,9 @@ def upload_to_weclapp(self):

body = json.dumps(self.dict_for_upload())

# Uncomment the following line if you want to see the plain request being sent
#print("DEBUG Request body: %s" % body)

try:
res = self.__api__.call(self.__fetch_command__, 'POST', body=body, expected_status_code=201)
except:
Expand Down