Skip to content

Latest commit

 

History

History
139 lines (98 loc) · 2.98 KB

README.md

File metadata and controls

139 lines (98 loc) · 2.98 KB

Call-Analytics-SpringBoot-API

Simple API that records call logs and generate a analytic by given date

Setup

  1. Clone the application

    git clone https://github.com/ShirishSaxena/Call-Analytics-SpringBoot-API.git
    cd Call-Analytics-SpringBoot-API
  2. Create MySQL database

    create database analytics
  3. Change MySQL username and password as per your MySQL installation

    • open src/main/resources/application.properties file.

    • change spring.datasource.username and spring.datasource.password properties as per your mysql installation

  4. Run the app

    You can run the spring boot app by typing the following command -

    mvn spring-boot:run

    The server will start on port 8080.

    You can also package the application in the form of a jar file and then run it like so -

    mvn package
    java -jar target/analytics-0.0.1-SNAPSHOT.jar
  5. Generate Logs (Optional) pip install pyperclip

    Run Generate Random POST Requests.py Change these variables as needed

    # Random number generator for Adjetter Media assignment (Java)
    numToGenerate = 2
    mobileNoStart = 8
    
    # seconds
    MinimumOffsetBetween2Date = 60
    MaximumOffsetBetween2Date = 240
    
    # Timestamp range
    TimeFormat = '%d-%m-%Y %H:%M:%S'
    
    randomDate_start = "01-01-2021 00:00:00"
    randomDate_end = "31-12-2021 23:00:00"
    

    It'll generate List of POST req and copy to your clipboard. Finally, paste it on POSTMAN...

Updates

* 20-Dec-2021
	Enabled Caching for getDate.
* 18-Dec-2021
	Optimized batch add function (Increase in POST request from avg 30 req/second to 400 req/second) ~Mileage may vary (tested with remote sql).
	Two hibernate sequence for two tables instead of one.
	Reformatted & cleaned some code.

API supports GET and POST requests

GET requests

  • Get Analytics

    Date format should be in : yyyy-MM-dd

     localhost:8080/api/getDate/2021-12-13
    

    Result with over 10k records

  • Get List of all logs saved in database

      localhost:8080/api/getAll/
    

    Result with over 10k records

POST requests

  • Save single log

     localhost:8080/api/
    
     {
     	"number": 8610483610,
     	"startTime": "06-11-2021 11:27:52",
     	"endTime": "06-11-2021 11:29:53"
     }
    

    POST req single

  • Save multiple log

     localhost:8080/api/saveCalls/
    
     [
     	{
     		"number": 8008216218,
     		"startTime": "05-05-2021 02:26:17",
     		"endTime": "05-05-2021 02:30:14"
     	},
     	{
     		"number": 8200845038,
     		"startTime": "30-12-2021 13:21:53",
     		"endTime": "30-12-2021 13:25:20"
     	}
     ]
     
    

    POST req multi

To-do

Delete LogByNumber
Delete LogByNumberAndStartTimeAndEndTime
Update LogByNumber/ID
Create Java API to get weekNo and DayName from Date