Skip to content

Commit b988cd8

Browse files
committed
tidyup
1 parent 19abaa2 commit b988cd8

File tree

2 files changed

+2
-46
lines changed

2 files changed

+2
-46
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ plugins {
66
}
77

88
group = 'uk.gov.hmcts.cp'
9-
version = System.getProperty('API_SPEC_VERSION') ?: '1.0.0'
9+
version = System.getProperty('API_SPEC_VERSION') ?: '1.0.7'
1010
description = 'Spring Job Scheduler'
1111

1212
def githubActor = project.findProperty("github.actor") ?: System.getenv("GITHUB_ACTOR")

task-manager-service/src/main/java/uk/gov/hmcts/cp/taskmanager/persistence/repository/JobsRepository.java

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -42,30 +42,10 @@
4242
@Repository
4343
public interface JobsRepository extends JpaRepository<Job, UUID> {
4444

45-
/**
46-
* Finds all unassigned jobs that are ready to be executed.
47-
*
48-
* <p>This query uses pessimistic write locking to prevent concurrent access.
49-
* Jobs are ordered by priority (ascending) and then by start time (ascending).
50-
*
51-
* <p>A job is considered unassigned if:
52-
* <ul>
53-
* <li>{@code workerId} is null</li>
54-
* <li>{@code assignedTaskStartTime} is less than or equal to the current time</li>
55-
* </ul>
56-
*
57-
* @param currentTime the current time for comparison with job start times
58-
* @return a list of unassigned jobs ready for execution, ordered by priority and start time
59-
*/
60-
@Lock(LockModeType.PESSIMISTIC_WRITE)
61-
@Query("SELECT j FROM Job j WHERE j.workerId IS NULL AND j.assignedTaskStartTime <= :currentTime ORDER BY j.priority ASC, j.assignedTaskStartTime ASC")
62-
List<Job> findUnassignedJobs(@Param("currentTime") ZonedDateTime currentTime);
63-
6445
/**
6546
* Finds unassigned jobs with pagination support.
6647
*
67-
* <p>This method is similar to {@link #findUnassignedJobs(ZonedDateTime)} but supports
68-
* limiting the number of results using {@link Pageable}. This is useful for batch
48+
* <p>This method limit the number of results using {@link Pageable}. This is useful for batch
6949
* processing to avoid loading too many jobs at once.
7050
*
7151
* <p>Uses pessimistic write locking to prevent concurrent access.
@@ -111,30 +91,6 @@ List<Job> assignJobsToWorkerBatch(@Param("workerId") UUID workerId,
11191
*/
11292
Optional<Job> findByJobId(UUID jobId);
11393

114-
/**
115-
* Inserts a new job into the database.
116-
*
117-
* <p>This method uses a native SQL query to insert a job with all its fields.
118-
* The job data is converted to JSONB format for PostgreSQL storage.
119-
*
120-
* @param jobId the unique job identifier
121-
* @param workerId the worker identifier (null for unassigned jobs)
122-
* @param workerLockTime the lock timestamp (null for unassigned jobs)
123-
* @param assignedTaskName the task name
124-
* @param assignedTaskStartTime the scheduled start time
125-
* @param jobData the job data as a JSON string
126-
* @param retryAttemptsRemaining the number of retry attempts remaining
127-
*/
128-
@Modifying
129-
@Query(value = "INSERT INTO jobs(job_id,worker_id,worker_lock_time,assigned_task_name,assigned_task_start_time,job_data,retry_attempts_remaining) values (:jobId,:workerId,:workerLockTime,:assignedTaskName,:assignedTaskStartTime,:jobData,:retryAttemptsRemaining)", nativeQuery = true)
130-
void insertJob(@Param("jobId") UUID jobId,
131-
@Param("workerId") UUID workerId,
132-
@Param("workerLockTime") ZonedDateTime workerLockTime,
133-
@Param("assignedTaskName") String assignedTaskName,
134-
@Param("assignedTaskStartTime") ZonedDateTime assignedTaskStartTime,
135-
@Param("jobData") String jobData,
136-
@Param("retryAttemptsRemaining") int retryAttemptsRemaining);
137-
13894
/**
13995
* Updates the job data for a specific job.
14096
*

0 commit comments

Comments
 (0)