Commit e47709e0 authored by Laurent Peuch's avatar Laurent Peuch
Browse files

feat(deprecated): optimise generation speed

parent 630f516af773
Pipeline #21360 passed with stages
in 4 minutes and 5 seconds
...@@ -131,7 +131,13 @@ def render_traceback(traceback_id, traceback, warning_name, project_id): ...@@ -131,7 +131,13 @@ def render_traceback(traceback_id, traceback, warning_name, project_id):
open(f"public/traceback/{traceback_id}.html", "w").write(rendered_template) open(f"public/traceback/{traceback_id}.html", "w").write(rendered_template)
ALREADY_GENERATED_FILES = set()
def render_source_code_file(file_content, path, file_name, lineno): def render_source_code_file(file_content, path, file_name, lineno):
if path in ALREADY_GENERATED_FILES:
return
os.makedirs("public/file", exist_ok=True) os.makedirs("public/file", exist_ok=True)
rendered_template = jinja2.Template(open("template/file.html", rendered_template = jinja2.Template(open("template/file.html",
...@@ -142,6 +148,7 @@ def render_source_code_file(file_content, path, file_name, lineno): ...@@ -142,6 +148,7 @@ def render_source_code_file(file_content, path, file_name, lineno):
lineno=lineno, lineno=lineno,
pygment_css=HtmlFormatter().get_style_defs()) pygment_css=HtmlFormatter().get_style_defs())
open(f"public/file/{path}.html", "w").write(rendered_template) open(f"public/file/{path}.html", "w").write(rendered_template)
ALREADY_GENERATED_FILES.add(path)
download_files_to_url_cache() download_files_to_url_cache()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment