diff --git a/README.rst b/README.rst index ad6c591..9c167be 100644 --- a/README.rst +++ b/README.rst @@ -35,3 +35,7 @@ to generate data for. "height" is an optional parameter detailing the size of the graph (230 pixels is the default value). "title" is an optional parameter for the name of the project in the index page. + +You can also optionally specify a 'rotation' parameter. Entries older +than the value (in days) will be removed from the dataset, resulting +in a rolling view of bug activity. diff --git a/bugdaystats.py b/bugdaystats.py index 341e2b9..984fef6 100755 --- a/bugdaystats.py +++ b/bugdaystats.py @@ -41,7 +41,7 @@ def create_files(templatepath, outputpath, projects): template.stream(project=project).dump(projectfile) -def update_stats(outputpath, project_name): +def update_stats(outputpath, project_name, rotation): now = int(time.time()) records = [] @@ -55,6 +55,10 @@ def update_stats(outputpath, project_name): json_data = json.load(data_file) data_file.close() for record in json_data['records']: + if rotation: + if (now - record['date']) > (rotation * 24 * 60 * 60): + print "skip" + continue records.append(record) except IOError: pass @@ -157,6 +161,7 @@ if __name__ == '__main__': with open(configpath, 'r') as configfile: config = json.load(configfile) projects = config['projects'] + rotation = config.get('rotation') # Create files in output directory, if needed create_files(templatepath, outputpath, projects) @@ -166,4 +171,4 @@ if __name__ == '__main__': cachedir) for p in projects: - update_stats(outputpath, p['project']) + update_stats(outputpath, p['project'], rotation) diff --git a/config.js.sample b/config.js.sample index d049fb3..bfee5ec 100644 --- a/config.js.sample +++ b/config.js.sample @@ -9,5 +9,6 @@ { "project": "swift" }, { "project": "openstack-manuals", "title": "Manuals" }, { "project": "tempest" } - ] + ], + "rotation": 2 }