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
8 changes: 5 additions & 3 deletions SOLUTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ SOLUTION

Estimation
----------
Estimated: n hours
Estimated: 8 hours

Spent: x hours
Spent: 7 hours


Solution
--------
Comments on your solution

I will make tables with different collumn name and with "timestamp" instead "date". Also I will make third table, and from that table I will send report in console. This table will be agregate data from first and second table.

25 changes: 23 additions & 2 deletions src/Command/ReportYearlyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use DB;

class ReportYearlyCommand extends ContainerAwareCommand
{
Expand All @@ -24,9 +25,29 @@ protected function execute(InputInterface $input, OutputInterface $output)
$db = $this->getContainer()->get('database_connection');

$profiles = $db->query('SELECT profile_name FROM profiles')->fetchAll();

//make result for only one date in
$views = $db->query('SELECT views.date, views.views, profiles.profile_name FROM views INNER JOIN profiles ON profiles.profile_id=views.profile_id WHERE date = "2014/09/01" GROUP BY date, views, profile_name')->fetchAll();

// Show data in a table - headers, data
$io->table(['Profile'], $profiles);
//make result for only one date and one user
$oneUsers = $db->query('SELECT views.date, views.views, profiles.profile_name FROM views INNER JOIN profiles ON profiles.profile_id=views.profile_id WHERE date = "2014/09/01" AND profile_name = "Tom Ford" GROUP BY date, views, profile_name')->fetchAll();

//make result for only one year and for one user
$oneYear = $db->query('SELECT views.date, views.views, profiles.profile_name FROM views INNER JOIN profiles ON profiles.profile_id=views.profile_id WHERE DATE_FORMAT(date, "%Y") = "2014" AND profile_name = "Sandra Choi" GROUP BY date, views, profile_name')->fetchAll();

//make result for only one month, for one user in each year
$oneMonth = $db->query('SELECT views.date, views.views, profiles.profile_name FROM views INNER JOIN profiles ON profiles.profile_id=views.profile_id WHERE DATE_FORMAT(date, "%m") = "02" AND profile_name = "Sandra Choi" GROUP BY date, views, profile_name')->fetchAll();

//make result between date for each profile_name
$oneMonthYear = $db->query('SELECT views.date, views.views, profiles.profile_name FROM views INNER JOIN profiles ON profiles.profile_id=views.profile_id WHERE date >= "2014/09/01" AND date < "2014/09/25" GROUP BY date, views, profile_name')->fetchAll();


// Show data in a table - headers, data
$io->table(['Date', 'Views', 'Profile_name'], $views);
$io->table(['Date', 'Views', 'Profile_name'], $oneUsers);
$io->table(['Date', 'Views', 'Profile_name'], $oneYear);
$io->table(['Feb', 'Views', 'Profile_name'], $oneMonth);
$io->table(['Date', 'Views', 'Profile_name'], $oneMonthYear);

}
}