Open SimonLab opened 6 years ago
We can render svg with Phoenix by adding the correct Mime type and using the send_resp
function instead of using the html template and the render
function
def show(conn, _payload) do
svg = File.read!("./assets/static/images/edit_count.svg") |> IO.inspect
conn
|> put_resp_content_type("image/svg+xml")
|> send_resp(200, svg)
end
From my understanding of #14 edits count = sum of edits on comments and issue description
So we can get the issue from the Postgres with all the comments
and versions
linked to the issue, then return the number of versions - the sum of comments (the first version of the comments is not an edit but a creation)
with the meta table (the svg is not display because try to access localhost):
linked to #14 (Meta table)
Each time a new version (edit) of the issue description or a comment of the issue is saved, the meta table will display the new incremented number of edits. We can update directly the issue description of the new number via the Github API, however a nicer solution is to use a svg served by the "github-backup" server. So in a similar way to https://github.com/dwyl/hits-elixir we need to:
/edit-count/{issue_id}
which will return an svg image[![HitCount](http://hits.dwyl.io/dwyl/hits-elixir.svg)](https://github.com/dwyl/hits-elixir)
format of the hit-elixir svg: