Skip to content

Commit

Permalink
add git workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
giovannimin committed Jun 27, 2023
1 parent aee264f commit c022de1
Show file tree
Hide file tree
Showing 7 changed files with 1,528 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/update_data.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: auto update-data

on:
push:
branches: master
schedule:
- cron: '*/15 * * * *'

jobs:
update-table:
runs-on: ubuntu-latest
steps:
- name: Checkout latest code version from git
uses: actions/checkout@master
with:
path: ./

- name: Set up Python environement
uses: actions/setup-python@master
with:
python-version: 3.9

- name: Install dependencies
run: pip install -r requirements.txt

- name: Fetch data
run: ./shell_script/update_data.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}




2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

sources/update_data.csv
5 changes: 5 additions & 0 deletions shell_script/update_data.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

set -e

python3 ./sources/fetch_data.py
Binary file modified sources/__pycache__/data_pipeline.cpython-39.pyc
Binary file not shown.
6 changes: 6 additions & 0 deletions sources/data_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ def extract_integer(dictionary_list, key):
stations['availableMechanicalBikesRate'] = stations['availableMechanicalBikesRate'].fillna(0)
stations['availableElectricRate'] = stations['availableElectricRate'].fillna(0)

# Arrondir les KPIs au dixième
stations['availableBikesRate'] = stations['availableBikesRate'].round(2)
stations['availableDocksRate'] = stations['availableDocksRate'].round(2)
stations['availableMechanicalBikesRate'] = stations['availableMechanicalBikesRate'].round(2)
stations['availableElectricRate'] = stations['availableElectricRate'].round(2)

return stations


Expand Down
17 changes: 17 additions & 0 deletions sources/fetch_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
"""
Created on 27/06/2023 19:13
@author: GiovanniMINGHELLI
"""
import os

from sources.data_pipeline import get_availablity_bikes


def fetch():
velib_data = get_availablity_bikes()
velib_data.to_csv('update_data.csv', header=False, mode='a', date_format='%Y-%m-%d %H:%M:%S')


if __name__ == '__main__':
fetch()
1,465 changes: 1,465 additions & 0 deletions sources/update_data.csv

Large diffs are not rendered by default.

0 comments on commit c022de1

Please sign in to comment.