結對第二次作業
| 這個作業屬於哪個課程 | 2021春軟件工程實踐S班 |
|---|---|
| 這個作業要求在哪里 | 作業要求 |
| 這個作業目標 | 實現論文增刪改查,網絡爬蟲 |
| 其他參考文件 | 《構建之法》 |
目錄
作業描述
Github倉庫地址
PSP表格:
| PSP2.1 | Personal Software Process Stages | 預估耗時(分鍾) | 實際耗時(分鍾) |
|---|---|---|---|
| Planning | 計划 | ||
| • Estimate | • 估計這個任務需要多少時間 | 30 | 60 |
| Development | 開發 | ||
| • Analysis | • 需求分析 (包括學習新技術) | 300 | 240 |
| • Design Spec | • 生成設計文檔 | 30 | 10 |
| • Design Review | • 設計復審 | 30 | 10 |
| • Coding Standard | • 代碼規范 (為目前的開發制定合適的規范) | 30 | 20 |
| • Design | • 具體設計 | 120 | 60 |
| • Coding | • 具體編碼 | 1200 | 1400 |
| • Code Review | • 代碼復審 | 60 | 20 |
| • Test | • 測試(自我測試,修改代碼,提交修改) | 30 | 60 |
| Reporting | 報告 | ||
| • Test Report | • 測試報告 | 30 | 10 |
| • Size Measurement | • 計算工作量 | 20 | 20 |
| • Postmortem & Process Improvement Plan | • 事后總結, 並提出過程改進計划 | 30 | 30 |
| 合計 | 1910 | 1940 |
雲服務器的訪問鏈接:http://www.wuzinian.top:88/
展示成品:
數據庫表結構:



結對討論過程:
1.剛開始看到題目的要求,還是比較迷茫的,因為我們都沒有前端設計的經驗(准確的說是從來沒做過前端),部署到雲服務器也是第一次聽說。但是心里也沒有很慌,因為時間還比較久,可以邊學邊做。
2.然后就是分工問題,因為分工明確的話可以快速確定學習方向,我(宋)同學決定試試前端設計,王同學決定設計后端。
3.后端實現使用PHP,因為宋同學沒選JAVAEE,所以用我們都會的PHP。
4.前端一開始因為原型設計時設計的比較簡單,想自己寫HTML,CSS,JAVASCRIPT這些來實現界面,發現自己水平還是不夠,設計的不好看,然后去看BootStrap的官方文檔。邊學邊做。
功能結構圖:


