Database design for storing users log data in mongodb on daily, weekly basis - mongodb

I am making a live tracking application which tracks the data of the application and the websites using by the user and stores the activity data of the user in the mongodb database. It stores the data of the user like which application or website is being used by the user and how much time they have used that application in their computer.
My current database document looks like this.
Database image
I want to store the logs of the user according to the Daily, Weekly and Monthly basis in mongodb. I want to have the database architecture to use for storing these logs on daily or weekly basis according to the user. I want to know how can I do this.

Related

How to Implement "Your contact just joined app" feature

I am building a mobile app (in flutter firebase, but the answer does not have to be firebase specific). And I would like to implement a feature that notifies users whenever anyone from their contact list joins the app. This seems like a very EXPENSIVE feature.
At the top of my head, I see a lambda/cloud function that is triggered everytime a user joins and then searches a database of users and their respective contacts for the existence of the new user's phone number. To me, this solution does not scale well for two reasons: if the number of total users is in the millions and the number of users joining simultaneously is a lot.
My better solution is to get the user's contacts upon joining and then searching a database of current users contacts for any of the phone numbers of the newly joined user.
Is there a solution better than the second one? If so, what is it? If the second solution is standard, what kind of backend storage mechanism provides the best search and retrieval time for a database of users and their respective contacts?
In the case of large users ill not do first solution because that may slow the sign up process instead i will creat a cron job that runs at a specific time or periodically it will get the list of the latest users signed up that day or that hour whatever you prefer then that cron will check the new user if related to any user in the databases and send a notification right away, or a better solution create a temporary table in a database in another server insert the notification informations into the other server, creat another cron job in the second server it will run at a specific time to sendthe notification

Where should I keep data to continuously use in server?

Currently, I'm trying to build a dating app(server part).
I'm going to store each user's profile data like videos, photos, profile messages to AWS S3.
And I have user info including location(longitude, latitude) in my database server.
If you've ever used this kind of app, you might easily understand how it works.
First, whenever a user opens this app, the user gets to see the profile of other users one at a time based on the current location.
Second, the user gives like or dislike to the current profile and gets to the next profile.
So, in order to implement the first step, I'm going to search other users in a certain distance from the user's current location in the database, but here I'm only going to get unique user ID values from database. This only happens once when a user opens the app.
Now that I have other users' id values like [id1, id2, id3, id4...] I can load each user's profile data from AWS S3 with each unique id value one by one whenever the user needs to see the next profile.
Here my question comes. To build the recommendation logic like that, where should I keep the id values??
Thanks in advance.
Use a in memory cache like Redis/memcache (both provided by AWS). Also your cahce should get updated as and when data in AWS S3 profile updates because only then you will have latest data.

How to load massive amount of data from Firebase Realtime Database

I have a pretty big problem.
I have two databases currently in my app. It's a meeting app. I am using MongoDB to store basic user data i.e. his name, surname, email and so on. And on Firebase Realtime Database I am storing the incomingRequests, sentRequests and friendsList.
So the question is following: How can I load massive amounts of data so that I can retrieve the userIds and statuses of the user from Firebase without doing it every time I open the app.
Currently, every time I open my app, I make a request to firebase to get me all of the user Ids that I have as friends. Then I query each userId and post a request to my MongoDB with the userId so that I can get user profile picture and username. I need to fix this because my loading times are 15+ seconds if someone has 100 friends for example.
So in summary, how can I solve this big data problem??

Tableau Server Extracts issue

A developer had created dashboard and successfully published to tableau server for auto refresh extract every day, Developer had data and DB access at that time.
Now the same developer's access for DB is removed, is it possible to get fresh data to reports everyday? will the extract have new data everyday ?
Not unless you update the database credentials published with the data source to be something that the database accepts
You typically want some sort of service account for this purpose - so that the published dashboards still work when the original publisher leaves

Correct Schema design for following application

I am learning MongoDB, Express, React etc and am putting together a simple application to do so but am stuck on the schema design.
The application will be a money manager where users will be able to sign up, then fill in their monthly income (salary and any other income), and regular expenditure. This will provide an amount they are able to spend each month.
The user can then enter transactions throughout the month, the application will log these, which will deplete the monthly allowance to provide the user with a snapshot of their funds available to spend.
I am just stuck on how to structure the schema.
Do I have a separate database for users, expenditure and income, and associate the expenditure and income with the user via the user's _id value?
Or should the expenditure and income be tracked in the same database as the user?