-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to topics_strength. Linting fixes + rendering improvements on Results
- Loading branch information
John Rogers
committed
May 3, 2024
1 parent
7502ef2
commit 947c727
Showing
18 changed files
with
688 additions
and
325 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"projects": { | ||
"default": "harmony-6bd51" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"firestore": { | ||
"rules": "firestore.rules", | ||
"indexes": "firestore.indexes.json" | ||
}, | ||
"functions": [ | ||
{ | ||
"source": "functions", | ||
"codebase": "default", | ||
"ignore": [ | ||
"venv", | ||
".git", | ||
"firebase-debug.log", | ||
"firebase-debug.*.log" | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"indexes": [], | ||
"fieldOverrides": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
rules_version = '2'; | ||
|
||
service cloud.firestore { | ||
match /databases/{database}/documents { | ||
match /harmonisations/{document} { | ||
// allow read access to own or public | ||
allow read: if resource.data.public == true || resource.data.uid == request.auth.uid; | ||
// write access to own | ||
allow write: if resource.data.uid == request.auth.uid; | ||
// create access to any logged in | ||
allow create: if request.auth != null; | ||
} | ||
match /mismatches/{document} { | ||
// allow create access to public | ||
allow create, write: if true ; | ||
} | ||
match /ratings/{document} { | ||
// allow create access to public | ||
allow create, write: if true ; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
venv | ||
__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Welcome to Cloud Functions for Firebase for Python! | ||
# To get started, simply uncomment the below code or create your own. | ||
# Deploy with `firebase deploy` | ||
|
||
from firebase_functions import https_fn | ||
from firebase_admin import initialize_app | ||
from firebase_admin import firestore | ||
import json | ||
import datetime | ||
|
||
app = initialize_app() | ||
db = firestore.client() | ||
|
||
# Define a custom function to serialize datetime objects | ||
def serialize_datetime(obj): | ||
if isinstance(obj, datetime.datetime): | ||
return obj.isoformat() | ||
raise TypeError("Type not serializable") | ||
|
||
@https_fn.on_request(region="europe-west1") | ||
def api(req: https_fn.Request) -> https_fn.Response: | ||
data = [] | ||
match req.path: | ||
case "/mismatches": | ||
docs = db.collection("mismatches").stream() | ||
for doc in docs: | ||
d = doc.to_dict() | ||
d["fbid"] = doc.id | ||
data.append(d) | ||
case "/harmonisations": | ||
docs = db.collection("harmonisations").stream() | ||
for doc in docs: | ||
d = doc.to_dict() | ||
d["fbid"] = doc.id | ||
data.append(d) | ||
case "/ratings": | ||
docs = db.collection("ratings").stream() | ||
for doc in docs: | ||
d = doc.to_dict() | ||
d["fbid"] = doc.id | ||
data.append(d) | ||
case _ : | ||
data.append("No such end point " + req.path ) | ||
return https_fn.Response(json.dumps(data, default=serialize_datetime), mimetype="application/json") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
firebase_functions~=0.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.