Skip to content
Draft
70 changes: 70 additions & 0 deletions .snaplet/dataModel.json
Original file line number Diff line number Diff line change
Expand Up @@ -3892,6 +3892,20 @@
"isId": false,
"maxLength": null
},
{
"id": "public.news.published_at",
"name": "published_at",
"columnName": "published_at",
"type": "timestamptz",
"isRequired": false,
"kind": "scalar",
"isList": false,
"isGenerated": false,
"sequence": false,
"hasDefaultValue": false,
"isId": false,
"maxLength": null
},
{
"name": "categories",
"type": "categories",
Expand Down Expand Up @@ -7313,6 +7327,20 @@
"isId": false,
"maxLength": null
},
{
"id": "public.projects.published_at",
"name": "published_at",
"columnName": "published_at",
"type": "timestamptz",
"isRequired": false,
"kind": "scalar",
"isList": false,
"isGenerated": false,
"sequence": false,
"hasDefaultValue": false,
"isId": false,
"maxLength": null
},
{
"name": "categories",
"type": "categories",
Expand Down Expand Up @@ -7649,6 +7677,20 @@
"isId": false,
"maxLength": null
},
{
"id": "public.questions.published_at",
"name": "published_at",
"columnName": "published_at",
"type": "timestamptz",
"isRequired": false,
"kind": "scalar",
"isList": false,
"isGenerated": false,
"sequence": false,
"hasDefaultValue": false,
"isId": false,
"maxLength": null
},
{
"name": "categories",
"type": "categories",
Expand Down Expand Up @@ -8143,6 +8185,20 @@
"isId": false,
"maxLength": null
},
{
"id": "public.research.published_at",
"name": "published_at",
"columnName": "published_at",
"type": "timestamptz",
"isRequired": false,
"kind": "scalar",
"isList": false,
"isGenerated": false,
"sequence": false,
"hasDefaultValue": false,
"isId": false,
"maxLength": null
},
{
"name": "categories",
"type": "categories",
Expand Down Expand Up @@ -8441,6 +8497,20 @@
"isId": false,
"maxLength": null
},
{
"id": "public.research_updates.published_at",
"name": "published_at",
"columnName": "published_at",
"type": "timestamptz",
"isRequired": false,
"kind": "scalar",
"isList": false,
"isGenerated": false,
"sequence": false,
"hasDefaultValue": false,
"isId": false,
"maxLength": null
},
{
"name": "profiles",
"type": "profiles",
Expand Down
4 changes: 4 additions & 0 deletions packages/components/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export const fakeNewsSB = (newsOverloads: Partial<News> = {}): News => ({
id: faker.number.int(),
createdAt: faker.date.past(),
modifiedAt: null,
publishedAt: null,
author: fakeAuthorSB(),
category: null,
commentCount: faker.number.int(100),
Expand Down Expand Up @@ -99,6 +100,7 @@ export const fakeQuestionSB = (questionOverloads: Partial<Question> = {}): Quest
id: faker.number.int(),
createdAt: faker.date.past(),
modifiedAt: null,
publishedAt: null,
author: fakeAuthorSB(),
category: null,
commentCount: faker.number.int(100),
Expand All @@ -122,6 +124,7 @@ export const fakeResearchItem = (
id: faker.number.int(),
createdAt: faker.date.past(),
modifiedAt: null,
publishedAt: null,
author: fakeAuthorSB(),
category: null,
collaborators: [],
Expand Down Expand Up @@ -150,6 +153,7 @@ export const fakeResearchUpdate = (
id: faker.number.int(),
createdAt: faker.date.past(),
modifiedAt: null,
publishedAt: null,
author: fakeAuthorSB(),
researchId: faker.number.int(100),
commentCount: faker.number.int(100),
Expand Down
5 changes: 5 additions & 0 deletions packages/cypress/src/utils/supabaseTestsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export class SupabaseTestsService {
status: item.status,
created_by: createdBy,
is_draft: item.is_draft,
published_at: item.is_draft ? null : item.created_at,
tags: [tagsData.data[0].id, tagsData.data[1].id],
category: categories.data[i % 2].id,
tenant_id: this.tenantId,
Expand All @@ -162,6 +163,7 @@ export class SupabaseTestsService {
title: item.title,
research_id: research.data[i].id,
created_by: createdBy,
published_at: item.created_at,
tenant_id: this.tenantId,
})),
});
Expand Down Expand Up @@ -230,6 +232,7 @@ export class SupabaseTestsService {
tenant_id: this.tenantId,
created_by: profiles[0].id,
category: categories.data[0].id,
published_at: question.created_at,
})),
});

Expand Down Expand Up @@ -295,6 +298,7 @@ export class SupabaseTestsService {
tags: [tagsData.data[0].id, tagsData.data[1].id],
category: categories.data[0].id,
tenant_id: this.tenantId,
published_at: news.created_at,
})),
});

