Code Explainers

Code explainers tagged #batch-processing

ruby
namespace :active_storage do
  desc "Purge blobs that have been unattached for more than 48 hours"
  task purge_stale: :environment do
    cutoff = 48.hours.ago

A Rake task to purge stale Active Storage blobs in Rails

rake active-storage batch-processing
Intermediate 8 steps
java
@Component
@RequiredArgsConstructor
@Slf4j
public class FailedJobReprocessor {

Retrying failed jobs on a Spring schedule

scheduling retry exponential-backoff
Intermediate 10 steps
rust
use axum::{extract::State, http::StatusCode, response::IntoResponse, Json};
use serde::{Deserialize, Serialize};
use std::sync::Arc;
 

Batch inserts with per-item status in Axum

batch-processing error-handling serde
Intermediate 8 steps
java
@RestController
@RequestMapping("/api/products")
@RequiredArgsConstructor
public class ProductBatchController {

Batch JSON Merge Patch in Spring

json-merge-patch rest-api partial-update
Intermediate 8 steps
python
from decimal import Decimal, ROUND_HALF_UP
 
from django.db import transaction
from django.db.models import F

Batch price updates safely in Django

decimal-precision batch-processing transactions
Advanced 8 steps
java
@Configuration
@EnableBatchProcessing
public class CustomerImportJobConfig {
 

How a chunk-based CSV import job works in Spring

batch-processing etl csv-parsing
Intermediate 9 steps
php
<?php
 
namespace App\Console\Commands;
 

Streaming CSV imports in Laravel

lazy-evaluation generators batch-processing
Intermediate 7 steps
ruby
class InactiveAccountCleanup
  BATCH_SIZE = 500
  INACTIVITY_THRESHOLD = 18.months
 

Batch-processing dormant users in Rails

batch-processing activerecord service-object
Intermediate 9 steps
python
from datetime import timedelta
 
from django.contrib.sessions.models import Session
from django.core.management.base import BaseCommand

A batched session-cleanup command in Django

management-command batch-processing database-cleanup
Intermediate 7 steps
java
@Repository
public interface OrderRepository extends JpaRepository<Order, Long> {
 
    @QueryHints(@QueryHint(name = HINT_FETCH_SIZE, value = "1000"))

Streaming large result sets in Spring Data JPA

streaming jpa memory-management
Advanced 6 steps