MCPcopy Create free account
hub / github.com/driangle/taskmd / handleWorklog

Function handleWorklog

apps/cli/internal/web/handlers.go:486–529  ·  view source on GitHub ↗
(dp *DataProvider)

Source from the content-addressed store, hash-verified

484}
485
486func handleWorklog(dp *DataProvider) http.HandlerFunc {
487 return func(w http.ResponseWriter, r *http.Request) {
488 dp := effectiveDP(r, dp)
489 taskID := r.PathValue("id")
490 if taskID == "" {
491 http.Error(w, "task ID is required", http.StatusBadRequest)
492 return
493 }
494
495 tasks, err := dp.GetTasks()
496 if err != nil {
497 http.Error(w, err.Error(), http.StatusInternalServerError)
498 return
499 }
500
501 found := findTaskByID(tasks, taskID)
502 if found == nil {
503 http.Error(w, "task not found", http.StatusNotFound)
504 return
505 }
506
507 wlPath := worklog.WorklogPath(found.FilePath, taskID)
508 if !worklog.Exists(wlPath) {
509 writeJSON(w, []WorklogEntryJSON{})
510 return
511 }
512
513 wl, err := worklog.ParseWorklog(wlPath)
514 if err != nil {
515 writeJSON(w, []WorklogEntryJSON{})
516 return
517 }
518
519 entries := make([]WorklogEntryJSON, len(wl.Entries))
520 for i, e := range wl.Entries {
521 entries[i] = WorklogEntryJSON{
522 Timestamp: e.Timestamp.Format("2006-01-02T15:04:05Z07:00"),
523 Content: e.Content,
524 }
525 }
526
527 writeJSON(w, entries)
528 }
529}
530
531func handleFeed(dp *DataProvider) http.HandlerFunc {
532 return func(w http.ResponseWriter, r *http.Request) {

Callers 5

registerRoutesMethod · 0.85

Calls 5

effectiveDPFunction · 0.85
writeJSONFunction · 0.85
ErrorMethod · 0.80
GetTasksMethod · 0.80
findTaskByIDFunction · 0.70

Tested by 4