Expand Down Expand Up @@ -336,6 +340,7 @@ export class SupabaseTestsService {
deleted: item.deleted,
moderation: item.moderation,
tenant_id: this.tenantId,
published_at: item.createdAt,
...(item.moderationFeedback ? { moderation_feedback: item.moderationFeedback } : {}),
});
}
Expand Down
3 changes: 3 additions & 0 deletions shared/models/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class DBProject implements IDBContentDoc, IDBDownloadable, IDBModeration
readonly id: number;
readonly created_at: Date;
readonly deleted: boolean | null;
readonly published_at: Date | null;
readonly author?: DBAuthor;
readonly update_count?: number;
readonly useful_count?: number;
Expand Down Expand Up @@ -62,6 +63,7 @@ export class Project implements IContentDoc, IDownloadable, IModeration {
createdAt: Date;
author: Author | null;
modifiedAt: Date | null;
publishedAt: Date | null;
title: string;
slug: string;
previousSlugs: string[];
Expand Down Expand Up @@ -98,6 +100,7 @@ export class Project implements IContentDoc, IDownloadable, IModeration {
createdAt: new Date(obj.created_at),
author: obj.author ? Author.fromDB(obj.author) : null,
modifiedAt: obj.modified_at ? new Date(obj.modified_at) : null,
publishedAt: obj.published_at ? new Date(obj.published_at) : null,
title: obj.title,
slug: obj.slug,
previousSlugs: obj.previous_slugs || [],
Expand Down
3 changes: 3 additions & 0 deletions shared/models/news.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class DBNews implements IDBContentDoc {
readonly id: number;
readonly created_at: Date;
readonly modified_at: Date | null;
readonly published_at: Date | null;
readonly author?: DBAuthor;
readonly comment_count?: number;
readonly category: DBCategory | null;
Expand Down Expand Up @@ -52,6 +53,7 @@ export class News implements IContentDoc {
modifiedAt: Date | null;
profileBadge: ProfileBadge | null;
previousSlugs: string[];
publishedAt: Date | null;
slug: string;
subscriberCount: number;
summary: string | null;
Expand Down Expand Up @@ -88,6 +90,7 @@ export class News implements IContentDoc {
modifiedAt: news.modified_at ? new Date(news.modified_at) : null,
profileBadge: news.profile_badge ? ProfileBadge.fromDB(news.profile_badge) : null,
previousSlugs: news.previous_slugs,
publishedAt: news.published_at ? new Date(news.published_at) : null,
slug: news.slug,
subscriberCount: news.subscriber_count || 0,
summary: news.summary || null,
Expand Down
3 changes: 3 additions & 0 deletions shared/models/question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export class DBQuestion implements IDBContentDoc {
is_draft: boolean;
readonly created_at: Date;
readonly modified_at: Date | null;
readonly published_at: Date | null;
readonly author?: DBAuthor;
readonly comment_count?: number;
readonly category: DBCategory | null;
Expand Down Expand Up @@ -46,6 +47,7 @@ export class Question implements IContentDoc {
isDraft: boolean;
modifiedAt: Date | null;
previousSlugs: string[];
publishedAt: Date | null;
slug: string;
subscriberCount: number;
tags: Tag[];
Expand Down Expand Up @@ -74,6 +76,7 @@ export class Question implements IContentDoc {
isDraft: obj.is_draft || false,
modifiedAt: obj.modified_at ? new Date(obj.modified_at) : null,
previousSlugs: obj.previous_slugs,
publishedAt: obj.published_at ? new Date(obj.published_at) : null,
slug: obj.slug,
subscriberCount: obj.subscriber_count || 0,
tagIds: obj.tags,
Expand Down
6 changes: 6 additions & 0 deletions shared/models/research.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export class DBResearchItem implements IDBContentDoc {
readonly id: number;
readonly created_at: Date;
readonly deleted: boolean | null;
readonly published_at: Date | null;
readonly author?: DBAuthor;
readonly update_count?: number;
readonly useful_count?: number;
Expand Down Expand Up @@ -53,6 +54,7 @@ export class ResearchItem implements IContentDoc {
createdAt: Date;
author: Author | null;
modifiedAt: Date | null;
publishedAt: Date | null;
title: string;
slug: string;
previousSlugs: string[];
Expand Down Expand Up @@ -114,6 +116,7 @@ export class ResearchItem implements IContentDoc {
createdAt: new Date(obj.created_at),
author: obj.author ? Author.fromDB(obj.author) : null,
modifiedAt: obj.modified_at ? new Date(obj.modified_at) : null,
publishedAt: obj.published_at ? new Date(obj.published_at) : null,
title: obj.title,
slug: obj.slug,
previousSlugs: obj.previous_slugs || [],
Expand Down Expand Up @@ -145,6 +148,7 @@ export class DBResearchUpdate implements IDBDocSB, IDBDownloadable {
readonly created_at: Date;
readonly deleted: boolean | null;
readonly is_draft: boolean | null;
readonly published_at: Date | null;
readonly comment_count?: number;
readonly file_download_count?: number;
readonly update_author?: DBAuthor;
Expand Down Expand Up @@ -175,6 +179,7 @@ export class ResearchUpdate implements IDoc, IDownloadable {
isDraft: boolean;
hasFileLink: boolean;
modifiedAt: Date | null;
publishedAt: Date | null;
researchId: number;
title: string;
videoUrl: string | null;
Expand All @@ -189,6 +194,7 @@ export class ResearchUpdate implements IDoc, IDownloadable {
id: obj.id,
createdAt: new Date(obj.created_at),
modifiedAt: obj.modified_at ? new Date(obj.modified_at) : null,
publishedAt: obj.published_at ? new Date(obj.published_at) : null,
author: obj.update_author ? Author.fromDB(obj.update_author) : null,
title: obj.title,
description: obj.description,
Expand Down
3 changes: 1 addition & 2 deletions src/pages/Library/Content/Page/LibraryDescription.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,8 @@ export const LibraryDescription = ({

<Text variant="auxiliary">
<DisplayDate
createdAt={item.createdAt}
createdAt={item.publishedAt || item.createdAt}
modifiedAt={item.modifiedAt}
action="Published"
/>
</Text>

Expand Down
2 changes: 1 addition & 1 deletion src/pages/News/NewsListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const NewsListItem = ({ news, query }: IProps) => {
</Flex>

<Text variant="auxiliary">
<DisplayDate action={'Published'} createdAt={news.createdAt} />
<DisplayDate createdAt={news.publishedAt || news.createdAt} />
</Text>

{news.summary && (
Expand Down
2 changes: 1 addition & 1 deletion src/pages/News/NewsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const NewsPage = observer(({ news }: IProps) => {
</Heading>

<Text variant="auxiliary">
<DisplayDate action={'Published'} createdAt={news.createdAt} />
<DisplayDate createdAt={news.publishedAt || news.createdAt} />
</Text>

{news.isDraft && <DraftTag />}
Expand Down
1 change: 1 addition & 0 deletions src/pages/Question/QuestionListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export const QuestionListItem = ({ question, query }: IProps) => {
author={question.author}
createdAt={question.createdAt}
modifiedAt={question.modifiedAt}
publishedAt={question.publishedAt}
/>
)}
</Flex>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Question/QuestionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const QuestionPage = observer(({ question }: IProps) => {

<Text variant="auxiliary">
<DisplayDate
createdAt={question.createdAt}
createdAt={question.publishedAt || question.createdAt}
modifiedAt={question.modifiedAt}
action="Asked"
/>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Research/Content/ResearchDescription.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const ResearchDescription = (props: IProps) => {

<Text variant="auxiliary">
<DisplayDate
createdAt={research.createdAt}
createdAt={research.publishedAt || research.createdAt}
modifiedAt={lastUpdated.toISOString()}
action="Started"
/>
Expand Down
7 changes: 5 additions & 2 deletions src/pages/Research/Content/ResearchUpdate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,16 @@ const ResearchUpdate = (props: IProps) => {
)}

<Text variant="auxiliary">
<DisplayDate createdAt={update.createdAt} action="Created" />
<DisplayDate
createdAt={update.publishedAt || update.createdAt}
action="Created"
/>
</Text>

{update.modifiedAt !== update.createdAt && (
<Text variant="auxiliary">
<DisplayDate
createdAt={update.createdAt}
createdAt={update.publishedAt || update.createdAt}
modifiedAt={update.modifiedAt}
action="Updated"
/>
Expand Down
10 changes: 8 additions & 2 deletions src/pages/common/UserNameTag/UserNameTag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ interface IProps {
createdAt?: string | number | Date;
action?: string;
modifiedAt?: string | number | Date | null;
publishedAt?: string | number | Date | null;
}

export const UserNameTag = (props: IProps) => {
const { author, createdAt, action = 'Published', modifiedAt } = props;
const { author, createdAt, action = 'Published', modifiedAt, publishedAt } = props;

return (
<Flex sx={{ flexDirection: 'column' }}>
Expand All @@ -26,7 +27,12 @@ export const UserNameTag = (props: IProps) => {
marginBottom: 2,
}}
>
| <DisplayDate action={action} createdAt={createdAt} modifiedAt={modifiedAt} />
|{' '}
<DisplayDate
action={action}
createdAt={publishedAt || createdAt}
modifiedAt={modifiedAt}
/>
</Text>
)}
</Flex>
Expand Down
Loading