Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

192
Visualizações
How can I select records n-at-a-time for multiple users to edit?

I am using a Django backend with postgresql.

Let's say I have a database with a table called Employees with about 20,000 records.

I need to allow multiple users to edit and verify the Area Code field for every record in Employees.

I'd prefer to allow a user to view the records, say, 30 at a time (to reduce burnout).

How can I select 30 records at a time from Employees to send to the front end UI for editing, without letting multiple users edit the same records, or re-selecting a record that has already been verified?

I don't need comments on the content of the database (these are example table and field names).

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

One way to do this would be to add 2 more fields to your table, say for example assigned_to and verified. You can update assigned_to, which can be a foreign key to the verifying user, when you allow the user to view that Employee. This will create a record preventing the Employee from being chosen twice. assigned_to can also double as a record of who verified this Employee for future reference.

verified could be simply a Boolean field which keeps track if the Employee has already been verified and can be updated when the user confirms the verification

The actual selects can be done like this:

employees = Employee.objects.filter(assigned_to=None, verified=False)[:30]

Then

for emp in employees:
        emp.assigned_to = user
        emp.save()

Note: This can still potentially cause a race condition if 2 users make this request at exactly the same time. To avoid this, another possibility could be to partition the employee tables into groups for each user with no overlap. This would ensure that no 2 users would ever have the same employees

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda