mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Added an informational log message for consumer start
This commit is contained in:
		| @@ -1,10 +1,12 @@ | ||||
| import datetime | ||||
| import logging | ||||
| import os | ||||
| import time | ||||
|  | ||||
| from django.conf import settings | ||||
| from django.core.management.base import BaseCommand, CommandError | ||||
|  | ||||
| from ...models import Log | ||||
| from ...consumer import Consumer, ConsumerError | ||||
| from ...mail import MailFetcher, MailFetcherError | ||||
|  | ||||
| @@ -44,6 +46,13 @@ class Command(BaseCommand): | ||||
|         except FileExistsError: | ||||
|             pass | ||||
|  | ||||
|         logging.getLogger(__name__).info( | ||||
|             "Starting document consumer at {}".format( | ||||
|                 settings.CONSUMPTION_DIR | ||||
|             ), | ||||
|             extra={"component": Log.COMPONENT_CONSUMER} | ||||
|         ) | ||||
|  | ||||
|         try: | ||||
|             while True: | ||||
|                 self.loop() | ||||
|   | ||||
| @@ -4,7 +4,7 @@ from django.db import models | ||||
| from django.db.models.aggregates import Max | ||||
|  | ||||
|  | ||||
| class Concat(models.Aggregate): | ||||
| class GroupConcat(models.Aggregate): | ||||
|     """ | ||||
|     Theoretically, this should work in Sqlite, PostgreSQL, and MySQL, but I've | ||||
|     only ever tested it in Sqlite. | ||||
| @@ -60,7 +60,7 @@ class LogQuerySet(models.query.QuerySet): | ||||
|     def by_group(self): | ||||
|         return self.values("group").annotate( | ||||
|             time=Max("modified"), | ||||
|             messages=Concat("message"), | ||||
|             messages=GroupConcat("message"), | ||||
|         ).order_by("-time") | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| import logging | ||||
| import os | ||||
| import re | ||||
| import uuid | ||||
|  | ||||
| from django.conf import settings | ||||
| from django.core.urlresolvers import reverse | ||||
| @@ -236,3 +237,16 @@ class Log(models.Model): | ||||
|  | ||||
|     def __str__(self): | ||||
|         return self.message | ||||
|  | ||||
|     def save(self, *args, **kwargs): | ||||
|         """ | ||||
|         To allow for the case where we don't want to group the message, we | ||||
|         shouldn't force the caller to specify a one-time group value.  However, | ||||
|         allowing group=None means that the manager can't differentiate the | ||||
|         different un-grouped messages, so instead we set a random one here. | ||||
|         """ | ||||
|  | ||||
|         if not self.group: | ||||
|             self.group = uuid.uuid4() | ||||
|  | ||||
|         models.Model.save(self, *args, **kwargs) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Daniel Quinn
					Daniel Quinn