feat(times): Sort time log items by date (fix #10)
This commit is contained in:
		
							
								
								
									
										7
									
								
								times.go
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								times.go
									
									
									
									
									
								
							| @ -3,6 +3,7 @@ package main | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"os" | ||||
| 	"sort" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/charmbracelet/bubbles/table" | ||||
| @ -56,6 +57,10 @@ func getTimeLogs(since time.Time, on_process_repo func(repo gitea.Repository, to | ||||
| 			page++ | ||||
| 		} | ||||
| 	} | ||||
| 	// Sort the times by Created At | ||||
| 	sort.Slice(times, func(i, j int) bool { | ||||
| 		return times[i].Created.Compare(times[j].Created) > 1 | ||||
| 	}) | ||||
| 	return times | ||||
| } | ||||
|  | ||||
| @ -104,7 +109,7 @@ func times() { | ||||
| 		} | ||||
| 	}() | ||||
|  | ||||
| 	since := time.Now().AddDate(0, 0, -7) | ||||
| 	since := time.Now().AddDate(0, -6, 0) | ||||
| 	times := getTimeLogs(since, func(repo gitea.Repository, took time.Duration) { | ||||
| 		p.Send(IndicatorInfo{ | ||||
| 			info:     fmt.Sprintf("%s / %s", repo.Owner.UserName, repo.Name), | ||||
|  | ||||
		Reference in New Issue
	
	Block a user