代碼說明:
public static function getPapers(string $title = null,
string $keyword,
string $year = null, string $forum = null,
string $id = null) : array
{
$sqlSelect = "select paper.id, paper.title, paper.abstract, paper.link, paper.year, paper.forum ";
$sqlTables = "from paper ";
if ($keyword != null)
$sqlTables .= ", keyword_paper, keyword ";
$sqlWhere = "where 1 = 1 ";
if ($id != null)
$sqlWhere .= "and paper.id = $id ";
if ($title != null)
$sqlWhere .= "and title like '%$title%' ";
if ($year != null)
$sqlWhere .= "and year = $year ";
if ($forum != null)
$sqlWhere .= "and forum = '$forum' ";
if ($keyword != null)
{
$sqlWhere .= "and paper.id = keyword_paper.paperid and keyword_paper.keyid = keyword.id and keyword.keyword = '$keyword' ";
}
$sqlCount = "select count(*) as count ".$sqlTables.$sqlWhere.";";
$sqlSearch = $sqlSelect.$sqlTables.$sqlWhere."limit 1000".";";
$result = array();
$con = DbUtil::getConnection();
if ($con->multi_query($sqlCount.$sqlSearch))
{
$rs = $con->store_result();
$result['total'] = $rs->fetch_row()[0];
$rs->free();
$con->next_result();
$rs = $con->store_result();
$papers = array();
while ($row = $rs->fetch_assoc())
{
$paper = Paper::InstancePaperFromRow($row);
$paper->keywords = KeywordDao::getKeywordsByPaperID($paper->id);
array_push($papers, $paper);
}
$result['papers'] = $papers;
}
return $result;
}
根據標題,關鍵詞,年份,論壇綜合搜索。
static public function getTop10Keywords()
{
$sql = "select * from keyword order by count desc limit 10";
$con = DbUtil::getConnection();
$rs = $con->query($sql);
$popularWords = array();
while ($row = $rs->fetch_assoc())
{
$keyword = $row['keyword'];
$count = intval($row['count']);
$popularWords[$keyword] = $count;
}
return $popularWords;
}
統計出現次數前十的關鍵詞。
public static function renderWords($popularWords)
{
echo '<ul class = "cloud">';
$i = 10;
foreach ($popularWords as $word => $count)
{
echo '<li><a data-weight="'.$i.'" href = "/?keyword='.urlencode($word).'">'.$word.'</a></li>';
$i--;
}
echo '</ul>';
}
ul.cloud {
list-style: none;
padding-left: 0;
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
line-height: 2.5em;
}
ul.cloud a {
color: #a33;
display: block;
font-size: 1.5em;
padding: 0.125rem 0.25rem;
text-decoration: none;
position: relative;
--size: 4;
font-size: calc(var(--size) * 0.25rem + 0.5rem);
color: var(--color);
}
ul.cloud a[data-weight="1"] { --size: 1; }
ul.cloud a[data-weight="2"] { --size: 2; }
ul.cloud a[data-weight="3"] { --size: 3; }
ul.cloud a[data-weight="4"] { --size: 4; }
ul.cloud a[data-weight="5"] { --size: 5; }
ul.cloud a[data-weight="6"] { --size: 6; }
ul.cloud a[data-weight="7"] { --size: 7; }
ul.cloud a[data-weight="8"] { --size: 8; }
ul.cloud a[data-weight="9"] { --size: 9; }
ul.cloud a[data-weight="10"] { --size: 10; }
ul.cloud li:nth-child(2n + 1) a { --color: #181; }
ul.cloud li:nth-child(3n + 1) a { --color: #33a; }
ul.cloud li:nth-child(4n + 1) a { --color: #c38; }
ul.cloud a:hover {
outline: 1px dashed;
}
ul.cloud a::before {
content: "";
position: absolute;
top: 0;
left: 50%;
width: 0;
height: 100%;
background: var(--color);
transform: translate(-50%, 0);
opacity: 0.15;
transition: width 0.25s;
}
ul.cloud a:focus::before,
ul.cloud a:hover::before {
width: 100%;;
}
將排前十的關鍵詞顯示為標簽雲。
static public function getTrendOfPopularWords()
{
$forums = ['ECCV', 'CVPR', 'ICCV'];
$keywords = array();
foreach ($forums as $forum)
{
$sql = 'select keyword from paper, keyword_paper, keyword
where paper.id = keyword_paper.paperid and keyword.id = keyword_paper.keyid
and forum = "'.$forum.'"
group by keyword
order by count(keyword) desc limit 1;';
$con = DbUtil::getConnection();
$result = $con->query($sql);
array_push($keywords, $result->fetch_array()[0]);
}
$statistics = array();
for ($i = 0; $i < sizeof($keywords); $i++)
{
$sql = "select count(year) as count, year as num from keyword, keyword_paper, paper
where keyword.id = keyword_paper.keyid and keyword = '".$keywords[$i]."' and paper.id = keyword_paper.paperid and forum = '".$forums[$i]."'
group by year;";
$result = $con->query($sql);
$yearCount = array();
while ($row = $result->fetch_array())
{
$year = $row[1];
$count = intval($row[0]);
$yearCount[$year] = $count;
}
$stat = ['forum' => $forums[$i], 'keyword' => $keywords[$i], 'statistics' => $yearCount];
array_push($statistics, $stat);
}
return $statistics;
}
統計每個定會中出現最多的關鍵詞,並統計這些關鍵詞每年出現的次數。
series : [
<?php
foreach ($result as $forum)
{
echo "{";
echo "name: '".$forum['forum']."--".$forum['keyword']."',";
echo "type: 'line',";
echo "data:[";
for ($i = 2016; $i < 2020; $i++)
if (array_key_exists(strval($i), $forum['statistics']))
echo $forum['statistics'][strval($i)].",";
else
echo "0,";
echo "]";
echo "},";
}
?>
將結果用echart顯示出來。
function ondelete(ob){
var child = ob.parentElement.parentElement.parentElement;
var parent = child.parentElement;
parent.removeChild(child);
}
搜索界面上的刪除
心路歷程和收獲:
只要思想不滑坡,辦法總比困難多。一開始還是比較困難的,因為很多東西都不會,但是我們都對學習新事物很開心。
宋:了解了前端的各種框架,學習了bootstrap框架,學習與后端的交互,學過PHP,但是是第一次用PHP寫程序,對PHP更熟悉了。
王:對PHP和數據庫查找增加了掌握度,學習了搭建到服務器上。
評價隊友:
宋:王同學和我一樣,做事情比較細心,我們都不會計較誰做的多誰做得少,因為做的多肯定收獲多,所以我們都盡可能的多做點,合作很舒服。
王:宋同學認真負責,積極學習前端的技術,有問題積極和我交流,合作的很愉快。
