Précisions sur les événements créés "manuellement"

This commit is contained in:
Jean-Marie Favreau 2024-11-11 19:17:40 +01:00
parent 3cd6dd8682
commit d4a12cadcd
2 changed files with 6 additions and 2 deletions

View File

@ -1436,13 +1436,15 @@ class Event(models.Model):
recurrentimport = RecurrentImport.objects.filter(source=OuterRef("import_sources__0")).order_by().annotate(count=Func(F('id'), function='Count')).values('count') recurrentimport = RecurrentImport.objects.filter(source=OuterRef("import_sources__0")).order_by().annotate(count=Func(F('id'), function='Count')).values('count')
nb_manual_creation = Event.objects.filter(created_date__gte=start, created_date__lt=end, imported_date__isnull=True).count() nb_manual_creation = Event.objects.filter(created_date__gte=start, created_date__lt=end, imported_date__isnull=True, uuids__len=0).count()
nb_local_copies = Event.objects.filter(created_date__gte=start, created_date__lt=end, imported_date__isnull=True, uuids__len__gt=0).count()
imported = Event.objects.filter(created_date__gte=start, created_date__lt=end, imported_date__isnull=False, uuids__len__gt=0).annotate(nb_rimport=Subquery(recurrentimport)) imported = Event.objects.filter(created_date__gte=start, created_date__lt=end, imported_date__isnull=False, uuids__len__gt=0).annotate(nb_rimport=Subquery(recurrentimport))
nb_manual_import = imported.filter(Q(import_sources__len=0)|Q(nb_rimport=0)).count() nb_manual_import = imported.filter(Q(import_sources__len=0)|Q(nb_rimport=0)).count()
nb_first_import = imported.filter(nb_rimport__gt=0).count() nb_first_import = imported.filter(nb_rimport__gt=0).count()
return {"when": (start, start + timedelta(days=when[1] - 1)), "nb_manual_creation": nb_manual_creation, "nb_manual_import": nb_manual_import, "nb_first_import": nb_first_import} return {"when": (start, start + timedelta(days=when[1] - 1)), "nb_manual_creation": nb_manual_creation, "nb_manual_import": nb_manual_import, "nb_first_import": nb_first_import, "nb_local_copies": nb_local_copies}
def get_count_modifications(when_list): def get_count_modifications(when_list):
return [Event.get_count_modification(w) for w in when_list] return [Event.get_count_modification(w) for w in when_list]

View File

@ -8,6 +8,7 @@
<th>Créations manuelles</th> <th>Créations manuelles</th>
<th>Imports manuels</th> <th>Imports manuels</th>
<th>Imports automatiques</th> <th>Imports automatiques</th>
<th>Créations de copies locales</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -17,6 +18,7 @@
<td>{{ m.nb_manual_creation }}</td> <td>{{ m.nb_manual_creation }}</td>
<td>{{ m.nb_manual_import }}</td> <td>{{ m.nb_manual_import }}</td>
<td>{{ m.nb_first_import }}</td> <td>{{ m.nb_first_import }}</td>
<td>{{ m.nb_local_copies }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>