utils

package
v0.0.0-...-91d0ab7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 15, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const BaseURL = "https://api.mfapi.in/mf/"

Define the base URL as a constant

View Source
const BatchSize = 1000
View Source
const ConcurrencyLimit = 8

Variables

View Source
var DBHost = os.Getenv("DBHost")
View Source
var DBPassword = os.Getenv("DBPassword")
View Source
var DBUser = os.Getenv("DBUser")
View Source
var FundDB = os.Getenv("FundDB")

Functions

func AtoF

func AtoF(s string) float64

func CheckIfFundExistsInDB

func CheckIfFundExistsInDB(db *sqlx.DB, schemeCode string) (bool, error)

func CreateErrorResponse

func CreateErrorResponse(w http.ResponseWriter, statusCode int, message string)

createErrorResponse creates an error response with the given status code and message.

func FetchFundData

func FetchFundData(db *sqlx.DB, mutualFundID string, start, end time.Time, getFromDB bool) (models.JsonResponse, error)

func FetchFundDataFromDB

func FetchFundDataFromDB(db *sqlx.DB, schemeCode string, startDate, endDate time.Time) (models.JsonResponse, error)

func FilterNAVDataByDate

func FilterNAVDataByDate(data []models.NAVData, start, end time.Time) []models.NAVData

FilterNAVDataByDate filters the NAV data based on the provided date range.

func GenerateJsonResponseModel

func GenerateJsonResponseModel(meta models.MetaData, data []models.NAVData, start, end time.Time) models.JsonResponse

generates a successful json response model from upstream response model

func SetupDB

func SetupDB() (*sqlx.DB, error)

func ValidateRequest

func ValidateRequest(mutualFundID, startDate, endDate string) (time.Time, time.Time, error)

func WriteDataToDB

func WriteDataToDB(wg *sync.WaitGroup, db *sqlx.DB, apiResponse models.JsonResponse, batchSize, concurrencyLimit int)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL