// create crawl
$request = $peggy->crawl()->createCrawlRequest($crawlName, $appName, $urllist, $maxDepth, $maxUrls);
$peggy->crawl()->create($request);
// get crawl
$crawl = $peggy->crawl()->get($crawlName);
echo $crawl->getName();
// cancel crawl
$peggy->crawl()->cancel($crawlName);
// get all crawls
$allCrawls = $peggy->crawl()->all();
foreach ($allCrawls as $crawl) {
echo $crawl->getName();
}
Results
// get result
$result = $peggy->result()->get($crawlName);
$urls = $result->getUrls(); // Returns the results of the crawl specified by CRAWL_NAME. This will return a 404 if no results have been posted. Example Url: "http://s3.amazonaws.com/results1"
Apps
// upload app
$request = $peggy->app()->createAppRequest($name, $filePath);
$peggy->app()->upload($request);
// get app
$app = $peggy->app()->get($appName); // this API is broken on 80legs.com
// remove app
$peggy->app()->remove($appName);
// get all apps
$allApps = $peggy->app()->all();
foreach ($allApps as $app) {
echo $app->getName();
}
Url Lists
// create url list
$request = $peggy->urllist()->createUrllistRequest($name, $filePath);
$peggy->urllist()->upload($request);
// get url list
$urllist = $peggy->urllist()->get($name);
echo $urllist->getName();
// remove url list
$peggy->urllist->remove($name);
// get all url lists
$allUrllists = $peggy->urllist()->all();
foreach ($allUrllists as $urllist) {
echo $urllist->getName();
}
User
// get me
$me = $peggy->user()->me();
// get user
$user = $peggy->user()->get($token);
DocumentaryWIRE is a website dedicated to documentaries. Our mission is to help people find and share documentaries they love. http://www.documentarywire.com/
DocumentaryWIRE was built using the following technologies:
Using a PHP Framework called Symfony2, I am developing a web application for people who play the video game Fifa to compete against each other in an online competition. It’s on Github: https://github.com/JonnyD/Elite-Fifa-Leagues
In the picture above you can see the UI of the league standings.
These values are calculated and stored in a Standings table after every
confirmed match. There’s a problem with this and that is storing
calculated values breaks normalization. The only time this could be
acceptable is in cases where you want to improve performance by not
having to re-calculate the values every time you need them.
However, what if I want to find out a teams standing by their Last X
Games Played at Home, Last X Games Played Away, or Last X Games Played
Combined?
Here’s how I could get Standings by home matches only:
SELECT team.name, home_team_id AS team_id,
COUNT(*) AS played,
SUM((CASE WHEN home_score > away_score THEN 1 ELSE 0 END)) AS won,
SUM((CASE WHEN away_score > home_score THEN 1 ELSE 0 END)) AS lost,
SUM((CASE WHEN home_score = away_score THEN 1 ELSE 0 END)) AS drawn,
SUM(home_score) AS goalsFor,
SUM(away_score) AS goalsAgainst,
SUM(home_score - away_score) AS goalDifference,
SUM((CASE WHEN home_score > away_score THEN 3 WHEN home_score = away_score THEN 1 ELSE 0 END)) AS points
FROM matches
INNER JOIN team ON matches.home_team_id = team.id
WHERE league_id = 94
AND season_id = 82
AND confirmed IS NOT NULL
GROUP BY home_team_id
ORDER BY POINTS DESC;
Here’s how I could get Standings by Away matches only:
```
SELECT team.name, away_team_id AS team_id,
COUNT(*) AS played,
SUM((CASE WHEN away_score > home_score THEN 1 ELSE 0 END)) AS won,
SUM((CASE WHEN home_score > away_score THEN 1 ELSE 0 END)) AS lost,
SUM((CASE WHEN home_score = away_score THEN 1 ELSE 0 END)) as drawn,
SUM(away_score) AS goalsFor,
SUM(home_score) AS goalsAgainst,
SUM(away_score - home_score) AS goalDifference,
SUM((CASE WHEN away_score > home_score THEN 3 WHEN away_score = home_score THEN 1 ELSE 0 END)) AS points
FROM matches
INNER JOIN team ON matches.away_team_id = team.id
WHERE league_id = 94
AND season_id = 82
AND confirmed IS NOT NULL
GROUP BY away_team_id
ORDER BY points DESC;
Here’s how I could get Standings by Home and Away matches combined:
SELECT team.name,
team_id AS team_id,
COUNT(*) AS played,
SUM((CASE WHEN team_score > other_team_score THEN 1 ELSE 0 END)) AS won,
SUM((CASE WHEN team_score < other_team_score THEN 1 ELSE 0 END)) AS lost,
SUM((CASE WHEN team_score = other_team_score THEN 1 ELSE 0 END)) AS drawn,
SUM(team_score) AS goalsFor,
SUM(other_team_score) AS goalsAgainst,
SUM(team_score - other_team_score) AS goalDifference,
SUM((CASE WHEN team_score > other_team_score THEN 3
WHEN team_score = other_team_score THEN 1
ELSE 0 END)) AS points
FROM
(
-- LIST TEAM STATS WHEN PLAYED AS HOME_TEAM
SELECT
id,
league_id,
season_id,
home_team_id as team_id,
home_score as team_score,
away_score as other_team_score,
confirmed
FROM matches
UNION ALL
-- LIST TEAM STATS WHEN PLAYED AS AWAY_TEAM
SELECT
id,
league_id,
season_id,
away_team_id as team_id,
away_score as team_score,
home_score as other_team_score,
confirmed
FROM matches
) matches
INNER JOIN team ON matches.team_id = team.id
WHERE league_id = 94
AND season_id = 82
AND confirmed IS NOT NULL
GROUP BY team.name, team_id
ORDER BY POINTS DESC;