Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ridz1208
Copy link
Collaborator

@ridz1208 ridz1208 commented Mar 5, 2017

The populateage.php tool is completely useless in its current state.

This PR creates a new PHP script that fixes candidate ages.

New functionality has been added:

  • check for null ages
  • check for incorrect ages
  • confirm changes

This tool is designed to fix automatically calculated ages in the databse instrument tables, additional functionality could be added if necessary

@ridz1208 ridz1208 added Release: Breaking changes PR that contains changes that might impact the code or accepted practices of active projects Category: Cleanup PR or issue introducing/requiring at least one clean-up operation Category: Feature PR or issue that aims to introduce a new feature labels Mar 5, 2017
@ridz1208 ridz1208 added this to the 17.1 milestone Mar 5, 2017
@ridz1208 ridz1208 requested review from driusan and gluneau March 5, 2017 21:16
@ridz1208 ridz1208 added the State: Discussion required PR or issue that requires the resolution of a discussion with the relevant parties to proceed label Mar 7, 2017
@mohadesz mohadesz added the State: Needs work PR awaiting additional work by the author to proceed label Mar 10, 2017
@ridz1208 ridz1208 removed the State: Needs work PR awaiting additional work by the author to proceed label Mar 10, 2017
@ridz1208
Copy link
Collaborator Author

Old behaviour was designed for manually populating candidate ages after data-entry.

This script needs testing on large data-sets @gluneau @sruthymathew123 can you please take a look at it ?

@ridz1208 ridz1208 removed the State: Discussion required PR or issue that requires the resolution of a discussion with the relevant parties to proceed label Mar 24, 2017
@sruthymathew123
Copy link
Contributor

@ridz1208: On running the script, I got the below error
PHP Fatal error: Uncaught LorisException: Could not select Candidate data from the database (DCCID: 532110) in /var/www/loris/project/libraries/Candidate.class.inc:61
Stack trace:
#0 /var/www/loris/project/libraries/Candidate.class.inc(36): Candidate->select('532110')
#1 /var/www/loris/php/libraries/TimePoint.class.inc(857): Candidate::singleton('532110')
#2 /var/www/loris/project/instruments/NDB_BVL_Instrument_adi_r_subject.class.inc(72): TimePoint->getEffectiveDateOfBirth()
#3 /var/www/loris/project/instruments/NDB_BVL_Instrument_adi_r.class.inc(73): NDB_BVL_Instrument_adi_r_subject->_getAge()
#4 /var/www/loris/project/instruments/NDB_BVL_Instrument_adi_r.class.inc(61): NDB_BVL_Instrument_adi_r->_setupForm()
#5 /var/www/loris/project/instruments/NDB_BVL_Instrument_adi_r_subject.class.inc(46): NDB_BVL_Instrument_adi_r->_setup('532110UNC000170...', NULL)
#6 /var/www/loris/php/libraries/NDB_BVL_Instrument.class.inc(209): NDB_BVL_Instrument_adi_r_subject->setup('532110UNC000170...', NULL)
#7 /var/www/loris/tools/fix_candidate_a in /var/www/loris/project/libraries/Candidate.class.inc on line 61

@sruthymathew123
Copy link
Contributor

@ridz1208 The above candidate is a not active candidate, but have tables associated with it.

@ridz1208 ridz1208 added the State: Needs work PR awaiting additional work by the author to proceed label Mar 28, 2017
@ridz1208
Copy link
Collaborator Author

@sruthymathew123 I cannot reproduce, lets look at it on your VM ?

@ridz1208
Copy link
Collaborator Author

@driusan @samirdas @LeighMac if a candidate is not active do we care about fixing its candidate_age fields ?

@sruthymathew123
Copy link
Contributor

@ridz. The query in candidate class on line 61 is failing for the above candidate. That is why the script is failing.

@ridz1208
Copy link
Collaborator Author

@sruthymathew123 please re-test

@ridz1208 ridz1208 removed the State: Needs work PR awaiting additional work by the author to proceed label Mar 30, 2017
@sruthymathew123
Copy link
Contributor

@ridz1208

