More work on updating Archives and Posts to use tmp_sort_x and other changes.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
import { db_save_ae_obj_li__ae_obj } from "$lib/ae_core/core__idb_dexie";
|
||||
|
||||
import { db_posts } from "$lib/ae_posts/db_posts";
|
||||
|
||||
import { load_ae_obj_li__post_comment } from "$lib/ae_posts/ae_posts__post_comment";
|
||||
@@ -732,3 +734,140 @@ export function db_save_ae_obj_li__post(
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-06-04
|
||||
export const properties_to_save = [
|
||||
'id',
|
||||
'post_id',
|
||||
// 'post_id_random',
|
||||
|
||||
'account_id',
|
||||
// 'account_id_random',
|
||||
|
||||
'external_person_id',
|
||||
|
||||
'topic_id',
|
||||
'topic',
|
||||
'topic_name',
|
||||
|
||||
'name',
|
||||
'title',
|
||||
'content',
|
||||
|
||||
'anonymous',
|
||||
'full_name',
|
||||
'email',
|
||||
'notify',
|
||||
|
||||
'enable_comments',
|
||||
|
||||
'archive',
|
||||
'archive_on',
|
||||
|
||||
'linked_li_json',
|
||||
'cfg_json',
|
||||
|
||||
'enable',
|
||||
'hide',
|
||||
'priority',
|
||||
'sort',
|
||||
'group',
|
||||
'notes',
|
||||
'created_on',
|
||||
'updated_on',
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
'tmp_sort_1',
|
||||
'tmp_sort_2',
|
||||
// 'tmp_sort_a',
|
||||
// 'tmp_sort_b',
|
||||
|
||||
// From SQL view
|
||||
'post_comment_count',
|
||||
|
||||
// A key value list of the comments
|
||||
// 'post_comment_kv',
|
||||
// 'post_comment_li',
|
||||
];
|
||||
|
||||
|
||||
// Updated 2025-06-04
|
||||
export async function process_ae_obj__post_props({
|
||||
obj_li,
|
||||
log_lvl = 0,
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** process_ae_obj__post_props() ***`, obj_li);
|
||||
}
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li = [];
|
||||
|
||||
for (const obj of obj_li) {
|
||||
if (log_lvl) console.log(`Processing ae_obj post:`, obj);
|
||||
|
||||
let processed_obj = {
|
||||
id: obj.post_id_random,
|
||||
post_id: obj.post_id_random,
|
||||
// post_id_random: obj.post_id_random,
|
||||
|
||||
account_id: obj.account_id_random,
|
||||
// account_id_random: obj.account_id_random,
|
||||
|
||||
external_person_id: obj.external_person_id,
|
||||
|
||||
topic_id: obj.topic_id,
|
||||
topic: obj.topic,
|
||||
topic_name: obj.topic_name,
|
||||
|
||||
name: obj.title,
|
||||
title: obj.title,
|
||||
content: obj.content,
|
||||
|
||||
anonymous: obj.anonymous,
|
||||
full_name: obj.full_name,
|
||||
email: obj.email,
|
||||
notify: obj.notify,
|
||||
|
||||
enable_comments: obj.enable_comments,
|
||||
|
||||
archive: obj.archive,
|
||||
archive_on: obj.archive_on,
|
||||
|
||||
linked_li_json: obj.linked_li_json,
|
||||
cfg_json: obj.cfg_json,
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
tmp_sort_1: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on ?? obj.created_on}`,
|
||||
tmp_sort_2: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on}_${obj.created_on}`,
|
||||
|
||||
// From SQL view
|
||||
post_comment_count: obj.post_comment_count,
|
||||
|
||||
// A key value list of the contents
|
||||
// post_comment_kv: obj.post_comment_kv,
|
||||
// post_comment_li: obj.post_comment_li,
|
||||
};
|
||||
|
||||
processed_obj_li.push(processed_obj);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
import { db_save_ae_obj_li__ae_obj } from "$lib/ae_core/core__idb_dexie";
|
||||
|
||||
import { db_posts } from "$lib/ae_posts/db_posts";
|
||||
|
||||
let ae_promises: key_val = {};
|
||||
@@ -392,3 +394,110 @@ export function db_save_ae_obj_li__post_comment(
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-06-04
|
||||
export const properties_to_save = [
|
||||
'id',
|
||||
'post_comment_id',
|
||||
// 'post_comment_id_random',
|
||||
|
||||
'post_id',
|
||||
// 'post_id_random',
|
||||
|
||||
'external_person_id',
|
||||
|
||||
'name',
|
||||
'title',
|
||||
'content',
|
||||
|
||||
'anonymous',
|
||||
'full_name',
|
||||
'email',
|
||||
'notify',
|
||||
|
||||
'linked_li_json',
|
||||
'cfg_json',
|
||||
|
||||
'enable',
|
||||
'hide',
|
||||
'priority',
|
||||
'sort',
|
||||
'group',
|
||||
'notes',
|
||||
'created_on',
|
||||
'updated_on',
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
'tmp_sort_1',
|
||||
'tmp_sort_2',
|
||||
// 'tmp_sort_a',
|
||||
// 'tmp_sort_b',
|
||||
|
||||
// From SQL view
|
||||
];
|
||||
|
||||
|
||||
// Updated 2025-06-04
|
||||
export async function process_ae_obj__post_comment_props({
|
||||
obj_li,
|
||||
log_lvl = 0,
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** process_ae_obj__post_comment_props() ***`, obj_li);
|
||||
}
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li = [];
|
||||
|
||||
for (const obj of obj_li) {
|
||||
if (log_lvl) console.log(`Processing ae_obj post_comment:`, obj);
|
||||
|
||||
let processed_obj = {
|
||||
id: obj.post_comment_id_random,
|
||||
post_comment_id: obj.post_comment_id_random,
|
||||
post_comment_id_random: obj.post_comment_id_random,
|
||||
|
||||
post_id: obj.post_id_random,
|
||||
post_id_random: obj.post_id_random,
|
||||
|
||||
external_person_id: obj.external_person_id,
|
||||
|
||||
name: obj.name,
|
||||
title: obj.title,
|
||||
content: obj.content,
|
||||
|
||||
anonymous: obj.anonymous,
|
||||
full_name: obj.full_name,
|
||||
email: obj.email,
|
||||
notify: obj.notify,
|
||||
|
||||
linked_li_json: obj.linked_li_json,
|
||||
cfg_json: obj.cfg_json,
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
tmp_sort_1: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on ?? obj.created_on}`,
|
||||
tmp_sort_2: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on}_${obj.created_on}`,
|
||||
};
|
||||
|
||||
processed_obj_li.push(processed_obj);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
}
|
||||
@@ -93,6 +93,10 @@ export interface Post_Comment {
|
||||
created_on: Date;
|
||||
updated_on?: null|Date;
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
tmp_sort_1?: null|string;
|
||||
tmp_sort_2?: null|string;
|
||||
|
||||
// Additional fields for convenience (database views)
|
||||
}
|
||||
|
||||
@@ -113,6 +117,7 @@ export class MySubClassedDexie extends Dexie {
|
||||
title,
|
||||
full_name, email,
|
||||
archive, archive_on,
|
||||
tmp_sort_1, tmp_sort_2,
|
||||
enable, hide, priority, sort, group, notes, created_on, updated_on, [updated_on+created_on], [created_on+updated_on]`,
|
||||
|
||||
comment: `
|
||||
|
||||
Reference in New Issue
Block a user