Skip to content

Commit

Permalink
feature(general): add created_at field on user document (#827)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkue authored May 10, 2024
1 parent cf36434 commit e14892b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions admin/src/collections/Users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { buildContributionsCollection } from './Contributions';
import { donationCertificateCollection } from './DonationCertificate';
import { buildAuditedCollection } from './shared';

// @ts-ignore
export const usersCollection = buildAuditedCollection<User>({
path: USER_FIRESTORE_PATH,
group: 'Contributors',
Expand Down Expand Up @@ -133,5 +134,11 @@ export const usersCollection = buildAuditedCollection<User>({
dataType: 'number',
readOnly: true,
},
created_at: {
name: 'Created At',
// @ts-ignore
dataType: 'date',
readOnly: true,
},
}),
});
1 change: 1 addition & 0 deletions shared/src/stripe/StripeEventHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,5 +438,6 @@ describe('stripeWebhook', () => {
payment_reference_id: DateTime.now().toMillis(),
test_user: false,
currency: 'USD',
created_at: toFirebaseAdminTimestamp(new Date('2023-01-01')),
};
});
1 change: 1 addition & 0 deletions shared/src/stripe/StripeEventHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ export class StripeEventHandler {
payment_reference_id: DateTime.now().toMillis(),
currency: bestGuessCurrency(customer.address?.country as CountryCode),
test_user: false,
created_at: toFirebaseAdminTimestamp(DateTime.now()),
};
};

Expand Down
2 changes: 2 additions & 0 deletions shared/src/types/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { CountryCode } from './country';
import { Currency } from './currency';
import { Employer } from './employers';
import { LanguageCode } from './language';
import { Timestamp } from './timestamp';

export const USER_FIRESTORE_PATH = 'users';

Expand Down Expand Up @@ -47,6 +48,7 @@ export type User = {
currency?: Currency;
contributor_organisations?: EntityReference[];
employers?: Employer[];
created_at: Timestamp;
};

export const splitName = (name: string) => {
Expand Down
3 changes: 3 additions & 0 deletions shared/src/utils/stats/ContributionStatsCalculator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ const user1: User = {
payment_reference_id: DateTime.now().toMillis(),
test_user: false,
currency: 'USD',
created_at: toFirebaseAdminTimestamp(new Date('2023-01-01')),
};
const contributionsUser1 = ['2023-01-05', '2023-02-05', '2023-03-05', '2023-04-05'].map((date) => {
return {
Expand Down Expand Up @@ -116,6 +117,7 @@ const user2: User = {
test_user: false,
institution: true,
currency: 'CHF',
created_at: toFirebaseAdminTimestamp(new Date('2023-02-01')),
};
const contributionsUser2 = ['2023-01-08', '2023-04-09'].map((date) => {
return {
Expand Down Expand Up @@ -145,6 +147,7 @@ const testUser: User = {
payment_reference_id: DateTime.now().toMillis(),
test_user: true,
currency: 'USD',
created_at: toFirebaseAdminTimestamp(new Date('2023-03-01')),
};
const contributionsTestUser = ['2023-01-05'].map((date) => {
return {
Expand Down

0 comments on commit e14892b

Please sign in to comment.