Skip to content

Allaye/Trakar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation


Trakar

This is a real time project activity time tracker, which tracks your time spent on projects.
Report Bug · Request Feature

Thanks for checking out this project.
If you have a suggestion that would make this better, please fork the repo and create a pull request or simply open an issue with the tag "feature update".
Don't forget to give the project a star if you like it!
Thanks again! Now go create something AMAZING! :D🫂
Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Examples

About The Project

This is a real time project activity tracker, which tracks your time spent on projects. with this app you can track the time employees spents on projects. and come out with some analytics insight from it. it can be use to calculate employee productivity and wages etc.

(back to top)

Built With

(back to top)

Getting Started

To get started download or clone the repo.

Prerequisites

You are required to have at least python 3.6.0 installed to use this project

Installation

Navigate into the project directory and install the requirements.txt file. install the requirements.txt file using the following command:

  1. Clone the repo using: git clone https://github.com/allaye/trakar.git
  2. Navigate into the directory containing the project: cd trakar
  3. Install the requirements.txt file using: pip install -r requirements.txt
  4. Run the project using: python manage.py runserver

(back to top)

Usage

This section contains all the useful endpoints this project provides.

- [x] User endpoints

    - [x] Register a new user
         * POST /api/register/
          request body:{
              "username": "johndoe",
              "email": "[email protected]",
              "password": "password"
          }
    - [x] Login a user
         * POST /api/login/
          request body:{
              "email": "[email protected]",
              "password": "password"
          }
          response object:{
              "email": "[email protected]",
              "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6ImEiLCJlbWFpbCI6ImFAZW1haWwuY29tIiwiZXhwIjoxNjQwNDQ2OTM1fQ.wF4WvEK37GOXRWC8rzRWUv2UgToNtqaRXte_G_wbO4s",
              "is_staff": false
          }
    - [x] Logout a user:{
      requirement is to be loged in
    }

- [x] Project endpoints

  -[x] Create New Project (can only be created by an admin)
      * POST /api/create/project/
        request body:{
            "name": "project name",
            "description": "project description",
            "members": [1,4,2]
            "start_date": "2020-01-01",
            "end_date": "",
            "is_active": true
        }
        response object:{
            "id": 1,
            "name": "project name",
            "description": "project description",
            "start_date": "2020-01-01",
            "end_date": "2020-01-01",
            "is_active": true
        }
  -[x] Get all projects
      * GET /api/projects/
        response object:{
            "projects": [
                {
                    "id": 1,
                    "name": "project name",
                    "description": "project description",
                    "start_date": "2020-01-01",
                    "end_date": "2020-01-01",
                    "is_active": true,
                    "members""[1,3]
                },
                {
                    "id": 2,
                    "name": "project name",
                    "description": "project description",
                    "start_date": "2020-01-01",
                    "end_date": "2020-01-01",
                    "is_active": true,
                    "members""[4]
                }
            ]
        }
- [x] Project Activities endpoints
    
    -[x] Create New Project Activity
        * POST /api/create/project/activity/
          request body:{
              "user": 1,
              "project": 1,
              "activity": "activity name",
              "description": "activity description",
              "start_date": "2020-01-01",
              "end_date": "",
          }
          response object:{
              "id": 1,
              "project": 1,
              "activity": "activity name",
              "description": "activity description",
              "start_date": "2020-01-01",
              "end_date": "2020-01-01",
              "is_active": true
              "duration": 1000
          }
    -[x] Get all project activities
        * GET /api/project/activities/
          response object:{
              "activities": [
                  {
                      "id": 1,
                      "project": 1,
                      "activity": "activity name",
                      "description": "activity description",
                      "start_date": "2020-01-01",
                      "end_date": "2020-01-01",
                      "is_active": true
                  },
                  {
                      "id": 2,
                      "project": 1,
                      "activity": "activity name",
                      "description": "activity description",
                      "start_date": "2020-01-01",
                      "end_date": "2020-01-01",
                      "is_active": true
                  }
              ]
          }

(back to top)

Examples

Register a new user, to create a new non admin user use the below example, create a post request with the following minimum request body:

- Endpoint: Post: /api/register/
- Request body:{
"username": "ab",
"email": "[email protected]",
"password": "[email protected]"
}

- Response:{
"id": 1,
"username": "ab",
"email": "[email protected]",
"is_staff": false
}

after creating a new user, you can now login with the email and password you provided to obtain a token on succesful login. login using the below endpoint and example request body:

- Endpoint: Post: /api/login/
- Request body:{
"email": "[email protected]",
"password": "[email protected]"
}

- Response:{
"email": "[email protected]",
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6ImEiLCJlbWFpbCI6ImFAZW1haWwuY29tIiwiZXhwIjoxNjQxMDUyMjI0fQ.unXe-dxoFCEY5l2VGkeRR8ue-Ggr6YxQS2nJUA63VZ4",
"is_staff": false
}

On successful login you get the above response object, the most important value there is the token, the token will be use on all protected endpoint in other to gain access to the protected endpoints.

Project Endpoints: The project endpoints have some few requirements to be able to use the endpoints,

  1. You must be an admin to create a project
  2. You must be logged in get details of a project
  3. A project can have 1 or more members

create a new project using the below endpoint and example request body:

- Endpoint: Post: /api/create/project
- Authorization: Bearer <eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6ImEiLCJlbWFpbCI6ImFAZW1haWwuY29tIiwiZXhwIjoxNjQxMDUyMjI0fQ.unXe-dxoFCEY5l2VGkeRR8ue-Ggr6YxQS2nJUA63VZ4>
- Request body:{
"name": "project pholoa",
"description": "blockchain systems to track spent time",
"technology": {"technology":"blockchain"},
"members": [1,4,2]           // this are the members ids added to the project (project members)
"start_date": "2022-01-01",  // if left blank it defaults to today
}

- Response:{
"id": 3,
"is_completed": false,
"title": "",
"description": "blockchain systems to track spent time",
"technology": {
    "technology": "blockchain"
},
"start_date": "2022-01-01",
"end_date": null,
"members": [
    1, 4, 2
]
}

you get a 403 error if you try to create a project without being an admin, to create an admin user you added

  • "is_staff": 1  
    

to the user body when creating a user.

