Skip to content

Commit

Permalink
v1.0.6 - add delta parameter to GitlabApi.refresh_tags
Browse files Browse the repository at this point in the history
  • Loading branch information
batou9150 committed Jun 16, 2021
1 parent b826589 commit 029da31
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
13 changes: 12 additions & 1 deletion gitlabui/gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,18 @@ def get_projects(self, search=None, opts=None):

return projects

def refresh_tags(self):
def refresh_tags(self, delta=None):
previous = self.get_refresh_tags_time()
if previous is not None and delta is not None:
from datetime import datetime, timedelta
if type(delta) == str:
delta = int(delta)
if type(delta) == int:
delta = timedelta(seconds=delta)
current_delta = datetime.now() - datetime.fromisoformat(previous)
if current_delta < delta:
self.logger.info('skip refresh tags, current_delta = ' + str(current_delta))
return None
projects = [self.get_latest_tag(p) for p in self.get_projects()]
from datetime import datetime
self.save(projects, datetime.now().isoformat(timespec='seconds'))
Expand Down
2 changes: 1 addition & 1 deletion gitlabui/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def reset():

@app.route('/refresh_tags')
def refresh_tags():
api.refresh_tags()
api.refresh_tags(request.args.get('delta'))
return redirect(url_for('tags'))


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name='gitlabui',
version='1.0.5',
version='1.0.6',
author='batou9150',
packages=find_packages(),
include_package_data=True,
Expand Down

0 comments on commit 029da31

Please sign in to comment.