-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[configuration] Add date_format as DataType in ConfigSettings #6719
[configuration] Add date_format as DataType in ConfigSettings #6719
Conversation
@jesscall this is failing Travis |
@jesscall The way I understand it, the casing of the I think the proper fix to the reported issue would be to throw a configuration error in the config module if you choose a date different then the only 2 supported formats OR to change that configuration field to a drop down and progressively add formats to it as we move forward. |
@ridz1208 @jesscall something like https://www.php.net/manual/en/datetime.format.php might be useful for converting to the correct format. |
@CamilleBeau ready for review [Notes]:
[Testing]:
|
SQL/New_patches/2020_06_16_Add_Date_Format_to_ConfigSettings_DataType.sql
Show resolved
Hide resolved
In general the way we display the date shouldn't impact what is saved in the database. The logic should be decoupled. A user can enter a year, month and day on the front-end and we can drop the day value if necessary when it goes into the database. When we display the date, we can show or hide to whatever resolution we want. As @maltheism suggested, this would be easier with DateTime objects. We can use them to validate date formats or easily replace just the date value. It's a more robust way than working with strings. There's also the config setting Alternatively - I'm not sure if it's important for the DoD and DoB formats to be different. Could they both instead use |
@johnsaigle the way we save the data does impact the display. Users get confused when they can select a day but it defaults to 01 after saving. The display should clearly show that you are selecting a whole month at a time |
@ridz1208 maybe the user's "format" of the date should be saved in the database and used for the standardized date in the database to be reverted to the correct format for the user on the frontened. |
@ridz1208 I think we're saying the same thing. We should save whatever the user enters but display it with either the day chopped off or with |
@johnsaigle the issue with saving the full date in the DB and then only displaying the day as Re: not having a day field displayed at all: I'm open to hearing your opinions as well. |
@jesscall @johnsaigle @ridz1208 I think having the actual day is important in keeping things consistent. Although, I doubt having the correct day of the month when a person died compared to a few days off is really valuable. It's probably better to not fake a day from the software side of LORIS. Why not just force the configuration module for DOB & DOD Format to always have "d" in the input field and an input error is displayed if otherwise. You could use regex. Maybe there should be a field for notes and where if the day isn't known the study admin would just add a note. |
@maltheism those are ethics regulated requirements, some projects are not allowed to save the day of the date of birth because it's identifiable |
@ridz1208 hmm if that's the case maybe there should be two more date columns in database. Someone that's born in the 1st of whatever month and dies on the 1st of whatever month. Wouldn't be happy if they were in the ethical study. |
@maltheism the idea is that we can't store the actual values in the database just like we can't store names and addresses |
@ridz1208 the ethics_dod or ethics_dob could be scrambled and the actual_dob & actual_dod would be left null depending on if it's an ethical study. Edit: Maybe jess's solution is best after all if the person managing the study doesn't care about the date being accurate. |
@CamilleBeau I suspect the data truncation is happening because of the note i left about existing projects having different values than the preset formats. Should be solved by running the last 4 queries in the patch submitted. |
SQL/New_patches/2020_06_16_Add_Date_Format_to_ConfigSettings_DataType.sql
Outdated
Show resolved
Hide resolved
e223309
to
ebf0301
Compare
@jesscall travis |
Getting |
@@ -61,6 +61,12 @@ class Configuration extends \NDB_Form | |||
$scan_types[$val] = $val; | |||
} | |||
|
|||
$date_format = [ | |||
'' => '', | |||
'Ymd' => 'Ymd', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would be a good idea to show a more descriptive label for these on the frontend since it's a dropdown now?
Like 2015-12-29 (Ymd)
and 2015-12 (Ym)
?
(Date is arbitrary, just something that's unambiguous with the day of the month > 12.. I'm assuming m is numeric month, I haven't looked into it, but it would avoid that type of confusion for users to provide an example in the dropdown label..)
) Add "date_format" config format type for DoB and DoD, which configures whether day of month is included in date. Resolves aces#6678
) Add "date_format" config format type for DoB and DoD, which configures whether day of month is included in date. Resolves aces#6678
Brief summary of changes
Quick fix for candidate parameter tabs
Date of Birth
andDate of Death
. Altering the DOB format or the DOD format fields in the configuration module to eitherYM
orYm
should result in the dates in cand param being saved withYYYY-MM-01
as the day of the month rather than whatever the user entered.Edit:
This PR now adds a new dataType to ConfigSettings:
date_format
. Fields such as DOB and DOD format will now have a dropdown in which users that select what format they prefer. This should also resolve the ambiguity in candidate parameters that is discussed in the thread below.Testing instructions (if applicable)
Link(s) to related issue(s)