diff --git a/api.py b/api.py index f25f5693b68727412b86d3c549710cff45302d04..bcba0b130e2020d1783abea7c631c427a5f7c58b 100755 --- a/api.py +++ b/api.py @@ -434,13 +434,9 @@ class FedStats(Resource): # /api/webdata class WebData(Resource): def get(self): - file_path = f"{e_p.ECCS_STATS_INPUT_DIR}/eccs-uwsgi-req.log" # will this name be moved to properties definer file ? + file_path = f"{e_p.ECCS_STATS_INPUT_DIR}/{e_p.ECCS_REQ_LOG}" criteria = {} criteria['date_from'] = criteria['date_to'] = e_p.DAY - # TBM to config - eccsLogRotated = True - useParsedFile = False - in_data = request.args if ('dateFrom' in in_data and isValidDate(in_data['dateFrom'])): @@ -471,15 +467,15 @@ class WebData(Resource): results = {} cur_date = criteria['date_from'] - if eccsLogRotated == True: + if e_p.ECCS_LOG_FILE_ROTATED == True: while cur_date <= criteria['date_to']: json_data = {} criteria['logfile_date'] = (datetime.strptime(cur_date, '%Y-%m-%d') + timedelta(days=1)).strftime('%Y-%m-%d') criteria['cur_date'] = cur_date tmpDate = datetime.strptime(criteria['logfile_date'], '%Y-%m-%d').strftime('%Y%m%d') - file_path = f"{e_p.ECCS_STATS_INPUT_DIR}/eccs-uwsgi-req.log-{tmpDate}" + file_path = f"{e_p.ECCS_STATS_INPUT_DIR}/{e_p.ECCS_REQ_LOG}-{tmpDate}" - if useParsedFile == True: + if e_p.USE_PARSED_DATA == True: json_file_path = f"{e_p.ECCS_DIR}/parsed/eccs-uwsgi-req-json-{tmpDate}" try: f = open(json_file_path) @@ -499,7 +495,7 @@ class WebData(Resource): json_data = parseLog(lines, criteria) - if useParsedFile == True and 'idp' not in criteria and 'reg_auth' not in criteria: + if e_p.USE_PARSED_DATA == True and 'idp' not in criteria and 'reg_auth' not in criteria: storeParsedDay(json_file_path, json_data) except FileNotFoundError as e: @@ -549,7 +545,7 @@ api.add_resource(Help, '/') # Route_1 api.add_resource(Test, '/test') # Route_2 api.add_resource(EccsResults, '/eccsresults') # Route_3 api.add_resource(FedStats, '/fedstats') # Route_4 -api.add_resource(WebData, '/webdata') # Route_4 +api.add_resource(WebData, '/usagestats') # Route_4 if __name__ == '__main__': diff --git a/eccs_properties.py b/eccs_properties.py index c596325b41785742742fa3ccfb6add7542ab607e..929e51ddc75da5a8ca67abe91b7f23a456c9a4ee 100644 --- a/eccs_properties.py +++ b/eccs_properties.py @@ -82,6 +82,12 @@ ECCS_SELENIUM_SCRIPTTIMEOUT = 60 #seconds # Statistics ECCS_STATS_INPUT_DIR = f"{ECCS_DIR}/stats" +# Requests Statistics +ECCS_LOG_FILE_ROTATED = True # Read daily rotated files +USE_PARSED_DATA = False # Read parsed data from files +ECCS_REQ_LOG_DIR = f"{ECCS_DIR}/logs" +ECCS_REQ_LOG = f"eccs-uwsgi-req.log" + # Number of processes to run in parallel ECCS_NUMPROCESSES = 30 diff --git a/web/index.php b/web/index.php index b4a4323773d169244fa83075efbbca46454c41e5..3adc9f565edb3384bcc94e32dc0f0126e746a5aa 100644 --- a/web/index.php +++ b/web/index.php @@ -57,7 +57,6 @@ $data[ 'check_result' ] = htmlspecialchars($_GET[ "check_result" ] ?? null); <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css"/> <link rel="stylesheet" type="text/css" href="eccs.css" /> - <link rel="stylesheet" type="text/css" href="statistics.css" /> <script> $( function() { $( "#datepicker" ).datepicker({ @@ -126,21 +125,7 @@ $data[ 'check_result' ] = htmlspecialchars($_GET[ "check_result" ] ?? null); var check_result = "<?php echo $data[ 'check_result' ] ?>"; </script> <script type="text/javascript" src="eccs.js"></script> - <script type="text/javascript" src="statistics.js"></script> </div> <!-- END eccs-central --> - <div id="statisticsModal" class="modal"> - <div class="modal-content"> - <span class="close">×</span> - <div class="chart-error" style="display: none;"> - <i class="fa fa-exclamation-triangle"></i> Something happened. Can't retrieve data - </div> - <div class="chart-container"> - <canvas id="statistics"></canvas> - </div> - <div class="data-container"> - </div> - </div> - </div> </div> <!-- END main_body --> </div> <!-- END wrap --> <?php include 'footer.php'; ?>