Skip to content

Commit cda69c7

Browse files
committed
WorkLog -> Worklog
1 parent 8fd7ad2 commit cda69c7

File tree

9 files changed

+74
-74
lines changed

9 files changed

+74
-74
lines changed

gojira/cli.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ var AppAsciiArt = fmt.Sprintf(""+
2121
" _/ | v%s \n"+
2222
" |__/ \n\n", projectVersion)
2323

24-
var WorkLogsCommand = &cli.Command{
24+
var WorklogsCommand = &cli.Command{
2525
Name: "worklogs",
2626
Usage: "Edit your today's work log",
2727
Action: func(c *cli.Context) error {
@@ -36,7 +36,7 @@ var WorkLogsCommand = &cli.Command{
3636
},
3737
}
3838

39-
func NewWorkLogIssues() error {
39+
func NewWorklogIssues() error {
4040
// goroutine awesomeness
4141
var err error
4242
startDate, endDate := MonthRange(app.time)
@@ -45,7 +45,7 @@ func NewWorkLogIssues() error {
4545
}
4646
if app.workLogsIssues.startDate != startDate || app.workLogsIssues.endDate != endDate {
4747
app.ui.loaderView.Show("Fetching worklogs...")
48-
app.workLogs, err = GetWorkLogs()
48+
app.workLogs, err = GetWorklogs()
4949
app.ui.loaderView.Hide()
5050
if err != nil {
5151
return err
@@ -55,19 +55,19 @@ func NewWorkLogIssues() error {
5555
}
5656
app.workLogsIssues.startDate = startDate
5757
app.workLogsIssues.endDate = endDate
58-
app.workLogsIssues.issues = []WorkLogIssue{}
58+
app.workLogsIssues.issues = []WorklogIssue{}
5959
waitGroup := sync.WaitGroup{}
6060
var errors []error
6161
errCh := make(chan error, len(app.workLogs.logs))
6262
for i := range app.workLogs.logs {
6363
waitGroup.Add(1)
64-
go func(workLog *WorkLog) {
64+
go func(workLog *Worklog) {
6565
issue, err := NewJiraClient().GetIssue(workLog.Issue.Key)
6666
if err != nil {
6767
errCh <- err // Send the error to the channel.
6868
return
6969
}
70-
app.workLogsIssues.issues = append(app.workLogsIssues.issues, WorkLogIssue{WorkLog: workLog, Issue: issue})
70+
app.workLogsIssues.issues = append(app.workLogsIssues.issues, WorklogIssue{Worklog: workLog, Issue: issue})
7171
waitGroup.Done()
7272
}(app.workLogs.logs[i])
7373
}
@@ -241,7 +241,7 @@ func (issue Issue) LogWork(logTime *time.Time, timeSpent string) error {
241241
if err != nil {
242242
return err
243243
}
244-
if Config.UpdateExistingWorkLog {
244+
if Config.UpdateExistingWorklog {
245245
for index, workLog := range todayWorklog {
246246
if workLog.Issue.Key == issue.Key {
247247
//fmt.Println("Updating existing worklog...")
@@ -257,12 +257,12 @@ func (issue Issue) LogWork(logTime *time.Time, timeSpent string) error {
257257
}
258258
}
259259
}
260-
worklog, err := NewWorkLog(issue.Key, logTime, timeSpent)
260+
worklog, err := NewWorklog(issue.Key, logTime, timeSpent)
261261
if err != nil {
262262
return err
263263
}
264264
// add this workload to global object
265265
app.workLogs.logs = append(app.workLogs.logs, &worklog)
266-
app.workLogsIssues.issues = append(app.workLogsIssues.issues, WorkLogIssue{Issue: issue, WorkLog: &worklog})
266+
app.workLogsIssues.issues = append(app.workLogsIssues.issues, WorklogIssue{Issue: issue, Worklog: &worklog})
267267
return nil
268268
}

gojira/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func GetEnv(key string) (env string) {
1616

1717
type Configuration struct {
1818
JiraUrl, JiraLogin, JiraToken, TempoUrl, TempoToken, JiraAccountId string
19-
UpdateExistingWorkLog bool
19+
UpdateExistingWorklog bool
2020
}
2121

2222
var Config *Configuration
@@ -29,6 +29,6 @@ func PrepareConfig() {
2929
JiraAccountId: GetEnv("GOJIRA_JIRA_ACCOUNT_ID"),
3030
TempoUrl: "https://api.tempo.io/core/3",
3131
TempoToken: GetEnv("GOJIRA_TEMPO_TOKEN"),
32-
UpdateExistingWorkLog: true,
32+
UpdateExistingWorklog: true,
3333
}
3434
}

gojira/dayview.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func loadWorklogs() {
9191
case loadingWorklogs <- true:
9292
go func() {
9393
defer func() { <-loadingWorklogs }()
94-
err := NewWorkLogIssues()
94+
err := NewWorklogIssues()
9595
if err != nil {
9696
app.ui.errorView.ShowError(err.Error())
9797
}
@@ -116,7 +116,7 @@ func (d *DayView) update() {
116116
)
117117
d.worklogList.SetCell(r, TimeSpentColumn,
118118
tview.NewTableCell(
119-
FormatTimeSpent((logs)[r].WorkLog.TimeSpentSeconds)).SetTextColor(color).SetAlign(tview.AlignLeft),
119+
FormatTimeSpent((logs)[r].Worklog.TimeSpentSeconds)).SetTextColor(color).SetAlign(tview.AlignLeft),
120120
)
121121
}
122122
d.worklogList.Select(0, IssueKeyColumn).SetFixed(1, 1).SetDoneFunc(func(key tcell.Key) {
@@ -126,7 +126,7 @@ func (d *DayView) update() {
126126
}).SetSelectedFunc(func(row, column int) {
127127
NewUpdateWorklogForm(d, logs, row)
128128
})
129-
timeSpent := CalculateTimeSpent(getWorkLogsFromWorkLogIssues(logs))
129+
timeSpent := CalculateTimeSpent(getWorklogsFromWorklogIssues(logs))
130130
d.worklogStatus.SetText(
131131
fmt.Sprintf("Worklogs - %s - [%s%s[white]]",
132132
app.time.Format("2006-01-02"),
@@ -276,15 +276,15 @@ func NewAddWorklogForm(d *DayView, issues []Issue, row int) *tview.Form {
276276
return form
277277
}
278278

279-
func NewUpdateWorklogForm(d *DayView, workLogIssues []*WorkLogIssue, row int) *tview.Form {
279+
func NewUpdateWorklogForm(d *DayView, workLogIssues []*WorklogIssue, row int) *tview.Form {
280280
var form *tview.Form
281281

282282
updateWorklog := func() {
283283
timeSpent := form.GetFormItem(0).(*tview.InputField).GetText()
284284
go func() {
285285
app.ui.loaderView.Show("Updating worklog...")
286286
defer app.ui.loaderView.Hide()
287-
err := workLogIssues[row].WorkLog.Update(timeSpent)
287+
err := workLogIssues[row].Worklog.Update(timeSpent)
288288
if err != nil {
289289
app.ui.errorView.ShowError(err.Error())
290290
return
@@ -300,7 +300,7 @@ func NewUpdateWorklogForm(d *DayView, workLogIssues []*WorkLogIssue, row int) *t
300300
go func() {
301301
app.ui.loaderView.Show("Deleting worklog...")
302302
defer app.ui.loaderView.Hide()
303-
err := app.workLogs.Delete(workLogIssues[row].WorkLog)
303+
err := app.workLogs.Delete(workLogIssues[row].Worklog)
304304
if err != nil {
305305
app.ui.errorView.ShowError(err.Error())
306306
return
@@ -313,7 +313,7 @@ func NewUpdateWorklogForm(d *DayView, workLogIssues []*WorkLogIssue, row int) *t
313313
}
314314

315315
form = tview.NewForm().
316-
AddInputField("Time spent", FormatTimeSpent(workLogIssues[row].WorkLog.TimeSpentSeconds), 20, nil, nil).
316+
AddInputField("Time spent", FormatTimeSpent(workLogIssues[row].Worklog.TimeSpentSeconds), 20, nil, nil).
317317
AddButton("Update", updateWorklog).
318318
AddButton("Delete", deleteWorklog).
319319
AddButton("Cancel", func() {

gojira/gojira.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ type gojira struct {
1212
cli *cli.App
1313
ui *UserInteface
1414
time *time.Time
15-
workLogs WorkLogs
16-
workLogsIssues WorkLogsIssues
15+
workLogs Worklogs
16+
workLogsIssues WorklogsIssues
1717
}
1818

1919
func Run() {
@@ -59,7 +59,7 @@ func Run() {
5959
Commands: []*cli.Command{
6060
LogWorkCommand,
6161
IssuesCommand,
62-
WorkLogsCommand,
62+
WorklogsCommand,
6363
ConfigCommand,
6464
ViewIssueCommand,
6565
},

gojira/jira.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ type Issue struct {
6464
} `json:"fields"`
6565
}
6666

67-
type WorkLogResponse struct {
67+
type WorklogResponse struct {
6868
Self string `json:"self"`
6969
Author struct {
7070
Self string `json:"self"`
@@ -120,7 +120,7 @@ func (jc *JiraClient) GetIssue(issueKey string) (Issue, error) {
120120
return jiraIssue, nil
121121
}
122122

123-
func (jc *JiraClient) CreateWorklog(issueKey string, logTime *time.Time, timeSpent string) (WorkLogResponse, error) {
123+
func (jc *JiraClient) CreateWorklog(issueKey string, logTime *time.Time, timeSpent string) (WorklogResponse, error) {
124124
payload := map[string]string{
125125
"timeSpent": FormatTimeSpent(TimeSpentToSeconds(timeSpent)),
126126
"adjustEstimate": "leave",
@@ -131,13 +131,13 @@ func (jc *JiraClient) CreateWorklog(issueKey string, logTime *time.Time, timeSpe
131131
requestUrl := fmt.Sprintf("%s/rest/api/2/issue/%s/worklog?notifyUsers=false", Config.JiraUrl, issueKey)
132132
response, err := SendHttpRequest("POST", requestUrl, requestBody, jc.getHttpHeaders(), 201)
133133
if err != nil {
134-
return WorkLogResponse{}, err
134+
return WorklogResponse{}, err
135135
}
136136

137-
var workLogRequest WorkLogResponse
137+
var workLogRequest WorklogResponse
138138
err = json.Unmarshal(response, &workLogRequest)
139139
if err != nil {
140-
return WorkLogResponse{}, err
140+
return WorklogResponse{}, err
141141
}
142142
return workLogRequest, nil
143143
}

gojira/tempo.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ func NewTempoClient() *TempoClient {
2121
}
2222
}
2323

24-
type WorkLogsResponse struct {
25-
WorkLogs []WorkLog `json:"results"`
24+
type WorklogsResponse struct {
25+
Worklogs []Worklog `json:"results"`
2626
}
2727

28-
type WorkLogUpdateRequest struct {
28+
type WorklogUpdateRequest struct {
2929
IssueKey string `json:"issueKey"`
3030
StartDate string `json:"startDate"`
3131
StartTime string `json:"startTime"`
@@ -34,7 +34,7 @@ type WorkLogUpdateRequest struct {
3434
TimeSpentSeconds int `json:"timeSpentSeconds"`
3535
}
3636

37-
func (tc *TempoClient) GetWorklogs(fromDate, toDate time.Time) (WorkLogsResponse, error) {
37+
func (tc *TempoClient) GetWorklogs(fromDate, toDate time.Time) (WorklogsResponse, error) {
3838
// tempo is required only because of fetching worklogs by date range
3939
requestUrl := fmt.Sprintf("%s/worklogs/user/%s?from=%s&to=%s&limit=1000",
4040
tc.Url, tc.JiraAccountId, fromDate.Format(dateLayout), toDate.Format(dateLayout))
@@ -44,20 +44,20 @@ func (tc *TempoClient) GetWorklogs(fromDate, toDate time.Time) (WorkLogsResponse
4444
}
4545
response, err := SendHttpRequest("GET", requestUrl, nil, headers, 200)
4646
if err != nil {
47-
return WorkLogsResponse{}, err
47+
return WorklogsResponse{}, err
4848
}
49-
var workLogsResponse WorkLogsResponse
49+
var workLogsResponse WorklogsResponse
5050
err = json.Unmarshal(response, &workLogsResponse)
5151
if err != nil {
52-
return WorkLogsResponse{}, err
52+
return WorklogsResponse{}, err
5353
}
5454
return workLogsResponse, err
5555
}
5656

57-
func (tc *TempoClient) UpdateWorklog(worklog *WorkLog, timeSpent string) error {
57+
func (tc *TempoClient) UpdateWorklog(worklog *Worklog, timeSpent string) error {
5858
timeSpentInSeconds := TimeSpentToSeconds(timeSpent)
5959

60-
payload := WorkLogUpdateRequest{
60+
payload := WorklogUpdateRequest{
6161
IssueKey: worklog.Issue.Key,
6262
StartDate: worklog.StartDate,
6363
StartTime: worklog.StartTime,
@@ -76,8 +76,8 @@ func (tc *TempoClient) UpdateWorklog(worklog *WorkLog, timeSpent string) error {
7676
return err
7777
}
7878

79-
func (tc *TempoClient) DeleteWorklog(tempoWorkLogId int) error {
80-
requestUrl := fmt.Sprintf("%s/worklogs/%d", Config.TempoUrl, tempoWorkLogId)
79+
func (tc *TempoClient) DeleteWorklog(tempoWorklogID int) error {
80+
requestUrl := fmt.Sprintf("%s/worklogs/%d", Config.TempoUrl, tempoWorklogID)
8181
headers := map[string]string{
8282
"Authorization": fmt.Sprintf("Bearer %s", Config.TempoToken),
8383
"Content-Type": "application/json",

gojira/utils.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ import (
1313

1414
const dateLayout = "2006-01-02"
1515

16-
func getWorkLogsFromWorkLogIssues(workLogIssues []*WorkLogIssue) []*WorkLog {
17-
var workLogs []*WorkLog
16+
func getWorklogsFromWorklogIssues(workLogIssues []*WorklogIssue) []*Worklog {
17+
var workLogs []*Worklog
1818
for _, workLog := range workLogIssues {
19-
workLogs = append(workLogs, workLog.WorkLog)
19+
workLogs = append(workLogs, workLog.Worklog)
2020
}
2121
return workLogs
2222
}
2323

24-
func CalculateTimeSpent(workLogs []*WorkLog) int {
24+
func CalculateTimeSpent(workLogs []*Worklog) int {
2525
timeSpentInSeconds := 0
2626
for _, workLog := range workLogs {
2727
timeSpentInSeconds += workLog.TimeSpentSeconds

gojira/utils_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func TestFormatTimeSpent(t *testing.T) {
2626
}
2727

2828
func TestCalculateTimeSpent(t *testing.T) {
29-
fixture := []*WorkLog{
29+
fixture := []*Worklog{
3030
{TimeSpentSeconds: 60}, // 1m
3131
{TimeSpentSeconds: 3600}, // 1h
3232
{TimeSpentSeconds: 7200}, // 2h

0 commit comments

Comments
 (0)