Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I am creating an assistant bot in javascript and I want to support reminders, my problem is that it need to support both short timeouts (10 mins) and long timeouts (a month).
To my understanding using the setTimeout() functions wouldn't work for the long timeout, so I thought of using a lookup table and check it every second, but that would be heavy on resources.
I wanted to know if the lookup table it the best option (as far as performance is concerned) and if so whether there are best practices to follow.
I would create a function prepareNextReminders(time_in_minutes, callback) that retrieves reminders in the next X minutes, e.g. one hour. For each of them, creates a setTimeout with the callback and the proper delay and adds the id to a list of prepared reminders.
This function runs every 15 minutes and in each run does the same for the new reminders not already existing in the list of prepared reminders.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 10 months ago.
The community reviewed whether to reopen this question 10 months ago and left it closed:
Original close reason(s) were not resolved
Improve this question
I have an application that users can use it 14 days without paying. However, after 14 days users will not be able to use the application unless s/he pays for it.
I don't know how to track the remaining time for the free trial. I'm thinking of setting an cronjob 14 days later when the users is created but I think it is a bit hard to manage (?).
The second thought would be checking the remaining time for every user at a specific time every day but timezone and server loading might be problem in this case.
I'm using MongoDB and Node.js for back-end and HTML, CSS, JS for front-end. How can I design my database and code to overcome this problem?
Thanks in advance.
I believe this question have enough detail please warn before closing.
You could possible save time of register of user and then every time on request of users that don't pays calculate the remaining time?
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I have a background process that collects all the users from MongoDB, and do certain checks and processing on their accounts; This happens daily at midnight. My questions are:
Is it a good practice (in terms of performance) to do this:
db.users.find()
to retrieve all the users, or this might slow down the DB and it's advisable to
follow some other practice?
Is it safe to do it on a master node?
PS This happens daily on a number of users close to 100K users
MongoDb is not a single-thread database, your operation is run in a thread.
What you need to pay attention is set timeout to find operation.
eg.
db.users.find(timeout=false)
Otherwise, you will get a expired cursor exception after a period of time
There is another way to avoid long-time cursor, you query one document every time, and query next document by
db.users.findOne({_id: {$gt: old_id}})
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have 100000 records in my database with 10 column
which are int, float
My question
I want to perform paging, search & sorting operation on this data.
I think i have two option.
either using Ajax request for each call or retrieve all data at time,perform operations like search, sort
suggest any better solution.
NOTE: Im using Meteor.js and numbtel:mysql package
Better you can try bootstrap framework(data tables). it can easily to integrate for large number of rows
including the DataTables Bootstrap files (CSS and JS)
You have two ways to perform the task:
Use jQuery Data table if you are retrieving all the records at once.
--
If you follows this technique it will increase the loading time. It is consider better for less no of records. more more records it takes time on first time.
If you have less time for development then "Datatable is best". It already has all the feature you are looking for.
Second way is "ajax", it is a bit time taking. you have to code separately for
search
pagination etc.
So it all depends on time of development and type of app you are going to develop.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Here is my goal:
Create some JavaScript action (some function call) that will be timed perfectly between two different clients.
Explanation:
I want a function to be called exactly on the same millisecond on two different browsers/computers no matter when the client accessed the web page.
I thought about creating a time base using the server time but im not sure this will work.
I think you should be using something Node.JS or APE (Ajax Push Engine) to achieve this.
so you want to do like this scenario: user come visit your webpage and he has to wait few seconds that page is shown?
This is useless to do in my opinion, unless you want to flood server with tons of requests..
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Right, i honestly have no idea what to even search to find this out! i have searched many phrases trying to find out and i keep coming back with nothing.
I have a client who has asked if it is possible to have a number like 2.00000000 and have it constantly going up at a variable speed. The task he wants is to have is for different users to have a number that keeps going up (for what reason i don't know, i said ill look into it for him to find out if there is a plugin or something).
But either way he wants it to b able to even while the user is offline the value still continues to go up.
Is there such a plugin to achieve this? cheers
If it is at variable speed couldn't he just check the date time at which he initialize the sequence and compare it to the time at which he checks the number. The difference in time would be that offset he would call variable speed
For example if he wanted the number to increase 10 every 24 hours then:
double intialTimeInSeconds = //Whatever the Start time would be
double amountGainedEverySecond = 24/10/60/60;
double nowTime = //whatever time it is now;
return (nowTime - initialTimeInSeconds)*amountGainedEverySecond;