function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sashamsasham 

Batch process

how batch apex will handle this situation. we have more than 2000 paticipants in participant objects and steps and weight object
we need a job to handle everyday to find the highst step amonght participant for ranking and to find most hightest step for participant for specific period of time.
if i set chuck to 1 . how all all the particpant steps can be compared.
 
Dev_AryaDev_Arya
hi Sasham,

Dont set the chunk to 1 and let it be default. You can use a global participant variable to save the value of Higherst Step Participant and compare the result of each batch against the global participant variable.
global class highStepParticipantBatchClass implements database.batchable<sObject> {
    global participant highStepParticipant;

    global highStepParticipantBatchClass (){
         highStepParticipant= new participant();
      
    }

    global Database.QueryLocator start(Database.BatchableContext BC) {
        return Database.getQueryLocator('your query');
    }

    global void execute(Database.BatchableContext BC, sObject[] scope){
       /*
        * your process function
        */
        //Store value of participant with highest step here in highStepParticipant
         for(participant p : (participant)scope) /7casting
         {
            // simple comparision here against global highStepParticipant
         }
    }

    global void finish(Database.BatchableContext BC){}
}


And to handle this requirement everyday, I beleive your are using  System.scheduleBatch Method.

Feel free to ask if you still have doubts or mark this answer as green if this solves your problem.

Cheers, Dev


 
sashamsasham
Thank you for the answer,I also need to get the highst step for each paticipnat for specific period of time untill the job finish. and highest step for everyday for each participant 
 
Dev_AryaDev_Arya
hi Sasham,

if I understood you correctly, you find the highest step participant for each batch and save it in the global variable and use it as benchmark for the next batch scope or elements.

I didnt get what you meant by, you need to get "highest step for everyday for each participant". Is highest step a property for individial participant and u need to store for each of the sobject in scope of a batch or whole batch?

Cheers, Dev