-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FIX: elekto version in UI #102
base: main
Are you sure you want to change the base?
Conversation
Nice, thanks, lemme test this out. |
elekto/templates/layouts/app.html
Outdated
@@ -49,6 +49,21 @@ | |||
document.getElementById('message').hidden = true | |||
}, 10000); | |||
} | |||
document.addEventListener('DOMContentLoaded', function () { | |||
// Fetch the version from the Flask API | |||
fetch('https://api.github.com/repos/elekto-io/elekto/releases/latest') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I reading this right? It seems to be pulling the latest version number from GitHub, rather than the version the user is actually running. Or did I miss something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my bad , i haven't thought through this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should i run the bash script ' git describe --tags from the flask ' to get the current version?
now the current app version is fetched instead of latest version
@jberkus i made new approach to fetch the current version of the app use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The canonical way to get version of a package is through importlib
. Not sure how Elekto is deployed but the version needs to be embedded statically rather than computing on every page load.
Also, the PR has unrelated changes. What are those for?
@@ -50,8 +65,8 @@ def elections(): | |||
meta.Election.all() if status is None else meta.Election.where("status", status) | |||
) | |||
res.sort(key=lambda e: e["start_datetime"], reverse=True) | |||
|
|||
return F.render_template("views/elections/index.html", elections=res, status=status) | |||
version = get_version(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
version = get_version(); | |
version = get_version() |
@@ -50,8 +65,8 @@ def elections(): | |||
meta.Election.all() if status is None else meta.Election.where("status", status) | |||
) | |||
res.sort(key=lambda e: e["start_datetime"], reverse=True) | |||
|
|||
return F.render_template("views/elections/index.html", elections=res, status=status) | |||
version = get_version(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error is not caught
def get_version(): | ||
"""Retrieve the app version using `git describe --tags`.""" | ||
try: | ||
process = subprocess.Popen(['git', 'describe', '--tags'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will run the subprocess everytime rendering happens. This is not good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you so much for the feedback ,iam new to open source contributions i should implement new static way to fetch the app version
So, this feature has a prerequisite, which is to do proper pip packaging so that an accurate version number is available. |
fixes #96
now the elekto version is displayed in the visible place