Improvements on how posts are pulled in and sorted.

This commit is contained in:
Scott Idem
2025-07-18 18:15:18 -04:00
parent fd69610a3a
commit 0ac7bea046
5 changed files with 82 additions and 32 deletions

View File

@@ -42,13 +42,19 @@ if (!post_id) {
}
// Functions and Logic
// WARNING: For now the archive_on is hardcoded. It should be configurable.
let lq__post_obj_li = $derived(liveQuery(async () => {
let results = await db_posts.post
.where('account_id')
.equals($slct.account_id)
// .and((x) => (x.archive_on === null || x.archive_on > (new Date()).toISOString()))
.and((x) => (x.archive_on === null || x.archive_on > (new Date()).toISOString())) // null or future posts only
// .and((x) => (x.archive_on < (new Date()).toISOString())) // past posts only
// .and((x) => (x.archive_on > (new Date()).toISOString())) // future posts only
// .orderBy('updated_on')
// .toArray()
.reverse()
.limit($idaa_loc.bb.qry__limit)
.sortBy('tmp_sort_1');
// .sortBy('updated_on');
// .sortBy('updated_on, created_on');
@@ -58,30 +64,30 @@ let lq__post_obj_li = $derived(liveQuery(async () => {
return results;
}));
let lq__post_obj = $derived(liveQuery(async () => {
let results = await db_posts.post
.get($idaa_slct.post_id ?? ''); // null or undefined does not reset things like '' does
// let lq__post_obj = $derived(liveQuery(async () => {
// let results = await db_posts.post
// .get($idaa_slct.post_id ?? ''); // null or undefined does not reset things like '' does
return results;
}));
// return results;
// }));
let lq__post_comment_obj_li = $derived(liveQuery(async () => {
let results = await db_posts.comment
.where('post_id')
.equals($idaa_slct.post_id ?? '') // null or undefined does not reset things like '' does
.reverse()
.sortBy('updated_on');
// .sortBy('title');
// let lq__post_comment_obj_li = $derived(liveQuery(async () => {
// let results = await db_posts.comment
// .where('post_id')
// .equals($idaa_slct.post_id ?? '') // null or undefined does not reset things like '' does
// .reverse()
// .sortBy('updated_on');
// // .sortBy('title');
return results;
}));
// return results;
// }));
let lq__post_comment_obj = $derived(liveQuery(async () => {
let results = await db_posts.comment
.get($idaa_slct.post_comment_id ?? ''); // null or undefined does not reset things like '' does
// let lq__post_comment_obj = $derived(liveQuery(async () => {
// let results = await db_posts.comment
// .get($idaa_slct.post_comment_id ?? ''); // null or undefined does not reset things like '' does
return results;
}));
// return results;
// }));
$effect(() => {
@@ -110,6 +116,7 @@ $effect(() => {
api_cfg: $ae_api,
for_obj_type: 'account',
for_obj_id: $idaa_slct.account_id,
qry_archive_on: '2024-01-01', // (new Date()).toISOString(),
inc_comment_li: true,
enabled: $idaa_loc.bb.qry__enabled,
hidden: $idaa_loc.bb.qry__hidden,
@@ -128,12 +135,12 @@ if (browser) {
let message = {'post_id': $idaa_slct?.post_id ?? null};
window.parent.postMessage(message, "*");
add_activity_log(
{
action: 'idaa_bb_page',
action_with: 'browser',
}
);
// add_activity_log(
// {
// action: 'idaa_bb_page',
// action_with: 'browser',
// }
// );
}

View File

@@ -7,7 +7,7 @@ import { browser } from '$app/environment';
import { posts_func } from '$lib/ae_posts/ae_posts_functions';
export const load = (async ({ params, parent }) => { // route
let log_lvl: number = 0;
let log_lvl: number = 1;
let data = await parent();
data.log_lvl = log_lvl;
@@ -20,11 +20,14 @@ export const load = (async ({ params, parent }) => { // route
api_cfg: ae_acct.api,
for_obj_type: 'account',
for_obj_id: account_id,
// archive_on should be current datetime in ISO format
// Date().toISOString()
qry_archive_on: '2024-01-01', // (new Date()).toISOString(),
inc_comment_li: true,
enabled: 'enabled',
hidden: 'not_hidden',
limit: 29,
order_by_li: {'priority': 'DESC', 'sort': 'DESC', 'updated_on': 'DESC', 'created_on': 'DESC', 'title': 'ASC'},
limit: 19,
order_by_li: {'updated_on': 'DESC', 'created_on': 'DESC'},
try_cache: true,
log_lvl: log_lvl
});