Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev' into Shaked
Browse files Browse the repository at this point in the history
  • Loading branch information
ShakedEdr1 committed Aug 29, 2024
2 parents aee1f2d + 7d62c4d commit 02a9dde
Show file tree
Hide file tree
Showing 86 changed files with 1,424 additions and 1,906 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
congifKey.ts



# Logs
Expand Down Expand Up @@ -43,3 +43,4 @@ firebase-debug.log
firebase-debug.log*
./firestore.indexes.json
firestore.rules

83 changes: 0 additions & 83 deletions firebas.json

This file was deleted.

14 changes: 13 additions & 1 deletion firestore.rules
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,19 @@ service cloud.firestore {
allow read: if request.auth.uid != null;
allow write: if request.auth.uid != null;
}

match /rooms/{roomId=**}{
allow read: if request.auth.uid != null;
allow write: if request.auth.uid != null;
}
match /participants/{participantId=**}{
allow read: if request.auth.uid != null;
allow write: if request.auth.uid != null;
}
match /roomsSettings/{roomSettingsId=**}{
allow read: if request.auth.uid != null;
allow write: if request.auth.uid != null;
}

match /timers-rooms/{timerIdx=**}{
allow read: if request.auth.uid != null;
allow write: if request.auth.uid != null;
Expand Down
8 changes: 4 additions & 4 deletions functions/package-lock.json

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

2 changes: 1 addition & 1 deletion functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"main": "lib/index.js",
"dependencies": {
"@google/generative-ai": "^0.15.0",
"delib-npm": "^1.3.33",
"delib-npm": "^1.3.44",
"dotenv": "^16.4.5",
"firebase-admin": "^11.8.0",
"firebase-functions": "^5.1.0",
Expand Down
14 changes: 7 additions & 7 deletions functions/src/fn_agree.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AgreeDisagree, AgreeDisagreeEnum, AgreeDocument, Collections } from "delib-npm";
import { logger } from "firebase-functions/v1";
import { db } from ".";
import { getAction } from "./fn_approval";
import { Action, getAction } from "./fn_approval";


export async function updateAgrees(event: any) {
Expand All @@ -14,17 +14,17 @@ export async function updateAgrees(event: any) {
const action = getAction(event);
let results: AgreeDocument = { agree: 0, disagree: 0 };

if (action === "create") {
if (action === Action.create) {
if (!agreeAfterData) throw new Error("No agreement data found");
const { agree } = agreeAfterData;

results = getUpdateCreateAgree(combinedAgreement.statementId, agree);
} else if (action === "delete") {
} else if (action === Action.delete) {
if (!agreeBeforeData) throw new Error("No agreement data found");
const { agree } = agreeBeforeData;

results = getUpdateDeleteAgree(combinedAgreement.statementId, agree);
} else if (action === "update") {
} else if (action === Action.update) {
if (!agreeAfterData) throw new Error("No agreement data found");
const { agree: agreeAfter } = agreeAfterData;
const { agree: agreeBefore } = agreeBeforeData || { agree: undefined };
Expand All @@ -44,15 +44,15 @@ export async function updateAgrees(event: any) {
const { agree, disagree } = statement.data()?.documentAgree || { agree: 0, disagree: 0 } as AgreeDocument;
const { agree: updateAgree, disagree: updateDisagree } = results;



const newAgree = agree + updateAgree;
const newDisagree = disagree + updateDisagree;
const totalAgree = newAgree + newDisagree;

const updateAgrees: AgreeDocument = {
agree: newAgree,
disagree:newDisagree,
disagree: newDisagree,
avgAgree: totalAgree !== 0 ? (newAgree - newDisagree) / totalAgree : 0,
}

Expand Down Expand Up @@ -90,7 +90,7 @@ function getUpdateDeleteAgree(statementId: string, agree: AgreeDisagreeEnum): Ag

function getUpdateUpdateAgree(statementId: string, agreeAfter: AgreeDisagreeEnum, agreeBefore: AgreeDisagreeEnum): AgreeDocument {
try {

const { Agree, Disagree, NoOpinion } = AgreeDisagreeEnum;


Expand Down
Loading

0 comments on commit 02a9dde

Please sign in to comment.