'Update a Python variable that is interrogating JIRA API that is subsequently presented on a template page

I have a variable that is being written from a JIRA call using the JIRA Python Library - when restarting the development server, the values in the variable are updated of course as the connection to JIRA is re-established.

I am trying to understand the best way to update the value in the variables - either on a timed basis, or on each refresh/visit to the Dashboard.

My views.py file below:

views.py

# Emergency Changes Query
jira_emergency_changes = jira.search_issues('labels = change-audit AND resolution = Unresolved').total

class Dashboard(LoginRequiredMixin,View):
    def get(self, request):
        greeting = {}
        greeting['heading'] = "Dashboard"
        greeting['pageview'] = "Tooling"
        greeting['jira_emergency_changes_render'] = jira_emergency_changes
        return render(request, 'hub/dashboard.html',greeting)

Thanks in advance :)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source