Add scrobble list to import detail view

This commit is contained in:
2023-05-24 19:31:16 -04:00
parent 7758c56d10
commit dbbb2b43a8
2 changed files with 31 additions and 1 deletions

View File

@ -99,6 +99,14 @@ class BaseFileImportMixin(TimeStampedModel):
]
)
def scrobbles(self) -> models.QuerySet:
scrobble_ids = []
for line in self.process_log.split("\n"):
sid = line.split("\t")[0]
if sid:
scrobble_ids.append(sid)
return Scrobble.objects.filter(id__in=scrobble_ids)
def mark_started(self):
self.processing_started = timezone.now()
self.save(update_fields=["processing_started"])

View File

@ -8,6 +8,28 @@
<p>Import started: {{object.processing_started}}</p>
<p>Import finished: {{object.processed_finished}}</p>
<p>Imported {{object.process_count}} scrobbles</p>
<h3>Scrobbles</h3>
<div class="table-responsive">
<table class="table table-striped table-sm">
<thead>
<tr>
<th scope="col">Date</th>
<th scope="col">Media Type</th>
<th scope="col">Media</th>
</tr>
</thead>
<tbody>
{% for scrobble in object.scrobbles %}
<tr>
<td><a href="{{scrobble.get_absolute_url}}">{{scrobble.timestamp}}</a></td>
<td>{{scrobble.media_type}}</td>
<td>{{scrobble.media_obj}}
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% endblock %}
{% endblock %}