Work on better sorting for the IDAA BB posts. Using generated tmp field. Date formats standardized.

This commit is contained in:
Scott Idem
2024-12-11 15:34:44 -05:00
parent eee8a67235
commit 3fef19488c
7 changed files with 23 additions and 12 deletions

View File

@@ -111,6 +111,7 @@ export interface Archive_Content {
created_on: Date;
updated_on?: null|Date;
// Generated fields for sorting locally only
tmp_sort_1?: null|string;
tmp_sort_2?: null|string;
@@ -145,7 +146,8 @@ export class MySubClassedDexie extends Dexie {
name,
hosted_file_id,
original_datetime, original_timezone, original_location,
[group+original_datetime],tmp_sort_1,tmp_sort_2,
[group+original_datetime],
tmp_sort_1, tmp_sort_2,
enable, hide, priority, sort, group, notes, created_on, updated_on, [group+priority+sort+updated_on]`,
});

View File

@@ -52,13 +52,13 @@ let idaa_local_data_struct: key_val = {
bb: {
enabled: 'enabled', // all, disabled, enabled
hidden: 'not_hidden', // all, hidden, not_hidden
limit: 150,
limit: 50,
offset: 0,
show_list__post_obj_li: true,
qry__enabled: 'enabled', // all, disabled, enabled
qry__hidden: 'not_hidden', // all, hidden, not_hidden
qry__limit: 150,
qry__limit: 50,
qry__offset: 0,
qry__order_by_li: {'priority': 'DESC', 'sort': 'DESC', 'updated_on': 'DESC', 'created_on': 'DESC', 'title': 'ASC'},
},

View File

@@ -714,6 +714,9 @@ export function db_save_ae_obj_li__post(
created_on: obj.created_on,
updated_on: obj.updated_on,
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.created_on}_${obj.updated_on}`,
// From SQL view
post_comment_count: obj.post_comment_count,

View File

@@ -50,6 +50,10 @@ export interface Post {
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)
post_comment_count?: number;
}
@@ -116,6 +120,7 @@ export class MySubClassedDexie extends Dexie {
post_id,
title,
full_name, email,
tmp_sort_1, tmp_sort_2,
enable, hide, priority, sort, group, notes, created_on, updated_on, [updated_on+created_on]`,
});
}

View File

@@ -32,7 +32,8 @@ $: lq__post_obj_li = liveQuery(async () => {
// .orderBy('updated_on')
// .toArray()
.reverse()
.sortBy('updated_on');
.sortBy('tmp_sort_1');
// .sortBy('updated_on');
// .sortBy('updated_on, created_on');
// .sortBy('[updated_on+created_on]');
// .sortBy('[created_on+updated_on]');

View File

@@ -191,18 +191,18 @@ onDestroy(() => {
<div class="post__created_on_updated_on">
{#if !$lq__post_obj?.updated_on}
<span class="ae_label">Created on:</span>
<span class="ae_value post__created_on">{ae_util.iso_datetime_formatter($lq__post_obj?.created_on, 'datetime_iso_12_no_seconds')}</span>
<span class="ae_value post__created_on">{ae_util.iso_datetime_formatter($lq__post_obj?.created_on, 'datetime_12_short')}</span>
{:else}
<span class="ae_label">Updated on:</span>
<span class="ae_value post__updated_on">
{ae_util.iso_datetime_formatter($lq__post_obj?.updated_on, 'datetime_iso_12_no_seconds')}</span>
{ae_util.iso_datetime_formatter($lq__post_obj?.updated_on, 'datetime_12_short')}</span>
{/if}
<span
class="post__archive_on"
class:hidden={!$ae_loc.administrator_access}
>
<span class="ae_label">Archive on:</span>
<span class="ae_value">{ae_util.iso_datetime_formatter($lq__post_obj?.archive_on, 'datetime_iso_12_no_seconds')}</span>
<span class="ae_value">{ae_util.iso_datetime_formatter($lq__post_obj?.archive_on, 'datetime_12_short')}</span>
</span>
</div>
</div>
@@ -300,10 +300,10 @@ onDestroy(() => {
<span class="post_comment__created_on_updated_on">
{#if !post_comment_obj.updated_on}
<span class="ae_label">Created on:</span>
<span class="ae_value post_comment__created_on">{ae_util.iso_datetime_formatter(post_comment_obj.created_on, 'datetime_iso_12_no_seconds')}</span>
<span class="ae_value post_comment__created_on">{ae_util.iso_datetime_formatter(post_comment_obj.created_on, 'datetime_12_short')}</span>
{:else}
<span class="ae_label">Updated on:</span>
<span class="ae_value post_comment__updated_on">{ae_util.iso_datetime_formatter(post_comment_obj.updated_on, 'datetime_iso_12_no_seconds')}</span>
<span class="ae_value post_comment__updated_on">{ae_util.iso_datetime_formatter(post_comment_obj.updated_on, 'datetime_12_short')}</span>
{/if}
</span>
</div>

View File

@@ -126,18 +126,18 @@ onMount(() => {
class="post__created_on"
>
<span class="ae_label text-xs">Created on:</span>
<span class="ae_value">{ae_util.iso_datetime_formatter(idaa_post_obj.created_on, 'datetime_iso_12_no_seconds')}</span>
<span class="ae_value">{ae_util.iso_datetime_formatter(idaa_post_obj.created_on, 'datetime_12_short')}</span>
</span>
{:else}
<span
class="post__updated_on"
>
<span class="ae_label text-xs">Updated on:</span>
<span class="ae_value">{ae_util.iso_datetime_formatter(idaa_post_obj.updated_on, 'datetime_iso_12_no_seconds')}</span>
<span class="ae_value">{ae_util.iso_datetime_formatter(idaa_post_obj.updated_on, 'datetime_12_short')}</span>
</span>
{/if}
{#if idaa_post_obj.archive_on}
<span class="post__archive_on text-xs">Archive on: {ae_util.iso_datetime_formatter(idaa_post_obj.archive_on, 'datetime_iso_12_no_seconds')}</span>
<span class="post__archive_on text-xs">Archive on: {ae_util.iso_datetime_formatter(idaa_post_obj.archive_on, 'datetime_12_short')}</span>
{/if}
</div>
{/if}