How to avoid the "Z" in my PostgreSQL datetime - reactjs

I am using the material-UI to select a date and store it in a SQL Database. When I send the date to the DB it is in this format "YYYY-MM-DDTHH:MM" for example "2017-05-24T10:30". However when I fetch the dates from the DB they come out like this "YYYY-MM-DDTHH:MM:SS.000Z" for example "2019-06-14T10:30:00.000Z"
Now I am using a calendar package called FullCalendar, which interprets the "Z" as -5H. So all of the dates on my calendar are moved back 5H. The really bazaar thing is that this only happens when the app is deployed on Heroku. If I run the app locally and try to fetch the dates the database is automatically adding 5H to the times to compensate for the "Z" and the dates are displayed correctly on the calendar.
I'm looking for a solution to either get rid of the "Z" or make the heroku and local app deployments consistent.
I'm not sure if there is any relevant code to include here. The POST and GET methods to the DB are pretty standard. Let me know if I can add anything that might be of use.

Without more information, this will be the easy solution (not the best):
SELECT LEFT(cast('2019-06-14T10:30:00.000Z' AS varchar),16)
Result: "2019-06-14T10:30"
Look at these functions for better answers in terms of performance: AT TIME ZONE, date_trunc
https://www.postgresql.org/docs/9.1/functions-datetime.html

Related

users and expiration date

I have a question that I hope someone can help me with, I would like to be able to search for how many paying members my website has at a specific date.
They belong to their own role "members" and there is an expiration date for each member. If they do not have an expiration date, they should also be listed.
Should I be able to use 2sxc module for this and would anyone tell me how to do?
You would need to have an intermediate understanding of SQL and the tables/fields related to the results you are trying to achieve. Though it is possible to get done in 2sxc, I would recommend starting the effort the DNN Reports module. That should let you focus on getting the results you need in the SQL Query first (since the display part is auto/default. Then, once you have the right query, you could move it over to 2sxc (or any module that allows data to be queried and returned as a result (set)) and do something more useful.

How to get Web2py Table Migration in Google App Engine to work?

I've been using web2py for a few years, but just starting with deploying to GAE.
I was able to get a simple web2py application running on GAE, then made some modifications which included schema modifications. I started getting weird errors (an insert failed because a field needed to be a float, when it was explicitly set to be a float constant), and it looks like the schema modifications were not carried out in GAE -- a check of the datastore shows entities w/ the old schema (for example, my problematic float-field is missing). These migrations worked fine locally (using SQLite).
settings.migrate is set to True, and all tables have migrate set to that value.
Not sure what code I could provide that would be helpful; all define_table calls are pretty standard.
As for the question(s):
What, if anything, do I need to do to make these migrations work? If it involves removing the current Entities for my tables (so new ones, with the right schemas, can be created), how would I go about doing that? (My Datastore Admin page is completely blank.) Might this be related to the fact that trying to truncate a table on GAE fails?
The problem was solved by changing the new fields from floats to doubles; not sure where (web2py or GAE, or the interface between the two) the issue w/ floats came from, but this was an easy way to route around it.

Implementing project newsfeed for Google App Engine

I am think about something like Github/Bitbucket news feed in main screen.
There are multiple users(tens or thousands) watching multiple projects(tens or hundreds). Each project would has it's latest update status message.
The combined result would looks like:
Project A: issue #3 change from opened to closed
Project B: #someuser commented on issue #231
Project C: #anotheruser opened issue #1493
Project B: #thirduser commented on issue #231
When using SQL, I would think about something like
select * from notifi where projId in (<user's watching list>)
But for GAE this is implemented as making multiple queries in the same time. This is not going to be efficient. And it won't work for users watching more than 30 projects (can not do more than 30 queries in the same time according to https://developers.google.com/appengine/docs/python/datastore/gqlreference).
How could I implement something similar?
Keep a model that contains the project's list of changes and update that. Subscribe users to that, and everybody get's the same update, subtracting updates they made themselves before sending the update to the user. So one query per project, results send to all subscribed users. So you don't do the "select" on a user basis, rather a project.
Or just try something then optimise it using the available tools. And use NDB!

Cakephp date input issue

I not 100% sure why this is happening, however, the issue I am having is that I have a very simple date input which works perfectly fine on my home server (generates a dropdown list of Years, Months, Days). When I upload it to a remote server, an input field appears instead of a dropdown.
On the remote server I have tried both DATE and DATETIME fields in the database both producing the same results.
Here is the basic code:
echo $this->Form->input('event_date');
The version of cake is 1.3 (if that makes any difference).
Just remove all the files in your app/tmp directory.
Cakephp will take the structure of tables to the cache.
Whenever you are making changes to database table structure, you have to clear the cache.

Web-App : Keeping trace of the version of the application in database?

We are building a webapp which is shipped to several client as a debian package. Each client runs his own server. But the update and support is done by us.
We make regular releases of the product, with a clean version number. Most of the users get an automatic update (by Puppet), some others don't.
We want to keep a trace of the version of the application (in order to allow the user to check the version in an "about" section, and for our support to help the user more accurately).
We plan to store the version of the code and the version of the base in our database, and to keep the info up to date automatically.
Is that a good idea ?
The other alternative we see is a file.
EDIT : The code and database schema are updated together. ( if we update to version x.y.z , both code and database go to x.y.z )
Using a table to track every change to a schema as described in this post is a good practice that I'd definitely suggest to follow.
For the application, if it is shipped independently of the database (which is not clear to me), I'd embed a file in the package (and thus not use the database to store the version of the web application).
If not and thus if both the application and the database versions are maintained in sync, then I'd just use the information stored in the database.
As a general rule, I would have both, DB version and application version. The problem here is how "private" is the database. If the database is "private" to the application, and user never modifies the schema then your initial solution is fine. In my experience, databases which accumulate several years of data stop being private, it means that users add a table or two and access data using some reporting tool; from that point on the database is not exclusively used by the application any more.
UPDATE
One more thing to consider is users (application) not being able to connect to the DB and calling for support. For this case it would be better to have version, etc.. stored on file system.
Assuming there are no compelling reasons to go with one approach or the other, I think I'd go with keeping them in the database.
I'd put them in both places. Then when running your about function you quickly check that they are both the same, and if they aren't you can display extra information about the version mismatch. If they're the same then you will only need to display one of them.
I've generally found users can do "clever" things like revert databases back to old versions by manually copying directories around "because they can" so defensively dealing with it is always a good idea.

Resources