Skip to content

Commit

Permalink
Correctly poll for updates on workflow first-run
Browse files Browse the repository at this point in the history
  • Loading branch information
lukewaite committed Jan 6, 2018
1 parent 1a79746 commit ea3e491
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/gitlab.py
Expand Up @@ -4,7 +4,7 @@
from workflow import Workflow3, ICON_WEB, ICON_WARNING, ICON_INFO, web, PasswordNotFound
from workflow.background import run_in_background, is_running

__version__ = '1.2.1'
__version__ = '1.2.2'

log = None

Expand Down Expand Up @@ -72,22 +72,24 @@ def main(wf):
autocomplete='workflow:update',
icon=ICON_INFO)

# Notify the user if the cache is being updated
if is_running('update') and not projects:
wf.rerun = 0.5
wf.add_item('Updating project list via GitLab...',
subtitle=u'This can take some time if you have a large number of projects.',
valid=False,
icon=ICON_INFO)

# Start update script if cached data is too old (or doesn't exist)
if not wf.cached_data_fresh('projects', max_age=3600):
if not wf.cached_data_fresh('projects', max_age=3600) and not is_running('update'):
cmd = ['/usr/bin/python', wf.workflowfile('update.py')]
run_in_background('update', cmd)
wf.rerun = 0.5

# If script was passed a query, use it to filter projects
if query and projects:
projects = wf.filter(query, projects, key=search_for_project, min_score=20)

# Notify the user if the cache is being updated
if is_running('update') and not projects:
wf.rerun = 1
wf.add_item('Updating project list via GitLab...',
valid=False,
icon=ICON_INFO)

if not projects: # we have no data to show, so show a warning and stop
wf.add_item('No projects found', icon=ICON_WARNING)
wf.send_feedback()
Expand Down

0 comments on commit ea3e491

Please sign in to comment.