DanNduati / Jokes_borrower

Source for jokes for https://github.com/DanNduati/Jokes_api the lazy way

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JokesBorrower

JokesApi Robin Hood


The JokeBorrower as the name suggests steals cough I mean sources for jokes from other APIs to be used by my jokesAPI by storing them to my heroku postgres database instance.

Prerequisites

Setup

Clone repository

$ git clone https://github.com/DanNduati/Jokes_borrower.git

Install dependencies

If you have pipenv installed you can just run pipenv automatically creates a virtual environment for you:

$ pipenv install

Otherwise you can use the good ol' requirements.txt file:

# create virtualenvironment and activate it
$ python -m venv venv
$ source venv/bin/activate
# install dependencies
$ pip install -r requirements.txt

Usage

Run source.sh bash script

Local sqlite database

$ ./source.sh 
Borrowing initiated
started borrowing at id 0
62 jokes borrowed successfully in 1.219724178314209 seconds
started borrowing at id 100
81 jokes borrowed successfully in 2.874145269393921 seconds
started borrowing at id 200
76 jokes borrowed successfully in 1.8248345851898193 seconds
All done

Free tier hobby postgres instance

$ sudo chmod +x source.sh
$ ./source.sh
Borrowing initiated
started borrowing at id 0
62 jokes borrowed successfully in 34.831594467163086 seconds
started borrowing at id 100
81 jokes borrowed successfully in 43.83061122894287 seconds
started borrowing at id 200
76 jokes borrowed successfully in 41.592899322509766 seconds
All done

For obvious reasons writing to the local sqlite database is significantly faster that writing to the free tier postgres database instance

Built with

Credit

JokesBorrower sources it jokes from this API created by Sven Fehler

To do

  • Throttle requests to avoid exceeding the request budget for rate limited APIs
  • Add other joke sources/Apis

License

license

About

Source for jokes for https://github.com/DanNduati/Jokes_api the lazy way

License:Other


Languages

Language:Python 95.8%Language:Shell 4.2%