mirror of
https://github.com/btdig/dhtcrawler2.git
synced 2025-02-23 13:49:03 +00:00
http ui stuff
This commit is contained in:
parent
60bb12538e
commit
f16d25dae7
@ -33,7 +33,7 @@ search(Keyword, Page, Count) ->
|
|||||||
mongodb ->
|
mongodb ->
|
||||||
db_store_mongo:search(Conn, Keyword);
|
db_store_mongo:search(Conn, Keyword);
|
||||||
sphinx ->
|
sphinx ->
|
||||||
Offset = Page * Count - if Page > 0 -> 1; true -> 0 end,
|
Offset = Page * Count,
|
||||||
sphinx_search:search(Conn, Keyword, Offset, Count)
|
sphinx_search:search(Conn, Keyword, Offset, Count)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -110,15 +110,14 @@ search_by_mongo(Keyword) ->
|
|||||||
Tip ++ Body.
|
Tip ++ Body.
|
||||||
|
|
||||||
search_by_sphinx(Keyword, Page) ->
|
search_by_sphinx(Keyword, Page) ->
|
||||||
{Rets, Stats} = db_frontend:search(Keyword, Page, ?COUNT_PER_PAGE + 1),
|
{Rets, Stats} = db_frontend:search(Keyword, Page, ?COUNT_PER_PAGE),
|
||||||
{TotalFound, CostTime, DBTime} = Stats,
|
{TotalFound, CostTime, DBTime} = Stats,
|
||||||
US = http_common:list_to_utf_binary(Keyword),
|
US = http_common:list_to_utf_binary(Keyword),
|
||||||
?LOG_STR(?INFO, ?FMT("search /~s/ found ~p, cost ~b sp ms, ~b db ms",
|
?LOG_STR(?INFO, ?FMT("search /~s/ found ~p, cost ~b sp ms, ~b db ms",
|
||||||
[US, length(Rets), CostTime, DBTime])),
|
[US, length(Rets), CostTime, DBTime])),
|
||||||
ThisPage = lists:sublist(Rets, ?COUNT_PER_PAGE),
|
|
||||||
Tip = ?TEXT("<h4>search ~s, ~b results, ~f seconds, db ~f seconds</h4>",
|
Tip = ?TEXT("<h4>search ~s, ~b results, ~f seconds, db ~f seconds</h4>",
|
||||||
[Keyword, TotalFound, CostTime / 1000, DBTime / 1000 / 1000]),
|
[Keyword, TotalFound, CostTime / 1000, DBTime / 1000 / 1000]),
|
||||||
BodyList = format_search_result(ThisPage),
|
BodyList = format_search_result(Rets),
|
||||||
Body = ?TEXT("<ol>~s</ol>", [lists:flatten(BodyList)]),
|
Body = ?TEXT("<ol>~s</ol>", [lists:flatten(BodyList)]),
|
||||||
Tip ++ Body ++ append_page_nav(Keyword, Page, TotalFound).
|
Tip ++ Body ++ append_page_nav(Keyword, Page, TotalFound).
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user