Timezone calculation in laravel application - database

There are a lot of Geo-device data in my database. The data is stored with the timestamp in UTC which is 5 hours 45 minutes behind in my laravel application.
I have configured the timezone to 'timezone' => 'Asia/Kathmandu', in my config/app.php file.
Now, every time I insert the data I need to subtract the query with 5:45and add 5:45 while sending to the view. Is there any configuration or any other methods that can act as there is no lagging in time?

Related

My Kibana instance randomly will take long times to load data on Kibana index

I am using json script to fetch Okta users data and save in .json files by cronjob till this process working fine.
After this try to load json files data into Kibana index to create visualizations using config files, Starting point data loading working fine randomly after certain period of time loading process getting very slow.
on basis of my observation only 3k to 4k data loaded daily means in 24 hr. .
can anyone please suggest any solution on this ?

How to make my React application automatically make an entry in the database at 00:00 hours (I.E. when its a new day)?

I am using axios in my React App and i have the following code ::-
axios.put(`Dates/${ todaysDate.getFullYear() }/${ this.utilMonthInAlpha(todaysDate.getMonth()) }/${ ( todaysDate.getDate() > 9 ) ? todaysDate.getDate() : '0' + todaysDate.getDate() }/.json` , {
goodHabits : userStoredHabits,
totalScore : '0'
});
The above code is in my componentDidMount lifecycle hook , so everytime the user loads the application the above code is executed, in my google firebase database the entry looks like below:
Now i want the data to be entered for each day of the month irrespective of weather the user accesses my application or not , so how do i go about doing that ? so you can see from the 5th - 9th when the user has not accessed the application the entry is not made, so how do i make my React application automatically make an entry in the database ?
Ideally for example today is the 9th and its around 7:37 PM , so as soon as the clock strikes 00:00 and its the 10th i would like my application to automatically make an entry into the database, how do i do this ?
On the server
If you want your database to be updated while your user is not using your app, you will have to run something on a server to update it.
You could use a Cloud Function that updates your database in response to an hourly Cloud Pub/Sub trigger.
You could store the users' time zones and execute the database updates from the function only when the hourly job is run closest to midnight in the user's time zone.
Setting up cron jobs can be done using the functions-cron package. The readme includes instructions on setting up an hourly job.
https://github.com/FirebaseExtended/functions-cron
In the app
Does it really matter for your app that the database gets updated every day at midnight? Perhaps your app can query the database when it is opened, and check which updates have been missed, and send them all to the database then.

How to ensure that the data pulled by Prometheus is up-to-date and does not include old data before the pull interval

The Prometheus interval pulls data from the pushgateway. The pushgateway uses the “-persistence.file string” data persistence parameter configuration. The client sends data to the pushgateway in real time.
If Prometheus pulls data within the time interval. Pushgateway did not
receive data from the client. What happens when Prometheus pulls data
from the pushgateway interval?
Will Prometheus pull old data outside the time interval, and then take the pull time as the time of the old data?
Prometheus will judge according to the pull time interval, pushgateway no new data during this period, and then pull the data is empty?
Still have other results
The Pushgateway will always serve the most recent push to it (if any) for a group. If you care about only getting very recent data then the pushgateway is not right for your use case (see https://prometheus.io/docs/practices/pushing/).
What you probably want to do is use direct instrumentation, and have Prometheus scrape your applications directly.

Node.JS & Socket.IO - Prioritise / Pause & Resume

I am building a real time application using AngularJS, NodeJS & Socket.IO. The application facilitates 3-4 large tables which are populted from a MongoDB database and after the initial load they only get updated.
Each table store almost 15-30Mb of data and it takes about 30 seconds to populate them using Socket.IO . Now, if a user navigates to a different page before all data is downloaded, the data required by the new page stays in the queue and is received after the table from the first page populates in full. Is there a way to pause or cancel the request when navigating to a different page?
Thanks in advance for your help.
--- Edit ---
To make the question more clear, here is the process that a user might follow:
The User opens /index and Grid_1 starts loading with Data from the server using Socket.IO. The data is coming in chunks of 50 records at the time. Grid_1 will eventualy get populated with 15.000 records and it will take 30 to download all the data.
After the user waits at /index for 10 secords, he decides to visit /mySecondPage where there is Grid_2 which simillar with Grid_1 populates from the database with 15.000 records which takes 30 seconds to download - again using Socket.IO. Since the user switched from /index to /mySecondPage before the data is populated in Grid_1, Grid_2 is not populated with data before Grid_1's data is fully downloaded. Hope that made it more clear?

How to update backbone model from database

I am creating a webpage to show the listing from my database table,
suppose my database table is updating in every 10 second from my php cron , then i want to sync my backbone model/collection whenever my database table get update from my php cron.
Example:- i have table stock_exchange in which i am storing the stocks rate for various companies, and my cronjob update the stocks rate in every 10 second, To show this on UI i am creating the backbone application but my problem is that whenever my table stock_exchange updated i want to sync my backbone model/collection.
Please help,
Thanks in advance
You can either poll the server by calling stockModel.fetch() every 10 seconds in the browser (via setInterval perhaps), or you can use something like web sockets (via socket.io perhaps) to allow the server to push the latest data to the browser, which you can then do stockModel.set(dataFromServer);. Try something and post some code as stack overflow is intended for specific problems not tutorials.

Resources