Home

Awesome

<h1 align="left">Fill Bi Database</h1>

<a href="https://www.plasticorigins.eu/"><img width="80px" src="https://github.com/surfriderfoundationeurope/The-Plastic-Origins-Project/blob/master/assets/PlasticOrigins_logo.png" width="5%" height="5%" align="left" hspace="0" vspace="0"></a>

<p align="justify">Proudly Powered by <a href="https://surfrider.eu/">SURFRIDER Foundation Europe</a>, this open-source initiative is a part of the <a href="https://www.plasticorigins.eu/">PLASTIC ORIGINS</a> project - a citizen science project that uses AI to map plastic pollution in European rivers and share its data publicly. Browse the <a href="https://github.com/surfriderfoundationeurope/The-Plastic-Origins-Project">project repository</a> to know more about its initiatives and how you can get involved. Please consider starring :star: the project's repositories to show your interest and support. We rely on YOU for making this project a success and thank you in advance for your contributions.</p>
<!--- OPTIONAL: You can add badges and shields to reflect the current status of the project, the licence it uses and if any dependencies it uses are up-to-date. Plus they look pretty cool! You can find a list of badges or design your own at https://shields.io/ ---> <h2 align="left">**2023 WARNING : THIS REPO IS NO LONGER TO USE. USE THE 'ETL' REPO THAT HOSTS AIRFLOW CONTENT**</h2>

Welcome to 'Fill Bi Database', code for the recurring job that fills Bi database schema that allows to launch a series of SQL scripts. These scripts do calculations on the campaigns and store the results in a BI database. The program ensures that the scripts run smoothly in an orderly fashion, when one of the scripts fails to update information in a log table for manual resolution.

This function runs every day at 02:00

Principles

Several ordered SQL request will be executed on the server in order to compute BI data.

image-20200505161802892

In red, the steps we think will take time. In grey, the optionnal step we will do in a second time.

StepNameGoalTables involvedParameters
000Test geometries are in countries we have river referential and test SRID for each campaign
00init_get_new_campaigns_id.sqlReturns a list of id_campaign to processCampaign.campaignNone
00_insert_main_tables.sqlData migration of new campaign from campaign.* to bi_temp.*bi_temp.pipelines Campaign.* bi_temp.*campaignID pipelineID
11_update_bi_temp_trajectory_point.sqlcomputes the following fields for each trajectory point : distance, time_diff, speed, lat, lonbi_temp.trajectory_pointcampaignID
22_update_bi_temp_campaign.sqlComputes the following fields for each campaign start_date end_date duration start_point end_point distance_start_endbi_temp.campaigncampaignID pipelineID
33_test_campaign.sqlunit test data campaign: raise exception if the campaign is not contained in one country of the referential ... more to comeReferential.country bi_temp.campaigncampaignID
44_insert_bi_temp_trajectory_point_river.sqlAssociates each trajectory point to a river section Computes the following field : trajectory point projection on river section distance between observed and estimated geopointbi_temp.trajectory_point referential.rivercampaignID pipelineID
55_insert_bi_temp_campaign_river.sqlassociates each campaign to a river section computes the following fields: campaign geom on referential river campaign distance on referential riverbi_temp.campaigncampaignID pipelineID
66_update_bi_temp_trash.sqlcomputes the following fields : Municipality_code municipality_name State_code State_name Country_code Country_namereferential.country bi_temp.trashcampaignID pipelineID
77_insert_bi_temp_trash_river.sqlassociates each trash to a river section computes the following field distance between river section and observed trash projection of the trash on the river sectionbi_temp.trash Referential.rivercampaignID piplineID
88_get_old_campaign_id.sqlThis script returns oldCampaignIDbi.campaign_river bi_temp.campaign_river bi_temp.pipelinescampaignID
99_get_river_name.sqlreturns river_name for a campaignIDBi_temp.campaign_rivercampaignID
1010_import_bi_table_to_bi_temp.sqldata migration from bi.* to bi_temp.*bi_temp.campaign_river Bi_temp.trash_riveroldCampaignID
1111_update_bi_river.sqlupdate the following fields : distance monitored the_geom_monitored count_trash Trash_per_kmbi_temp.river bi_temp.campaign_river bi_temp.trash_rivercampaignID pipelineID
1212_import_bi_temp_table_to_bi.sqldata miragration from bi_temp.* to bi.*insert into: bi.campaign from bi_temp.campaign bi.campaign_river from bi_temp.campaign_river bi.trajectory_point from bi_temp.trajectory_point bi.trajectory_point_river from bi_temp.bi.trajectory_point_river Bi.trash from bi_temp.trash update: bi.river from bi_temp.rivercampaignID pipelineID
1313_test_campaign_processing.sqlreturns True if pipeline has been successfully computes for a campaignID: campaign_has_been_computed=True, river_has_been_computed=Truebi_temp.pipelinescampaignID
1414_delete_from_bi_temp_table.sqlDelete data from bi_temp schema for a pipelineIDbi_temp.trash bi_temp.campaign bi_temp.trajectory_point bi_temp.campaign_river bi_temp.trash_river bi_temp.trajectory_point_riverpipelineID

Architectural Decision

Getting Started

Prerequisites

Before you begin, ensure you have met the following requirements:

Technical stack

Installation

To install Surfrider-Recuring Jobs, follow these steps:

Usage

To use Surfrider-RecurringJobs, follow these steps:

<!--- If needed add here any Extra Sections (must have their own titles).Specifically, the Security section should be here if it wasn't important enough to be placed above.-->

API references

<!--- If an external API file is work in progress and/or you are planning to host API specification in the Swagger documentation, you can use the text below as exaple: add, duplicate or remove as required *SOON: To see API specification used by this repository browse to the Swagger documentation (currently not available).* -->

Build and Test

'Fill Bi Database' is easy to test w/ VSCode and a local installation of Node.js.

In order to test and run 'Fill Bi Database' locally, you need to install the following VSCode extensions:

After extensions installed, please check your local environement can run azure functions : open your Terminal and run "func". Is everything goes well, the installed version is displayed.

To test 'Fill Bi Database', go to Debug section, then click on Run.

To start the function immediately without having to wait util 02 am, you can replace the line below in the class PowerBIFillDatabase.cs

public static async Task Run([TimerTrigger("0 0 2 * * *")] TimerInfo myTimer, ILogger logger)// runs everyd ay at 02:00b

by following:

public static async Task Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] Microsoft.AspNetCore.Http.HttpRequest req, ILogger logger)

Contributing

It's great to have you here! We welcome any help and thank you in advance for your contributions.

Maintainers

If you experience any problems, please don't hesitate to ping:

<!--- Need to check the full list of Maintainers and their GIThub contacts -->

Special thanks to all our Contributors.

License

We’re using the MIT License. For more details, check LICENSE file.

Additional information

Good to mention

Useful links