Compare commits

..

1 Commits

Author SHA1 Message Date
shamoon
bf468ac64f Documentation: fix cache invalidation command in documentation (#10665) 2025-08-23 04:00:02 -07:00
15 changed files with 8 additions and 99 deletions

View File

@@ -471,7 +471,7 @@ Failing to invalidate the cache after such modifications can lead to stale data
Use the following management command to clear the cache:
```
invalidate_cachalot
python3 manage.py invalidate_cachalot
```
!!! info

View File

@@ -113,7 +113,7 @@
[disablePopover]="!slimSidebarEnabled" placement="end" container="body" triggers="mouseenter:mouseleave"
popoverClass="popover-slim">
<i-bs class="me-1" name="funnel"></i-bs>
<span>&nbsp;<div class="d-inline-flex view-name"><span class="overflow-hidden" [class.text-truncate]="!slimSidebarEnabled">{{view.name}}</span></div>
<span>&nbsp;<div class="d-inline-flex view-name"><span [class.text-truncate]="!slimSidebarEnabled">{{view.name}}</span></div>
@if (showSidebarCounts && !slimSidebarEnabled) {
<span class="badge bg-info text-dark ms-2 d-inline">{{ savedViewService.getDocumentCount(view) }}</span>
}
@@ -147,7 +147,7 @@
[disablePopover]="!slimSidebarEnabled" placement="end" container="body" triggers="mouseenter:mouseleave"
popoverClass="popover-slim">
<i-bs class="me-1" name="file-text"></i-bs><span>&nbsp;{{d.title | documentTitle}}</span>
<span class="close flex-column justify-content-center" (click)="closeDocument(d); $event.preventDefault()">
<span class="close" (click)="closeDocument(d); $event.preventDefault()">
<i-bs name="x"></i-bs>
</span>
</a>

View File

@@ -191,7 +191,7 @@ main {
list-style-type: none;
&:hover .close {
display: flex;
display: block;
}
.close {

View File

@@ -1,9 +1,4 @@
<pngx-page-header [(title)]="title">
@if (document?.in_process) {
<span class="badge bg-danger text-dark ms-2 d-flex align-items-center">
<div class="spinner-border spinner-border-sm me-1" role="status"></div><span i18n>Processing...</span>
</span>
}
@if (archiveContentRenderType === ContentRenderType.PDF && !useNativePdfViewer) {
@if (previewNumPages) {
<div class="input-group input-group-sm d-none d-md-flex">
@@ -55,7 +50,7 @@
<div class="d-none d-sm-inline">&nbsp;<ng-container i18n>Actions</ng-container></div>
</button>
<div ngbDropdownMenu aria-labelledby="actionsDropdown" class="shadow">
<button ngbDropdownItem (click)="reprocess()" [disabled]="!userCanEdit || !userIsOwner || document?.in_process">
<button ngbDropdownItem (click)="reprocess()" [disabled]="!userCanEdit || !userIsOwner">
<i-bs width="1em" height="1em" name="arrow-counterclockwise"></i-bs>&nbsp;<span i18n>Reprocess</span>
</button>
@@ -63,7 +58,7 @@
<i-bs width="1em" height="1em" name="diagram-3"></i-bs>&nbsp;<span i18n>More like this</span>
</button>
<button ngbDropdownItem (click)="editPdf()" [disabled]="!userIsOwner || !userCanEdit || originalContentRenderType !== ContentRenderType.PDF || document?.in_process">
<button ngbDropdownItem (click)="editPdf()" [disabled]="!userIsOwner || !userCanEdit || originalContentRenderType !== ContentRenderType.PDF">
<i-bs name="pencil"></i-bs>&nbsp;<ng-container i18n>PDF Editor</ng-container>
</button>
</div>
@@ -95,6 +90,7 @@
}
</div>
</div>
</pngx-page-header>
<div class="row">

View File

@@ -452,18 +452,6 @@ describe('DocumentDetailComponent', () => {
expect(navigateSpy).toHaveBeenCalledWith(['404'], { replaceUrl: true })
})
it('should navigate to 404 if error on load', () => {
jest
.spyOn(activatedRoute, 'paramMap', 'get')
.mockReturnValue(of(convertToParamMap({ id: 3, section: 'details' })))
const navigateSpy = jest.spyOn(router, 'navigate')
jest
.spyOn(documentService, 'get')
.mockReturnValue(throwError(() => new Error('not found')))
fixture.detectChanges()
expect(navigateSpy).toHaveBeenCalledWith(['404'], { replaceUrl: true })
})
it('should support save, close and show success toast', () => {
initNormally()
component.title = 'Foo Bar'
@@ -1400,19 +1388,4 @@ describe('DocumentDetailComponent', () => {
component.openEmailDocument()
expect(modalSpy).toHaveBeenCalled()
})
it('should set previewText', () => {
initNormally()
const previewText = 'Hello world, this is a test'
httpTestingController.expectOne(component.previewUrl).flush(previewText)
expect(component.previewText).toEqual(previewText)
})
it('should set previewText to error message if preview fails', () => {
initNormally()
httpTestingController
.expectOne(component.previewUrl)
.flush('fail', { status: 500, statusText: 'Server Error' })
expect(component.previewText).toContain('An error occurred loading content')
})
})

View File

@@ -15,13 +15,8 @@
}
</div>
<div class="col col-md-10">
<div class="col col-md-10">
<div class="card-body">
@if (document?.in_process) {
<span class="badge bg-secondary text-light mb-2">
<div class="spinner-border spinner-border-sm me-1" role="status"></div><span i18n>Processing...</span>
</span>
}
<div class="d-flex justify-content-between align-items-center">
<h5 class="card-title w-100">
@if (document) {

View File

@@ -37,11 +37,6 @@
}
<div class="card-body bg-light p-2">
@if (document?.in_process) {
<span class="badge bg-secondary text-light mb-2">
<div class="spinner-border spinner-border-sm me-1" role="status"></div><span i18n>Processing...</span>
</span>
}
<p class="card-text">
@if (document) {
@if (displayFields.includes(DisplayField.CORRESPONDENT) && document.correspondent) {

View File

@@ -301,11 +301,6 @@
}
@if (activeDisplayFields.includes(DisplayField.TITLE) || activeDisplayFields.includes(DisplayField.TAGS)) {
<td width="30%">
@if (d.in_process) {
<span class="badge bg-secondary text-light me-1">
<div class="spinner-border spinner-border-sm me-1" role="status"></div><span i18n>Processing...</span>
</span>
}
@if (activeDisplayFields.includes(DisplayField.TITLE)) {
<div class="d-inline-block" (mouseleave)="popupPreview.close()">
<a routerLink="/documents/{{d.id}}" title="Edit document" i18n-title style="overflow-wrap: anywhere;">{{d.title | documentTitle}}</a>

View File

@@ -159,8 +159,6 @@ export interface Document extends ObjectWithPermissions {
page_count?: number
in_process?: boolean
// Frontend only
__changedFields?: string[]
}

View File

@@ -283,7 +283,6 @@ def rotate(doc_ids: list[int], degrees: int) -> Literal["OK"]:
f"Attempting to rotate {len(doc_ids)} documents by {degrees} degrees.",
)
qs = Document.objects.filter(id__in=doc_ids)
Document.objects.filter(pk__in=doc_ids).update(in_process=True)
affected_docs: list[int] = []
import pikepdf
@@ -310,9 +309,7 @@ def rotate(doc_ids: list[int], degrees: int) -> Literal["OK"]:
f"Rotated document {doc.id} by {degrees} degrees",
)
affected_docs.append(doc.id)
Document.objects.filter(pk__in=doc_ids).update(in_process=False)
except Exception as e:
Document.objects.filter(pk__in=doc_ids).update(in_process=False)
logger.exception(f"Error rotating document {doc.id}: {e}")
if len(affected_docs) > 0:
@@ -477,7 +474,6 @@ def delete_pages(doc_ids: list[int], pages: list[int]) -> Literal["OK"]:
f"Attempting to delete pages {pages} from {len(doc_ids)} documents",
)
doc = Document.objects.get(id=doc_ids[0])
Document.objects.filter(pk=doc.id).update(in_process=True)
pages = sorted(pages) # sort pages to avoid index issues
import pikepdf
@@ -496,7 +492,6 @@ def delete_pages(doc_ids: list[int], pages: list[int]) -> Literal["OK"]:
update_document_content_maybe_archive_file.delay(document_id=doc.id)
logger.info(f"Deleted pages {pages} from document {doc.id}")
except Exception as e:
Document.objects.filter(pk=doc.id).update(in_process=False)
logger.exception(f"Error deleting pages from document {doc.id}: {e}")
return "OK"
@@ -523,7 +518,6 @@ def edit_pdf(
f"Editing PDF of document {doc_ids[0]} with {len(operations)} operations",
)
doc = Document.objects.get(id=doc_ids[0])
Document.objects.filter(pk=doc.id).update(in_process=True)
import pikepdf
pdf_docs: list[pikepdf.Pdf] = []
@@ -593,7 +587,6 @@ def edit_pdf(
except Exception as e:
logger.exception(f"Error editing document {doc.id}: {e}")
Document.objects.filter(pk=doc.id).update(in_process=False)
raise ValueError(
f"An error occurred while editing the document: {e}",
) from e

View File

@@ -1,23 +0,0 @@
# Generated by Django 5.2.5 on 2025-08-26 07:54
from django.db import migrations
from django.db import models
class Migration(migrations.Migration):
dependencies = [
("documents", "1068_alter_document_created"),
]
operations = [
migrations.AddField(
model_name="document",
name="in_process",
field=models.BooleanField(
db_index=True,
default=False,
help_text="Whether the document is currently being processed.",
verbose_name="in process",
),
),
]

View File

@@ -289,13 +289,6 @@ class Document(SoftDeleteModel, ModelWithOwner):
),
)
in_process = models.BooleanField(
_("in process"),
default=False,
db_index=True,
help_text=_("Whether the document is currently being processed."),
)
class Meta:
ordering = ("-created",)
verbose_name = _("document")

View File

@@ -935,8 +935,6 @@ class DocumentSerializer(
required=False,
)
in_process = serializers.BooleanField(read_only=True)
def get_page_count(self, obj) -> int | None:
return obj.page_count
@@ -1105,7 +1103,6 @@ class DocumentSerializer(
"remove_inbox_tags",
"page_count",
"mime_type",
"in_process",
)
list_serializer_class = OwnedObjectListSerializer

View File

@@ -250,7 +250,6 @@ def update_document_content_maybe_archive_file(document_id):
it exists.
"""
document = Document.objects.get(id=document_id)
Document.objects.filter(pk=document_id).update(in_process=True)
mime_type = document.mime_type
@@ -350,7 +349,6 @@ def update_document_content_maybe_archive_file(document_id):
)
finally:
parser.cleanup()
Document.objects.filter(pk=document_id).update(in_process=False)
@shared_task

View File

@@ -88,7 +88,6 @@ class StandardPagination(PageNumberPagination):
response_schema["properties"]["all"] = {
"type": "array",
"example": "[1, 2, 3]",
"items": {"type": "integer"},
}
return response_schema