List all, one, update and delete project endpoints are protected use token to access them, endpoints url List All:

  •  Endpoint Get api/projects/
    
  •  Authorization: Bearer <eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6ImEiLCJlbWFpbCI6ImFAZW1haWwuY29tIiwiZXhwIjoxNjQxMDUyMjI0fQ.unXe-dxoFCEY5l2VGkeRR8ue-Ggr6YxQS2nJUA63VZ4>
    
  •  - Response:{
      "projects": [
          {
              "id": 1,
              "is_completed": false,
              "title": "",
              "description": "blockchain systems to track spent time",
              "technology": {
                  "technology": "blockchain"
              },
              "start_date": "2022-01-01",
              "end_date": null,
              "members": [
                  1, 4, 2
              ]
          }
    

List All endpoint user is member of:

  •  Endpoint Get api/projects/me/
    
  •  token: <eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6ImEiLCJlbWFpbCI6ImFAZW1haWwuY29tIiwiZXhwIjoxNjQxMDUyMjI0fQ.unXe-dxoFCEY5l2VGkeRR8ue-Ggr6YxQS2nJUA63VZ4>
    
  •  Response{
    
      }
    

List one project:

  •  Endpoint Get api/projects/1/
    
  •  Authorization: Bearer <eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6ImEiLCJlbWFpbCI6ImFAZW1haWwuY29tIiwiZXhwIjoxNjQxMDUyMjI0fQ.unXe-dxoFCEY5l2VGkeRR8ue-Ggr6YxQS2nJUA63VZ4>
    
  •  Response{
      "id": 1,
      "is_completed": false,
      "title": "",
      "description": "blockchain systems to track spent time",
      "technology": {
          "technology": "blockchain"
      },
      "start_date": "2022-01-01",
      "end_date": null,
      "members": [
          1, 4, 2
      ]
      }
    

delete a project:

  •  Endpoint DELETE api/project/delete/1/
    
  •  Authorization: Bearer <eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6ImEiLCJlbWFpbCI6ImFAZW1haWwuY29tIiwiZXhwIjoxNjQxMDUyMjI0fQ.unXe-dxoFCEY5l2VGkeRR8ue-Ggr6YxQS2nJUA63VZ4>
    
  •  Response{
      "message": "Project deleted successfully"
      }
    

Update a project:

  •  Endpoint PATCH api/project/update/1/
    
  •  Authorization: Bearer <eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6ImEiLCJlbWFpbCI6ImFAZW1haWwuY29tIiwiZXhwIjoxNjQxMDUyMjI0fQ.unXe-dxoFCEY5l2VGkeRR8ue-Ggr6YxQS2nJUA63VZ4>
    
  •  Request body:{
      "start_date": "2022-01-01",
      "end_date": 2022-10-10,
      }
    
  •  Response{
      "id": 1,
      "is_completed": true,
      "title": "title here",
      "description": "blockchain systems to track spent time",
      "technology": {
          "technology": "blockchain"
      },
      "start_date": "2022-01-01",
      "end_date": "2022-10-10",
      "members": [
          1, 4, 2
      ]
      }
    

Project activities endpoints: These endpoints are used to create, list, update and delete project activities. activities are tasks that are perform on a project., theses endpoints are all protected, use token to access them,

The project activities endpoints have some few requirements to be able to use the endpoints,

  1. only a project member can create a project activity on a project
  2. only a project activity creator can update or delete a project activity
  3. only some field of a project activity can be updated or fields remain read only
  •  Endpoint POST api/create/activity
    
  •  Authorization: Bearer <eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6ImEiLCJlbWFpbCI6ImFAZW1haWwuY29tIiwiZXhwIjoxNjQxMDUyMjI0fQ.unXe-dxoFCEY5l2VGkeRR8ue-Ggr6YxQS2nJUA63VZ4>
    
  •  Request body:{
      "user": 1,
      "description": "developing payment endpoint",
      "project": 3
    }
    
  •  Response{
      "id": 1,
      "is_running": true,
      "duration": "0:00:00",
      "description": "developing payment endpoint",
      "start_time": "2021-12-31T17:26:46.826450Z",
      "end_time": null,
      "project": 3,
      "user": 1
      }
    

Update a project activity:

  •  Endpoint PATCH api/activity/update/1/
    
  •  Authorization: Bearer <eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6ImEiLCJlbWFpbCI6ImFAZW1haWwuY29tIiwiZXhwIjoxNjQxMDUyMjI0fQ.unXe-dxoFCEY5l2VGkeRR8ue-Ggr6YxQS2nJUA63VZ4>
    
  •  Request body:{
      "end_time": 2022-10-10,
      }
    
  •  Response{
      "id": 1,
      "is_running": false,
      "duration": "2:00:00",
      "description": "developing payment endpoint",
      "start_time": "2021-12-31T17:26:46.826450Z",
      "end_time": "2021-12-31T19:26:46.826450Z",
      "project": 3,
      "user": 1
      }
    

delete a project activity:

  •  Endpoint DELETE api/activity/delete/1/
    
  •  Authorization: Bearer <eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6ImEiLCJlbWFpbCI6ImFAZW1haWwuY29tIiwiZXhwIjoxNjQxMDUyMjI0fQ.unXe-dxoFCEY5l2VGkeRR8ue-Ggr6YxQS2nJUA63VZ4>
    
  •  Response{
      "message": "Project deleted successfully"
      }
    

Analytics endpoints: These endpoints are used to get analytics data for a project and a user. we can get the total time a user spent on a project, we can get the total time all project member spent on a project, List time spent on a project by a user:

  •  Endpoint get api/analytics/activity/duration/<int:user>/<int:project>'
    
  •  Authorization: Bearer <eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6ImEiLCJlbWFpbCI6ImFAZW1haWwuY29tIiwiZXhwIjoxNjQxMDUyMjI0fQ.unXe-dxoFCEY5l2VGkeRR8ue-Ggr6YxQS2nJUA63VZ4>
    
  •  Response{
      "total_time": "8 days, 11:08:10",
      "user": 1
      }
    

List time spent on a project by all project members:

  •  Endpoint get api/analytics/activity/duration/<int:project>'
    
  •  Authorization: Bearer <eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6ImEiLCJlbWFpbCI6ImFAZW1haWwuY29tIiwiZXhwIjoxNjQxMDUyMjI0fQ.unXe-dxoFCEY5l2VGkeRR8ue-Ggr6YxQS2nJUA63VZ4>
    
  •  Response{
      "total_time": "30 days, 11:08:10",
      "project": 1
      }
    

--> Thanks for checking out this projecr. <--

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages