File tree Expand file tree Collapse file tree 3 files changed +18
-6
lines changed Expand file tree Collapse file tree 3 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -131,14 +131,14 @@ public boolean cacheExpired(Workflow workflow) {
131
131
logger .debug ("Current: " + workflow .getLastCommit () + ", HEAD: " + currentHead );
132
132
133
133
// Reset date in database if there are still no changes
134
- boolean changes = workflow .getLastCommit ().equals (currentHead );
135
- if (changes ) {
134
+ boolean expired = ! workflow .getLastCommit ().equals (currentHead );
135
+ if (! expired ) {
136
136
workflow .setRetrievedOn (new Date ());
137
137
workflowRepository .save (workflow );
138
138
}
139
139
140
140
// Return whether the cache has expired
141
- return ! changes ;
141
+ return expired ;
142
142
} else {
143
143
// Cache expiry time has not elapsed yet
144
144
return false ;
Original file line number Diff line number Diff line change @@ -159,8 +159,20 @@ public ModelAndView getWorkflowByGithubDetails(@PathVariable("owner") String own
159
159
if (workflowModel != null ) {
160
160
boolean cacheExpired = workflowService .cacheExpired (workflowModel );
161
161
if (cacheExpired ) {
162
- workflowService .removeWorkflow (workflowModel );
163
- workflowModel = null ;
162
+ // Update by trying to add a new workflow
163
+ Workflow newWorkflow = workflowService .newWorkflowFromGithub (workflowModel .getRetrievedFrom ());
164
+
165
+ // Only replace workflow if it could be successfully parsed
166
+ if (newWorkflow == null ) {
167
+ logger .error ("Could not parse updated workflow " + workflowModel .id );
168
+ } else {
169
+ // Delete the existing workflow
170
+ workflowService .removeWorkflow (workflowModel );
171
+
172
+ // Save new workflow
173
+ workflowRepository .save (newWorkflow );
174
+ workflowModel = newWorkflow ;
175
+ }
164
176
}
165
177
}
166
178
Original file line number Diff line number Diff line change @@ -98,7 +98,7 @@ <h4 class="modal-title" id="dotGraphLabel">Workflow DOT Graph</h4>
98
98
99
99
< div class ="container ">
100
100
< div class ="row ">
101
- < div class ="col-md-12 " role ="main " id ="main " th:with ="workflowURL=@{'github.com/' + ${workflow.retrievedFrom.owner} + '/' + ${workflow.retrievedFrom.repoName} + '/tree/' + ${workflow.retrievedFrom. lastCommit} + '/' + ${workflow.retrievedFrom.path}} ">
101
+ < div class ="col-md-12 " role ="main " id ="main " th:with ="workflowURL=@{'github.com/' + ${workflow.retrievedFrom.owner} + '/' + ${workflow.retrievedFrom.repoName} + '/tree/' + ${workflow.lastCommit} + '/' + ${workflow.retrievedFrom.path}} ">
102
102
< h2 > Workflow: < span th:text ="${workflow.label} "> Workflow Name</ span > </ h2 >
103
103
< p >
104
104
< a th:href ="@{'https://' + ${workflowURL}} " href ="# " rel ="noopener " target ="_blank ">
You can’t perform that action at this time.
0 commit comments