File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change 2626 // first we check if we already have a run in the last 30 days for this
2727 let last_run = null ;
2828 try {
29- last_run = await fetchData ( 1 , normalized_url ) ;
29+ const modded_date = new Date ( ) ;
30+ modded_date . setDate ( modded_date . getDate ( ) - 30 ) ;
31+ const thirty_days_ago = modded_date . toISOString ( ) . split ( 'T' ) [ 0 ] ;
32+
33+ last_run = await fetchData ( 1 , normalized_url , thirty_days_ago ) ;
3034 } catch ( error ) {
3135 alert ( 'Could not check in DB for already present runs. Please try again later' ) ;
3236 console . error ( 'Error:' , error ) ;
Original file line number Diff line number Diff line change @@ -29,9 +29,12 @@ function normalizeUrl(url) {
2929
3030
3131// Function to fetch data from the API and output JSON
32- async function fetchData ( limit = 10 , usage_scenario_variables = '' ) {
33- const apiUrl = `https://api.green-coding.io/v2/runs?uri=https%3A%2F%2Fgithub.com%2Fgreen-coding-solutions%2Fgreen-metrics-tool&filename=templates%2Fwebsite%2Fusage_scenario_cached.yml&failed=false&usage_scenario_variables=${ encodeURIComponent ( usage_scenario_variables ) } &limit=${ limit } ` ;
32+ async function fetchData ( limit = 10 , usage_scenario_variables = '' , start_date = null ) {
33+ let apiUrl = `https://api.green-coding.io/v2/runs?uri=https%3A%2F%2Fgithub.com%2Fgreen-coding-solutions%2Fgreen-metrics-tool&filename=templates%2Fwebsite%2Fusage_scenario_cached.yml&failed=false&usage_scenario_variables=${ encodeURIComponent ( usage_scenario_variables ) } &limit=${ limit } ` ;
3434
35+ if ( start_date != null ) {
36+ apiUrl += `&start_date=${ start_date } `
37+ }
3538
3639 let json_response ;
3740 return ( await fetch ( apiUrl )
You can’t perform that action at this time.
0 commit comments