Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions SOLUTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,39 @@ SOLUTION

Estimation
----------
Estimated: n hours
Estimated: 6 hours

Spent: x hours
Spent: 7 hours


Solution
--------
Comments on your solution
ReportYearlyCommand exposes command for yearly report of views per profile.
Added functionality to specify year by command line.

Added PRIMARY KEY and auto_increment to profiles.profile_id and FOREIGN KEY to views.profile_id. Additional SQL needed:

``` SQL
ALTER TABLE profiles ADD PRIMARY KEY (profile_id);
ALTER TABLE profiles MODIFY profile_id int(11) NOT NULL auto_increment;
ALTER TABLE views
ADD CONSTRAINT views_profiles_profile_id_fk
FOREIGN KEY (profile_id) REFERENCES profiles (profile_id);
```


Future ideas
------------
What could have been done better:
- Using Doctrine ORM with entities and native Doctrine repositories
- ProfilesRepository could return []Profile
- Private methods ReportYearlyCommand::pivotData and ReportYearlyCommand::fillEmpty could be set public static and moved to separate utils if needed. Personally I did not find it necessary because there would be too many parameters passed and would make code less readable for single use case


Possible test cases
-------------------
- No year passed but no error is shown
- Year is of invalid type but no error is shown
- No historical data but no error is shown
- Profiles are not alphabetically listed
- Empty columns do not have 'n/a'
6 changes: 5 additions & 1 deletion app/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ services:
database_connection:
class: \Doctrine\DBAL\Driver\Connection
factory: [\Doctrine\DBAL\DriverManager, getConnection]
arguments: [{url: 'mysql://bof-test:bof-test@127.0.0.1/bof_test'}, '@database_configuration']
arguments: [{url: 'mysql://bof-test:bof-test@127.0.0.1/bof_test'}, '@database_configuration']

repository.profiles:
class: \BOF\Repository\ProfilesRepository
arguments: ['@database_connection']
Loading