Comments (5)
Is there something actionable we can do here really? Do you have information on why it might be missing?
from sharezone-app.
No, I don't have any idea, why this happen.
What we can do is catching the missing typeOfUser behaviour in the cloud function, which adds the user ids and check, if there are users without a typeOfUser. If yes, we notify ourselves via Slack. Advantage of this: Getting a feeling how many users are affected and getting the user ids of the affected users (they could give us more information, what they did before).
from sharezone-app.
@nilsreichardt Did you investigate this? Or is this still important? Just asking because this is still in "Soon-ish" in the triage board.
from sharezone-app.
I was reproducible with one of the versions before the summer (by using Google or Apple Sign In with an account that is not registered) but was fixed with one the updates in the summer. However, we should still do the following tasks:
- Check if there are still broken documents even after the new updates (making a query that check the user documents of the last weeks)
- Write a script that fixes the broken user documents (just using some default values because with a broken user document some features are not working like renaming)
from sharezone-app.
TL;DR
This issue appears to have been resolved. The last user with a broken user document created their account on 2023-10-31. Additionally, I have fixed all broken user documents that were in our database.
Here is the documentation of how I did it:
Because we can't query for documents without a field, I exported the User
collection using:
PROJECT_ID="sharezone-c2bd8"
gcloud firestore export gs://$PROJECT_ID.appspot.com/export/2024-02-27-users \
--collection-ids=User \
--project=$PROJECT_ID
Then I imported the data to BigQuery using the following instructions: https://cloud.google.com/bigquery/docs/loading-data-cloud-firestore#console
I used the following SQL query to get all affected users:
SELECT __key__.name as UserId, createdOn, typeOfUser
FROM `sharezone-c2bd8.2024_02_27_User.User`
WHERE typeOfUser IS NULL
ORDER BY createdOn DESC
The number of affected users is 2251.
I exported the SQL query result as JSON and executed the following script:
import * as fs from "fs";
import { firestore } from "../firebase_globals";
async function main() {
// Read users from JSON file
const data = fs.readFileSync(`${__dirname}/data.json`).toString();
const json = JSON.parse(data);
let counter = 0;
for (const user of json) {
// Update user in Firestore
await firestore.doc(`User/${user.UserId}`).update({
typeOfUser: "student", // assuming that every affacted user is a student
});
// Log the action
const logMessage = `Updated user ${user.UserId} to typeOfUser "student"`;
fs.appendFileSync("log.txt", `${logMessage}\n`);
console.log(`${logMessage}; ${++counter} users updated`);
}
}
main().catch(console.error);
It's enough to only set the typeOfUser
. Some cloud functions require a typeOfUser
, like the UserUpdate
cloud function. The other fields (name, etc.) can be easily changed by the user in the settings.
from sharezone-app.
Related Issues (20)
- Send email to users because privacy policy chagned HOT 2
- Send push notifications to new users when they don't invited users
- Add a teacher to a lesson
- Give users who donated a few months sz plus for free? HOT 1
- `Error: > Couldn't find any `pages` or `app` directory. Please create one under the project root`: docs website cloud function
- `undefined` in `GroupCreate` cloud function
- Add UI for editing grades
- Add UI for custom grade types
- iCal events are missing, when the course wasn't part of the `courseId` array HOT 1
- The subject of a lesson should be changable by a substituion.
- A lesson should be partly cancelable as a substiution.
- Add the option to change the teacher for a substitution
- When adding a new event to the iCal calendar, the `courseIds` list will be cleared
- Add notes field for lessons
- Huawei P 30 Lite: Android app crashes when selecting an image from the gallery
- Switch from Firebase Distribution to Google Play Store Closed testing for the alpha track
- macOS deployment pipeline fails since Flutter 3.22.0 HOT 1
- Grades should be sorted by the date on the term details page
- Verify email addresses of users
- Recurring homework
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sharezone-app.