Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add status timpestamps #45

Merged
merged 6 commits into from
Feb 27, 2024
Merged

Add status timpestamps #45

merged 6 commits into from
Feb 27, 2024

Conversation

technophile-04
Copy link
Member

@technophile-04 technophile-04 commented Feb 26, 2024

Description

  1. Renamed timestamp => completedAt in seed.sample.json (Because of indentation updated, it looking like I added new stuff :( ) please let me know if I should revert it 🙌 and use 4 space indentation instead at
  2. Updated schema to add status timestamps fields
  3. Updated firebase functions to respect this changes
  4. display createdAt date on frontend cards

Also a question currently we are generating timestamp as :

const timestamp = new Date().getTime();

But I saw some people generate timestamp for firebase like this :

import { FieldValue } from "firebase-admin/firestore";
const serverTimeStamp = FieldValue.serverTimestamp();
//  ^ <Full name of the month> dd, yyyy hh:mm:ss <Time zone of your location>

Basically storing its Timestamp object from firebase

And this is how it looks in the firebase document:
Screenshot 2024-02-26 at 10 13 49 PM

Here is chatGPT difference.

Basically, FieldValue.serverTimestamp(); creates a placeholder value and uses timestamp which is generated while writing to firestore. People use this just to avoid using timestamp from client's system clock instead using firebase's cloack.

Since we are not using firebase on client, it doest much affect us but another advantage of FieldValue.serverTimestamp(); its more precise than JS Date since it stores value in nanoseconds where JS Date store in milisecond checkout this

Please let me know if we should use FieldValue.serverTimestamp();, we will needing script to convert current seed timestamps(JS Date) to Firebase Timestamp, it should be though 🙌

Copy link

vercel bot commented Feb 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
grants-bg ❌ Failed (Inspect) Feb 27, 2024 10:39am

@technophile-04 technophile-04 changed the title Add timpestamps Add status timpestamps Feb 26, 2024
Comment on lines +53 to +59
export type GrantData = Simplify<
GrantWithoutTimestamps & {
[k in GrantWithoutTimestamps["status"] as `${k}At`]?: number;
}
>;

export type GrantDataWithBuilder = Simplify<GrantData & { builderData?: BuilderData }>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uncle Bob, is this you? 🤣

Copy link
Contributor

@carletex carletex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is perfect. Just added a commit to sort completed grants by date DESC

@carletex carletex merged commit 1a4e5b3 into main Feb 27, 2024
2 of 3 checks passed
@Pabl0cks Pabl0cks mentioned this pull request Feb 27, 2024
@carletex carletex deleted the add-timpestamps branch March 6, 2024 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants