Skip to content

Commit 55e33f4

Browse files
committed
fix(toggl): correct harvest output column names
1 parent 48afc6a commit 55e33f4

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

compiler_admin/services/harvest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import compiler_admin.services.files as files
99

1010
# input CSV columns needed for conversion
11-
INPUT_COLUMNS = ["Date", "Client", "Project", "Notes", "Hours", "First Name", "Last Name"]
11+
INPUT_COLUMNS = ["Date", "Client", "Project", "Notes", "Hours", "First name", "Last name"]
1212

1313
# default output CSV columns
1414
OUTPUT_COLUMNS = ["Email", "Start date", "Start time", "Duration", "Project", "Task", "Client", "Billable", "Description"]
@@ -63,7 +63,7 @@ def convert_to_toggl(
6363
source["Billable"] = "Yes"
6464

6565
# add the Email column
66-
source["Email"] = source["First Name"].apply(lambda x: f"{x.lower()}@compiler.la")
66+
source["Email"] = source["First name"].apply(lambda x: f"{x.lower()}@compiler.la")
6767

6868
# Convert numeric Hours to timedelta Duration
6969
source["Duration"] = source["Hours"].apply(pd.to_timedelta, unit="hours")

compiler_admin/services/toggl.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
INPUT_COLUMNS = ["Email", "Task", "Client", "Start date", "Start time", "Duration", "Description"]
1919

2020
# default output CSV columns
21-
OUTPUT_COLUMNS = ["Date", "Client", "Project", "Task", "Notes", "Hours", "First Name", "Last Name"]
21+
OUTPUT_COLUMNS = ["Date", "Client", "Project", "Task", "Notes", "Hours", "First name", "Last name"]
2222

2323

2424
def _harvest_client_name():
@@ -119,9 +119,9 @@ def convert_to_harvest(
119119
# get cached project name if any
120120
source["Project"] = source["Project"].apply(lambda x: _toggl_project_info(x) or x)
121121

122-
# assign First and Last Name
123-
source["First Name"] = source["Email"].apply(_get_first_name)
124-
source["Last Name"] = source["Email"].apply(_get_last_name)
122+
# assign First and Last name
123+
source["First name"] = source["Email"].apply(_get_first_name)
124+
source["Last name"] = source["Email"].apply(_get_last_name)
125125

126126
# calculate hours as a decimal from duration timedelta
127127
source["Hours"] = (source["Duration"].dt.total_seconds() / 3600).round(2)

notebooks/data/harvest-sample.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Date,Client,Project,Project Code,Task,Notes,Hours,Billable?,Invoiced?,Approved?,First Name,Last Name,Roles,Employee?,External Reference URL
1+
Date,Client,Project,Project Code,Task,Notes,Hours,Billable?,Invoiced?,Approved?,First name,Last name,Roles,Employee?,External Reference URL
22
2023-01-21,Client1,Project5,PROJECT,Project Consulting,nascetur ridiculus mus etiam vel augue vestibulum rutrum rutrum neque aenean auctor gravida sem praesent id massa id nisl venenatis lacinia aenean sit,2.51,true,false,false,Hetti,Becken,Team Member,true,
33
2023-01-07,Client1,Project4,PROJECT,Project Consulting,quam a odio in hac habitasse platea dictumst maecenas ut massa quis augue luctus tincidunt nulla mollis molestie lorem quisque ut erat curabitur,1.84,false,true,false,Sawyer,Berrey,Team Member,false,
44
2023-01-25,Client1,Project5,PROJECT,Project Consulting,odio odio elementum eu interdum eu tincidunt in leo maecenas pulvinar lobortis est,2.11,true,false,true,Silas,Idenden,Team Member,true,

tests/services/test_toggl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def test_convert_to_harvest_sample(toggl_file, harvest_file, mock_google_user_in
206206
assert isinstance(output, str)
207207
assert ",".join(OUTPUT_COLUMNS) in output
208208

209-
order = ["Date", "First Name", "Hours"]
209+
order = ["Date", "First name", "Hours"]
210210
sample_output_df = pd.read_csv(harvest_file).sort_values(order)
211211
output_df = pd.read_csv(StringIO(output)).sort_values(order)
212212

0 commit comments

Comments
 (0)