PHP Fatal error: Uncaught Exception: Failed to retrieve data for timepoint (2418) in /var/www/loris/php/libraries/TimePoint.class.inc:142
Stack trace:
#0 /var/www/loris/php/libraries/TimePoint.class.inc(87): TimePoint->select('2418')
#1 /var/www/loris/project/instruments/NDB_BVL_Instrument_adi_r_subject.class.inc(71): TimePoint::singleton('2418')
#2 /var/www/loris/project/instruments/NDB_BVL_Instrument_adi_r.class.inc(73): NDB_BVL_Instrument_adi_r_subject->_getAge()
#3 /var/www/loris/project/instruments/NDB_BVL_Instrument_adi_r.class.inc(61): NDB_BVL_Instrument_adi_r->_setupForm()
#4 /var/www/loris/project/instruments/NDB_BVL_Instrument_adi_r_subject.class.inc(46): NDB_BVL_Instrument_adi_r->_setup('802278SEA013224...', NULL)
#5 /var/www/loris/php/libraries/NDB_BVL_Instrument.class.inc(209): NDB_BVL_Instrument_adi_r_subject->setup('802278SEA013224...', NULL)
#6 /var/www/loris/tools/fix_candidate_age.php(56): NDB_BVL_Instrument::factory('adi_r_subject', '802278SEA013224...', NULL, false)
#7 {main}
thrown in /var/www/loris/php/libraries/TimePoint.class.inc on line 142

@ridz1208
Copy link
Collaborator Author

@sruthymathew123 and now ?

@sruthymathew123
Copy link
Contributor

Sorry @ridz1208

PHP Warning: Missing argument 4 for LorisForm::createElement(), called in /var/www/loris/project/instruments/NDB_BVL_Instrument_edi.class.inc on line 473 and defined in /var/www/loris/php/libraries/LorisForm.class.inc on line 1809
PHP Notice: Undefined variable: options in /var/www/loris/php/libraries/LorisForm.class.inc on line 1822
PHP Notice: Undefined index: DoB in /var/www/loris/php/libraries/NDB_BVL_Instrument.class.inc on line 1984
PHP Notice: Undefined index: Date_taken in /var/www/loris/php/libraries/NDB_BVL_Instrument.class.inc on line 1984
PHP Fatal error: Uncaught Exception: Argument 1 does not match expected date format (YYYY-MM-DD) in /var/www/loris/php/libraries/Utility.class.inc:100
Stack trace:
#0 /var/www/loris/php/libraries/NDB_BVL_Instrument.class.inc(1984): Utility::calculateAge(NULL, NULL)
#1 /var/www/loris/tools/fix_candidate_age.php(82): NDB_BVL_Instrument->getCandidateAge()
#2 {main}
thrown in /var/www/loris/php/libraries/Utility.class.inc on line 100


// Break if Date taken does not exist
if (!$DB->columnExists($inst, 'Date_taken')) {
continue;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should there be an error message printed here?

@ridz1208
Copy link
Collaborator Author

ridz1208 commented Jun 9, 2017

@driusan error added

// get Age from instrument class
$calculatedAge = $instrument->getCandidateAge();
$agemonths = $calculatedAge['year'] * 12 + $calculatedAge['mon'] + ($calculatedAge['day'] / 30);
$calculatedAgeMonths = (round($agemonths*10) / 10.0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@driusan @ridz1208 Glad to see these formulas are the same as in the instrument library.

@ridz1208 ridz1208 added the State: Needs work PR awaiting additional work by the author to proceed label Jun 9, 2017
@ridz1208
Copy link
Collaborator Author

ridz1208 commented Jun 9, 2017

@gluneau could you give it a quick try when you have a minute. I removed the code duplication

@ridz1208 ridz1208 removed State: Needs work PR awaiting additional work by the author to proceed Passed manual tests PR has been successfully tested by at least one peer labels Jun 9, 2017
@ridz1208
Copy link
Collaborator Author

@kongtiaowang HELP MEEEE

@kongtiaowang
Copy link
Contributor

It failed - because this automation test find this
"The following errors occured while attempting to display this page:
The user with name does not exist in the database."

@ridz1208
Copy link
Collaborator Author

@gluneau please re-test quickly, minor changes took place

@driusan
Copy link
Collaborator

driusan commented Jun 27, 2017

Has this been tested in the latest incarnation? It moved from "Needs Testing" without any indication on the PR that that happened..

@ridz1208 ridz1208 added the Passed manual tests PR has been successfully tested by at least one peer label Jun 27, 2017
@driusan driusan merged commit f5107e9 into aces:17.1-dev Jul 4, 2017
@Jkat
Copy link
Contributor

Jkat commented Jul 11, 2018

Thank you 🙏

@ridz1208
Copy link
Collaborator Author

@Jkat believe me MY PLEASURE lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Category: Cleanup PR or issue introducing/requiring at least one clean-up operation Category: Feature PR or issue that aims to introduce a new feature Passed manual tests PR has been successfully tested by at least one peer Release: Breaking changes PR that contains changes that might impact the code or accepted practices of active projects

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants