Skip to content

Commit

Permalink
Merge pull request #41 from RotaractMora/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
SakinduRansindu authored Dec 6, 2024
2 parents da08ed2 + 24002c6 commit ae2e960
Show file tree
Hide file tree
Showing 55 changed files with 2,058 additions and 426 deletions.
7 changes: 7 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file is used to store environment variables that are specific to your local development environment.
NEXT_PUBLIC_API_KEY=<firebase_api_key>
NEXT_PUBLIC_AUTH_DOMAIN=<firebase_auth_domain>
NEXT_PUBLIC_PROJECT_ID=<firebase_project_id>
NEXT_PUBLIC_STORAGE_BUCKET=<firebase_storage_bucket>
NEXT_PUBLIC_MESSAGING_SENDER_ID=<firebase_messaging_sender_id>
NEXT_PUBLIC_APP_ID=<firebase_app_id>
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ next-env.d.ts
# firebase emulator logs
ui-debug.log
firebase-debug.log
firestore-debug.log
firestore-debug.log
4 changes: 2 additions & 2 deletions functions/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
// Exporting triggers for /info-sponsors and /info-timeline collections
const sponsorsTriggers = createInfoTriggers("info-sponsors");
const timelineTriggers = createInfoTriggers("info-timeline");
const reachUsTriggers = createInfoTriggers("info-reach");

export const infoSponsorsOnCreate = sponsorsTriggers.onCreate;
export const infoSponsorsOnUpdate = sponsorsTriggers.onUpdate;
Expand All @@ -16,6 +17,9 @@ export const infoTimelineOnCreate = timelineTriggers.onCreate;
export const infoTimelineOnUpdate = timelineTriggers.onUpdate;
export const infoTimelineOnDelete = timelineTriggers.onDelete;

export const infoReachUsOnCreate = reachUsTriggers.onCreate;
export const infoReachUsOnUpdate = reachUsTriggers.onUpdate;
export const infoReachUsOnDelete = reachUsTriggers.onDelete;

// Exporting Firestore triggers for incremental company aggregation
export const companyOnCreate = incrementalAggregateCompanies.onCreate;
Expand Down
13 changes: 10 additions & 3 deletions functions/src/infoAggregator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,27 @@ const aggregateData = async () => {
const aggregatedData: {
"info-sponsors": Record<string, unknown>;
"info-timeline": Record<string, unknown>;
} = {"info-sponsors": {}, "info-timeline": {}};
"info-reach": Record<string, unknown>;
} = {"info-sponsors": {}, "info-timeline": {}, "info-reach": {}};

// Aggregate data from info-sponsors
const sponsorsSnapshot = await db.collection("info-sponsors").get();
const sponsorsSnapshot = await db.collection("info-sponsors").where("isVisibleToPublic", "==", true).get();
sponsorsSnapshot.forEach((doc) => {
aggregatedData["info-sponsors"][doc.id] = doc.data();
});

// Aggregate data from info-timeline
const timelineSnapshot = await db.collection("info-timeline").get();
const timelineSnapshot = await db.collection("info-timeline").where("isVisibleToPublic", "==", true).get();
timelineSnapshot.forEach((doc) => {
aggregatedData["info-timeline"][doc.id] = doc.data();
});

// Aggregate data from info-reach
const reachSnapshot = await db.collection("info-reach").where("isVisibleToPublic", "==", true).get();
reachSnapshot.forEach((doc) => {
aggregatedData["info-reach"][doc.id] = doc.data();
});

// Save the aggregated data to the Firestore document
await db.doc(AGGREGATED_DOC_PATH).set(aggregatedData);
logger.info("Successfully aggregated data into:", AGGREGATED_DOC_PATH);
Expand Down
2 changes: 1 addition & 1 deletion next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ const nextConfig: NextConfig = {
},
};

export default nextConfig;
export default nextConfig;
Loading

0 comments on commit ae2e960

Please sign in to comment.