I've been developing a portfolio website and part of the data for the projects (like the project summaries and the latest update times) are obtained through PyGithub using the project title.
When I call for an update to my database it compares the time (which is stored as a string but converted to a datetime object for comparison) stored to the time that I get from the Repository()._updated_at.value. The following is the function I use to get the project information through PyGithub.
def access_project(title: str) -> dict:
auth = Auth.Token(os.environ.get("GITHUB_TOKEN"))
g = Github(auth=auth)
repo = g.get_user().get_repo(title)
my_project = {
'title': title,
'description': repo.description,
'last_updated': repo._updated_at.value,
}
print(repo._updated_at.value)
g.close()
return my_project
The issue I'm having is that the value from repo._updated_at.value is the exact same value that I have stored in my database, despite the fact that I just updated one of my projects just around half an hour ago after a couple months of having left it untouched. I don't really understand why this is, my best guess would be that maybe the update time of the repository itself is different from that of just the files that I updated.
Either way, I'd like to avoid having to compare EVERY files' latest update time and picking out the latest if possible. Any suggestions?
Found it! What I wanted was the Repository().pushed_at value, which gives me the time of the last push to my repository. So for my code I'd just change
repo._updated_at.value
torepo.pushed_at