use process_set for related name not processes

This commit is contained in:
Nick Sweeting
2025-12-30 12:55:23 -08:00
parent 1b49ea9a0e
commit ba8c28a866
4 changed files with 7 additions and 8 deletions

View File

@@ -351,7 +351,7 @@ class Snapshot(ModelWithOutputDir, ModelWithConfig, ModelWithNotes, ModelWithHea
def binary_set(self):
"""Get all Binary objects used by processes related to this snapshot."""
from archivebox.machine.models import Binary
return Binary.objects.filter(process__archiveresult__snapshot_id=self.id).distinct()
return Binary.objects.filter(process_set__archiveresult__snapshot_id=self.id).distinct()
def save(self, *args, **kwargs):
is_new = self._state.adding

View File

@@ -249,9 +249,9 @@ class Migration(migrations.Migration):
('url', models.URLField(blank=True, default=None, help_text='Connection URL (CDP endpoint, sonic server, etc.)', max_length=2048, null=True)),
('status', models.CharField(choices=[('queued', 'Queued'), ('running', 'Running'), ('exited', 'Exited')], db_index=True, default='queued', max_length=16)),
('retry_at', models.DateTimeField(blank=True, db_index=True, default=django.utils.timezone.now, help_text='When to retry this process', null=True)),
('machine', models.ForeignKey(help_text='Machine where this process executed', on_delete=django.db.models.deletion.CASCADE, related_name='processes', to='machine.machine')),
('binary', models.ForeignKey(blank=True, help_text='Binary used by this process', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='processes', to='machine.binary')),
('iface', models.ForeignKey(blank=True, help_text='Network interface used by this process', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='processes', to='machine.networkinterface')),
('machine', models.ForeignKey(help_text='Machine where this process executed', on_delete=django.db.models.deletion.CASCADE, related_name='process_set', to='machine.machine')),
('binary', models.ForeignKey(blank=True, help_text='Binary used by this process', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='process_set', to='machine.binary')),
('iface', models.ForeignKey(blank=True, help_text='Network interface used by this process', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='process_set', to='machine.networkinterface')),
],
options={
'verbose_name': 'Process',

View File

@@ -510,7 +510,7 @@ class Process(ModelWithHealthStats):
Machine,
on_delete=models.CASCADE,
null=False,
related_name='processes',
related_name='process_set',
help_text='Machine where this process executed'
)
@@ -545,14 +545,14 @@ class Process(ModelWithHealthStats):
Binary,
on_delete=models.SET_NULL,
null=True, blank=True,
related_name='processes',
related_name='process_set',
help_text='Binary used by this process'
)
iface = models.ForeignKey(
NetworkInterface,
on_delete=models.SET_NULL,
null=True, blank=True,
related_name='processes',
related_name='process_set',
help_text='Network interface used by this process'
)