Skip to content

Commit f40cbf5

Browse files
committed
remove relation not published
1 parent ffb734f commit f40cbf5

File tree

1 file changed

+45
-6
lines changed

1 file changed

+45
-6
lines changed

frontend/main/src/services/notion.server.ts

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,22 @@ export const queryRelationById = async (
633633
direction: 'descending',
634634
},
635635
];
636+
let filter: any = {
637+
and: [
638+
{
639+
property: relation,
640+
relation: {
641+
contains: id,
642+
},
643+
},
644+
{
645+
property: 'published',
646+
select: {
647+
equals: 'published',
648+
},
649+
},
650+
],
651+
};
636652

637653
if (_type == PostType.podcast) {
638654
sorts = [
@@ -645,6 +661,34 @@ export const queryRelationById = async (
645661
direction: 'descending',
646662
},
647663
];
664+
filter = {
665+
and: [
666+
{
667+
property: 'slug',
668+
url: {
669+
is_not_empty: true,
670+
},
671+
},
672+
{
673+
property: 'Status',
674+
select: {
675+
equals: 'Released',
676+
},
677+
},
678+
{
679+
property: 'Episode',
680+
number: {
681+
is_not_empty: true,
682+
},
683+
},
684+
{
685+
property: 'start',
686+
date: {
687+
on_or_before: new Date().toISOString(),
688+
},
689+
},
690+
],
691+
};
648692
}
649693
if (skipNotion) {
650694
return {
@@ -655,12 +699,7 @@ export const queryRelationById = async (
655699
let raw = await notionClient.databases.query({
656700
database_id: getNotionDbByType(_type),
657701
page_size: 20, // Adding this so that Algolia is used more
658-
filter: {
659-
property: relation,
660-
relation: {
661-
contains: id,
662-
},
663-
},
702+
filter,
664703
sorts,
665704
});
666705
return await formatPosts(raw, _type);

0 commit comments

Comments
 (0)