Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

FIX: elekto version in UI #102

wants to merge 3 commits into from

Conversation

Diwaz
Copy link

@Diwaz Diwaz commented Nov 25, 2024

fixes #96
now the elekto version is displayed in the visible place

@jberkus
Copy link
Member

jberkus commented Nov 28, 2024

Nice, thanks, lemme test this out.

@@ -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')
Copy link
Member

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?

Copy link
Author

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

Copy link
Author

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
@Diwaz
Copy link
Author

Diwaz commented Nov 28, 2024

@jberkus i made new approach to fetch the current version of the app use

Copy link

@palnabarun palnabarun left a 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();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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();

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)

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.

Copy link
Author

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

@jberkus
Copy link
Member

jberkus commented Dec 18, 2024

So, this feature has a prerequisite, which is to do proper pip packaging so that an accurate version number is available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Display Elekto version in UI
3 participants