-
Notifications
You must be signed in to change notification settings - Fork 0
initial implementation #2
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
Open
xmonader
wants to merge
11
commits into
master
Choose a base branch
from
development
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
667ea59
initial commit
xmonader 5a8052b
precheck the configPath if empty and replace %w directive in log.Fata…
xmonader 687ef1f
Steal .golangci from the sdk-go
xmonader 2ae7db0
replace fmt, vet, lint targets with lint that uses golangci-lint
xmonader ad8c5b1
unify the timetracker name to timetracker-cli
xmonader 335aaa7
remove cors configs and enforce it to be '*' by default
xmonader d38d7d8
add csv tags
xmonader 298974a
add description to required fields errror message in StartTracking
xmonader 20143ef
Add validation for drivers other than sqlite. Added StatusCreated on …
xmonader 36e4aed
Add validation for backend url, also switching statusOK to statusCrea…
xmonader 546b42f
Add small UI
xmonader File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # Binaries for programs and plugins | ||
| *.exe | ||
| *.exe~ | ||
| *.dll | ||
| *.so | ||
| *.dylib | ||
|
|
||
| # Test binary, built with `go test -c` | ||
| *.test | ||
|
|
||
| # Output of the go coverage tool, specifically when used with LiteIDE | ||
| *.out | ||
|
|
||
| # Go workspace file | ||
| *.workspace | ||
|
|
||
| # IDE and Editor directories and files | ||
| .vscode/ | ||
| .idea/ | ||
| *.sublime-project | ||
| *.sublime-workspace | ||
|
|
||
| # macOS files | ||
| .DS_Store | ||
|
|
||
| # Windows files | ||
| Thumbs.db | ||
|
|
||
| # Logs | ||
| *.log | ||
|
|
||
| # Database files | ||
| *.db | ||
|
|
||
|
|
||
| # Environment variables | ||
| .env | ||
| .env.local | ||
| .env.*.local | ||
|
|
||
| # Build directories | ||
| /bin/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| linters: | ||
| enable: | ||
| - errcheck | ||
| - goconst | ||
| - gofmt | ||
| - govet | ||
| - ineffassign | ||
| - misspell | ||
| - unconvert | ||
| enable-all: false | ||
| run: | ||
| timeout: 20m |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| # Makefile for timetracker | ||
| PWD := $(shell pwd) | ||
| GOPATH := $(shell go env GOPATH) | ||
| # Directories | ||
| SERVER_DIR=cmd/server | ||
| CLIENT_DIR=cmd/client | ||
|
|
||
| # Binaries | ||
| SERVER_BIN=bin/timetrackerd | ||
| CLIENT_BIN=bin/timetracker-cli | ||
|
|
||
| # Default target | ||
| .PHONY: all build lint test clean run-server | ||
|
|
||
| all: build | ||
|
|
||
| # Build both server and client | ||
| build: build-server build-client | ||
|
|
||
| # Build server binary | ||
| build-server: | ||
| @echo "Building server..." | ||
| @mkdir -p bin | ||
| CGO_ENABLED=1 go build -o $(SERVER_BIN) $(SERVER_DIR)/main.go | ||
|
|
||
| # Build client binary | ||
| build-client: | ||
| @echo "Building client..." | ||
| @mkdir -p bin | ||
| CGO_ENABLED=1 go build -o $(CLIENT_BIN) $(CLIENT_DIR)/main.go | ||
|
|
||
| # Lint code by formatting and vetting | ||
|
|
||
| lint: | ||
| @echo "Installing golangci-lint" && go get github.com/golangci/golangci-lint/cmd/golangci-lint && go install github.com/golangci/golangci-lint/cmd/golangci-lint | ||
| go mod tidy | ||
| @echo "Running $@" | ||
| ${GOPATH}/bin/golangci-lint run -c .golangci.yml | ||
|
|
||
| # Run tests | ||
| test: | ||
| @echo "Running tests..." | ||
| go test ./... -v | ||
|
|
||
| # Clean build artifacts | ||
| clean: | ||
| @echo "Cleaning build artifacts..." | ||
| rm -rf bin | ||
|
|
||
| # Run server | ||
| run-server: build-server | ||
| @echo "Running server..." | ||
| $(SERVER_BIN) -config=./team-timetracker-server.sample.json | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,219 @@ | ||
| # Timetracker | ||
|
|
||
| TimeTracker is a robust command-line interface (CLI) and server application designed to help teams to efficiently track time spent on various URLs, such as GitHub issues, project management tasks, or any web-based activities. By seamlessly integrating with your workflow, TimeTracker allows you to start and stop time entries, view detailed logs, and export data in multiple formats. | ||
|
|
||
| ## Getting started | ||
|
|
||
| ### Download the Binaries | ||
|
|
||
| Get the binaries from the releases or download/clone the source code and build it manually | ||
|
|
||
| ### Manual Building | ||
|
|
||
| ### Building the server | ||
|
|
||
| Executing `make build-server` is enough, a binary named `timetrackerd` should be created in the `bin` directory | ||
|
|
||
| ### Building the CLI | ||
|
|
||
| Executing `make build-client` will create a binary named `timetracker` in the `bin` directory | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to unify the name
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated |
||
|
|
||
| ### Running the server | ||
|
|
||
| #### Sample server configuration | ||
|
|
||
| ```json | ||
| { | ||
| "server": { | ||
| "addr": "0.0.0.0:8080", | ||
| "allowed_origins": ["*"] | ||
| }, | ||
| "database": { | ||
| "driver": "sqlite", | ||
| "data_source": "timetracker.db" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| the command to run the server is `./bin/timetrackerd -config ./team-timetracker-server.sample.json` | ||
|
|
||
| ### Running the client | ||
|
|
||
| The client has 3 main commands `start`, `stop`, `entries` | ||
|
|
||
| #### Client configurations | ||
|
|
||
| The client requires configuration either passed as `-config` flag or in `~/.config/team-timetracker.json` that has the username and backend URL | ||
|
|
||
| ```json | ||
| { | ||
| "username": "xmonader", | ||
| "backend_url": "http://localhost:8080" | ||
| } | ||
| ``` | ||
|
|
||
| #### Start time entry | ||
|
|
||
| ``` | ||
| ~> ./bin/timetracker-cli start github.com/theissues/issue/142 "helllooo starting" | ||
| Started tracking ID 9 for URL 'github.com/theissues/issue/142'. | ||
| ``` | ||
|
|
||
| It takes the URL as an argument and a description and returns you a tracking ID | ||
| > Note: you can't start an already started entry. | ||
|
|
||
| #### Stop time entry | ||
|
|
||
| ``` | ||
| ~> ./bin/timetracker-cli stop github.com/theissues/issue/142 | ||
|
|
||
| Stopped tracking for URL 'github.com/theissues/issue/142'. Duration: 35 minutes. | ||
| ``` | ||
|
|
||
| #### Querying the time entries | ||
|
|
||
| > You can generate CSV data by specifying --format=csv | ||
|
|
||
| ##### Querying all of the entries | ||
|
|
||
| ``` | ||
| ~> ./bin/timetracker-cli entries | ||
| Time Entries: | ||
| ------------------------------ | ||
| ID: 9 | ||
| Username: azmy | ||
| URL: github.com/theissues/issue/154 | ||
| Description: helllooo starting | ||
| Start Time: Sun, 15 Sep 2024 22:08:01 EEST | ||
| End Time: Sun, 15 Sep 2024 22:08:14 EEST | ||
| Duration: 3 minutes | ||
| ------------------------------ | ||
| ID: 8 | ||
| Username: xmonader | ||
| URL: github.com/theissues/issue/112 | ||
| Description: hello 142 | ||
| Start Time: Sun, 15 Sep 2024 22:07:10 EEST | ||
| End Time: Sun, 15 Sep 2024 22:07:12 EEST | ||
| Duration: 42 minutes | ||
| ------------------------------ | ||
| ID: 7 | ||
| Username: xmonader | ||
| URL: github.com/theissues/issue/52111 | ||
| Description: the descrpition | ||
| Start Time: Sun, 15 Sep 2024 22:06:55 EEST | ||
| End Time: Sun, 15 Sep 2024 22:06:58 EEST | ||
| Duration: 11 minutes | ||
| ------------------------------ | ||
| ID: 6 | ||
| Username: guido | ||
| URL: github.com/theissues/issue/4 | ||
| Description: alright done | ||
| Start Time: Sun, 15 Sep 2024 22:03:59 EEST | ||
| End Time: Sun, 15 Sep 2024 22:04:09 EEST | ||
| Duration: 20 minutes | ||
| ------------------------------ | ||
| ID: 5 | ||
| Username: guido | ||
| URL: github.com/rfs/issue/87 | ||
| Description: that's tough | ||
| Start Time: Sun, 15 Sep 2024 22:03:00 EEST | ||
| End Time: Sun, 15 Sep 2024 22:03:04 EEST | ||
| Duration: 15 minutes | ||
| ------------------------------ | ||
| ID: 4 | ||
| Username: xmonader | ||
| URL: github.com/zos/issue/414 | ||
| Description: woh | ||
| Start Time: Sun, 15 Sep 2024 22:02:26 EEST | ||
| End Time: Sun, 15 Sep 2024 22:02:41 EEST | ||
| Duration: 33 minutes | ||
| ------------------------------ | ||
| ID: 3 | ||
| Username: xmonader | ||
| URL: github.com/thesites/www_what_io | ||
| Description: another desc1123 | ||
| Start Time: Sun, 15 Sep 2024 22:00:13 EEST | ||
| End Time: --- | ||
| Duration: --- | ||
| ------------------------------ | ||
| ID: 2 | ||
| Username: ahmed | ||
| URL: https://github.com/xmonader/team-timetracker/issues/121 | ||
| Description: el desc | ||
| Start Time: Sun, 15 Sep 2024 20:03:56 EEST | ||
| End Time: Sun, 15 Sep 2024 20:06:05 EEST | ||
| Duration: 24 minutes | ||
| ------------------------------ | ||
| ID: 1 | ||
| Username: ahmed | ||
| URL: https://github.com/xmonader/team-timetracker/issues/1 | ||
| Description: another desc | ||
| Start Time: Sun, 15 Sep 2024 20:03:24 EEST | ||
| End Time: Sun, 15 Sep 2024 20:03:50 EEST | ||
| Duration: 23 minutes | ||
| ------------------------------ | ||
| ``` | ||
|
|
||
| ###### Generating CSV data | ||
|
|
||
| ``` | ||
| ~> ./bin/timetracker-cli entries --format=csv | ||
| ID,Username,URL,Description,Start Time,End Time,Duration (minutes),Created At,Updated At | ||
| 9,azmy,github.com/theissues/issue/154,helllooo starting,2024-09-15T22:08:01+03:00,2024-09-15T22:08:14+03:00,3,2024-09-15T22:08:01+03:00,2024-09-15T22:08:14+03:00 | ||
| 8,xmonader,github.com/theissues/issue/112,hello 142,2024-09-15T22:07:10+03:00,2024-09-15T22:07:12+03:00,42,2024-09-15T22:07:10+03:00,2024-09-15T22:07:12+03:00 | ||
| 7,xmonader,github.com/theissues/issue/52111,the descrpition,2024-09-15T22:06:55+03:00,2024-09-15T22:06:58+03:00,11,2024-09-15T22:06:55+03:00,2024-09-15T22:06:58+03:00 | ||
| 6,guido,github.com/theissues/issue/4,alright done,2024-09-15T22:03:59+03:00,2024-09-15T22:04:09+03:00,20,2024-09-15T22:03:59+03:00,2024-09-15T22:04:09+03:00 | ||
| 5,guido,github.com/rfs/issue/87,that's tough,2024-09-15T22:03:00+03:00,2024-09-15T22:03:04+03:00,15,2024-09-15T22:03:00+03:00,2024-09-15T22:03:04+03:00 | ||
| 4,xmonader,github.com/zos/issue/414,woh,2024-09-15T22:02:26+03:00,2024-09-15T22:02:41+03:00,33,2024-09-15T22:02:26+03:00,2024-09-15T22:02:41+03:00 | ||
| 3,xmonader,github.com/thesites/www_what_io,another desc1123,2024-09-15T22:00:13+03:00,N/A,5,2024-09-15T22:00:13+03:00,2024-09-15T22:00:13+03:00 | ||
| 2,ahmed,https://github.com/xmonader/team-timetracker/issues/121,el desc,2024-09-15T20:03:56+03:00,2024-09-15T20:06:05+03:00,24,2024-09-15T20:03:56+03:00,2024-09-15T20:06:05+03:00 | ||
| 1,ahmed,https://github.com/xmonader/team-timetracker/issues/1,another desc,2024-09-15T20:03:24+03:00,2024-09-15T20:03:50+03:00,23,2024-09-15T20:03:24+03:00,2024-09-15T20:03:50+03:00 | ||
|
|
||
| ``` | ||
|
|
||
| ##### Querying entries by username | ||
|
|
||
| ``` | ||
| ------------------------------ | ||
| ~> ./bin/timetracker-cli entries --username="azmy" | ||
| Time Entries: | ||
| ------------------------------ | ||
| ID: 9 | ||
| Username: azmy | ||
| URL: github.com/theissues/issue/154 | ||
| Description: helllooo starting | ||
| Start Time: Sun, 15 Sep 2024 22:08:01 EEST | ||
| End Time: Sun, 15 Sep 2024 22:08:14 EEST | ||
| Duration: 3 minutes | ||
| ------------------------------ | ||
| ``` | ||
|
|
||
| ##### Querying entries by URL | ||
|
|
||
| ``` | ||
| ~> ./bin/timetracker-cli entries --url="github.com/theissues/issue/154" | ||
| Time Entries: | ||
| ------------------------------ | ||
| ID: 9 | ||
| Username: azmy | ||
| URL: github.com/theissues/issue/154 | ||
| Description: helllooo starting | ||
| Start Time: Sun, 15 Sep 2024 22:08:01 EEST | ||
| End Time: Sun, 15 Sep 2024 22:08:14 EEST | ||
| Duration: 3 minutes | ||
| ------------------------------ | ||
| ``` | ||
|
|
||
| ## Web UI | ||
|
|
||
| ### HomePage | ||
|
|
||
|  | ||
|
|
||
| ### Start a time entry | ||
|
|
||
|  | ||
|
|
||
| ### Stop a time entry | ||
|
|
||
|  | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tried to run but got
got error Binary was compiled with 'CGO_ENABLED=0', go-sqlite3 requires cgo to work.I think we should add
CGO_ENABLED=1There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I added that in the Makefile now.