feat: Enhance background job settings UI and functionality
Some checks failed
build.yaml / feat: Enhance background job settings UI and functionality (push) Failing after 0s
Some checks failed
build.yaml / feat: Enhance background job settings UI and functionality (push) Failing after 0s
- Updated BackgroundJob.vue to improve the display of background job statuses, including missing cross-references and current job mode. - Added auto-refresh functionality for background job status. - Introduced success toast notifications for successful status refreshes. - Modified the XML serialization process in DatasetXmlSerializer for better caching and performance. - Implemented a new RuleProvider for managing custom validation rules. - Improved error handling in routes for loading background job settings. - Enhanced ClamScan configuration with socket support for virus scanning. - Refactored dayjs utility to streamline locale management.
This commit is contained in:
parent
6757bdb77c
commit
b5bbe26ec2
27 changed files with 1221 additions and 603 deletions
|
|
@ -4,7 +4,8 @@ import { builder, create } from 'xmlbuilder2';
|
|||
import { XMLBuilder } from 'xmlbuilder2/lib/interfaces.js';
|
||||
import db from '@adonisjs/lucid/services/db';
|
||||
import { DateTime } from 'luxon';
|
||||
import type { BelongsTo } from "@adonisjs/lucid/types/relations";
|
||||
import type { BelongsTo } from '@adonisjs/lucid/types/relations';
|
||||
import logger from '@adonisjs/core/services/logger';
|
||||
|
||||
export default class DocumentXmlCache extends BaseModel {
|
||||
public static namingStrategy = new SnakeCaseNamingStrategy();
|
||||
|
|
@ -66,33 +67,38 @@ export default class DocumentXmlCache extends BaseModel {
|
|||
}
|
||||
|
||||
/**
|
||||
* Check if a dataset in a specific xml version is already cached or not.
|
||||
* Check if a valid (non-stale) cache entry exists
|
||||
* Cache is valid only if it was created AFTER the dataset's last modification
|
||||
*
|
||||
* @param mixed datasetId
|
||||
* @param mixed serverDateModified
|
||||
* @returns {Promise<boolean>} Returns true on cached hit else false.
|
||||
* @param datasetId - The dataset ID to check
|
||||
* @param datasetServerDateModified - The dataset's last modification timestamp
|
||||
* @returns true if valid cache exists, false otherwise
|
||||
*/
|
||||
// public static async hasValidEntry(datasetId: number, datasetServerDateModified: DateTime): Promise<boolean> {
|
||||
// // const formattedDate = dayjs(datasetServerDateModified).format('YYYY-MM-DD HH:mm:ss');
|
||||
|
||||
// const query = Database.from(this.table)
|
||||
// .where('document_id', datasetId)
|
||||
// .where('server_date_modified', '2023-08-17 16:51:03')
|
||||
// .first();
|
||||
|
||||
// const row = await query;
|
||||
// return !!row;
|
||||
// }
|
||||
|
||||
// Assuming 'DocumentXmlCache' has a table with a 'server_date_modified' column in your database
|
||||
public static async hasValidEntry(datasetId: number, datasetServerDateModified: DateTime): Promise<boolean> {
|
||||
const serverDateModifiedString: string = datasetServerDateModified.toFormat('yyyy-MM-dd HH:mm:ss'); // Convert DateTime to ISO string
|
||||
const query = db.from(this.table)
|
||||
|
||||
const row = await db
|
||||
.from(this.table)
|
||||
.where('document_id', datasetId)
|
||||
.where('server_date_modified', '>=', serverDateModifiedString) // Check if server_date_modified is newer or equal
|
||||
.where('server_date_modified', '>', serverDateModifiedString) // Check if server_date_modified is newer or equal
|
||||
.first();
|
||||
|
||||
const row = await query;
|
||||
return !!row;
|
||||
const isValid = !!row;
|
||||
|
||||
if (isValid) {
|
||||
logger.debug(`Valid cache found for dataset ${datasetId}`);
|
||||
} else {
|
||||
logger.debug(`No valid cache for dataset ${datasetId} (dataset modified: ${serverDateModifiedString})`);
|
||||
}
|
||||
|
||||
return isValid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidate (delete) cache entry
|
||||
*/
|
||||
public async invalidate(): Promise<void> {
|
||||
await this.delete();
|
||||
logger.debug(`Invalidated cache for document ${this.document_id}`);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue