usable page

pull/5/head
Adam Veldhousen 2023-05-16 16:34:30 -05:00
parent 93e19b0605
commit d504ad8b47
Signed by: adam
GPG Key ID: 6DB29003C6DD1E4B
13 changed files with 65 additions and 26 deletions

View File

@ -28,7 +28,8 @@ message AuctionSearchCriteria {
message GetUpcomingResult {
int32 page = 1;
int32 total = 2;
repeated Auction results = 3;
int32 found = 3;
repeated Auction results = 4;
}
message Auction {

View File

@ -8,6 +8,8 @@ fts.ts @@ phraseto_tsquery($1)
ORDER BY ts_rank(fts.ts, phraseto_tsquery($1)) DESC
LIMIT $2;
-- name: GetTotal :one
SELECT COUNT(*) FROM catalog.upcoming_auctions;
-- name: ImportAuction :one
SELECT catalog.bh_import_auction(

View File

@ -14,7 +14,7 @@ type PGCatalogStorage struct {
Queries *postgres.Queries
}
func (ps *PGCatalogStorage) GetUpcoming(ctx context.Context, q domain.UpcomingQuery) (results []domain.Auction, total int, err error) {
func (ps *PGCatalogStorage) GetUpcoming(ctx context.Context, q domain.UpcomingQuery) (results []domain.Auction, total int64, err error) {
var pgResults []postgres.CatalogUpcomingAuction
if pgResults, err = ps.Queries.GetUpcoming(ctx, postgres.GetUpcomingParams{
@ -25,6 +25,11 @@ func (ps *PGCatalogStorage) GetUpcoming(ctx context.Context, q domain.UpcomingQu
return
}
if total, err = ps.Queries.GetTotal(ctx); err != nil {
err = fmt.Errorf("could not get total auction count: %w", err)
return
}
results = make([]domain.Auction, len(pgResults))
for idx, row := range pgResults {
results[idx] = domain.Auction{

View File

@ -17,7 +17,7 @@ type (
}
Storage interface {
GetUpcoming(context.Context, UpcomingQuery) ([]Auction, int, error)
GetUpcoming(context.Context, UpcomingQuery) ([]Auction, int64, error)
CreateUpcoming(context.Context, Auction) (string, error)
}
@ -37,7 +37,7 @@ type (
UpcomingResults struct {
Page int
Total int
Total int64
Results []Auction
}
)

View File

@ -37,6 +37,7 @@ message SyncStatus {
message StatusFilter {
int32 page = 1;
int32 id = 2;
}
message SyncStatusList {

View File

@ -5,7 +5,8 @@ SELECT id,
targetSiteName,
auctionsFound,
errors
FROM runner.scrapejob;
FROM runner.scrapejob
ORDER BY startedTs DESC;
-- name: GetJobByID :one
SELECT id,

View File

@ -179,6 +179,7 @@ func LAGetSaleInfo(ctx context.Context, catIDs LACatalogIDs) (results []catalog.
Description string `json:"description"`
ItemCount int `json:"lotsListed"`
SaleStartTS int64 `json:"saleStartTs"`
SellerID int64 `json:"sellerId"`
Address struct {
CountryCode string `json:"country"`
Lat float64 `json:"lat"`

View File

@ -15,6 +15,7 @@
"@playwright/test": "^1.28.1",
"@sveltejs/adapter-node": "^1.2.4",
"@sveltejs/kit": "^1.5.0",
"@types/luxon": "^3.3.0",
"@typescript-eslint/eslint-plugin": "^5.45.0",
"@typescript-eslint/parser": "^5.45.0",
"autoprefixer": "^10.4.14",
@ -846,6 +847,12 @@
"integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==",
"dev": true
},
"node_modules/@types/luxon": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/@types/luxon/-/luxon-3.3.0.tgz",
"integrity": "sha512-uKRI5QORDnrGFYgcdAVnHvEIvEZ8noTpP/Bg+HeUzZghwinDlIS87DEenV5r1YoOF9G4x600YsUXLWZ19rmTmg==",
"dev": true
},
"node_modules/@types/node": {
"version": "20.1.4",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.1.4.tgz",

View File

@ -17,6 +17,7 @@
"@playwright/test": "^1.28.1",
"@sveltejs/adapter-node": "^1.2.4",
"@sveltejs/kit": "^1.5.0",
"@types/luxon": "^3.3.0",
"@typescript-eslint/eslint-plugin": "^5.45.0",
"@typescript-eslint/parser": "^5.45.0",
"autoprefixer": "^10.4.14",

View File

@ -34,18 +34,18 @@
const saleStartTime = DateTime.fromISO(start);
</script>
<article class="auction-result flex flex-col py-3 rounded-md shadow-sm">
<header>
<h2>
<article class="auction-result flex flex-col py-3 shadow-sm border-b-2 border-bh-gold">
<header class="pb-2">
<h2 class="text-lg">
<a href={sourceURL} target="_blank">{title}</a>
</h2>
</header>
<section>
<ul>
<li>Starts {saleStartTime.toLocaleString(DateTime.DATETIME_FULL)}</li>
<li>{province}, {country.toUpperCase()}</li>
<li>{items} Items</li>
<li>
<li class="text-sm">Starts {saleStartTime.toLocaleString(DateTime.DATETIME_FULL)}</li>
<li class="text-sm">{province}, {country.toUpperCase()}</li>
<li class="text-sm">{items} Items</li>
<li class="text-sm">
Available at <a href={sourceSiteURL} target="_blank">{sourceSiteName}</a>
</li>
<li class="py-2"><p>{description}</p></li>

View File

@ -5,26 +5,44 @@
function onSubmit(evt: CustomEvent) {
const { query } = evt.detail;
goto(`/?query=${query}`);
goto(query ? `/?query=${query}` : '/');
}
</script>
<main class="w-full">
<nav class="flex w-full bg-bh-gold text-bh-black" style="height: 60px;">
<img style="width: 450px; height: 60px;" src="/logo_black_gold.svg" alt="BarrettHousen" />
<ul class="flex w-full py-3">
<li class="flex grow">
<SearchBox on:search={onSubmit} />
<nav
class="flex w-full bg-bh-gold text-bh-black fixed top-0 left-0 right-0 shadow-bh-black shadow-lg"
style="height: 80px;"
>
<img
class="pr-5"
style="width: 450px; height: 80px;"
src="/logo_black_gold.svg"
alt="BarrettHousen"
/>
<ul class="flex w-full py-3 items-center justify-between">
<li class="flex grow justify-center">
<span class="flex grow" style="max-width: 75%;">
<SearchBox on:search={onSubmit} />
</span>
</li>
<li class="flex h-full items-baseline px-6">
<span> 1234 Auctions </span>
<li class="px-6">
<span>I want email alerts!</span>
</li>
</ul>
</nav>
<div class="flex flex-row">
<div id="gutter" class="h-full" style="min-width: 150px;" />
<div class="flex flex-row pt-16">
<div id="gutter" class="h-full" style="min-width: 195px;" />
<section id="content" class="pt-6">
<slot />
</section>
</div>
<footer
class="flex justify-center bg-bh-gold text-bh-black w-full mt-20 py-10 shadow-inner shadnow-md shadow-bh-black"
>
<p>
We find great auctions of rare and one of a kind collectibles from around the web and compile
them in one easy place.
</p>
</footer>
</main>

View File

@ -5,9 +5,9 @@
export let data: PageData;
</script>
<h1>{data?.pagination?.page} Search Results</h1>
<h1 class="pb-5 text-lg">{data?.total} Upcoming & Live Auctions</h1>
<ul class="flex flex-wrap flex-row m-0 p-0 justify-between pr-10">
<ul class="flex flex-col m-0 p-0 justify-between pr-10">
{#each data.results as auction, i}
<li id="catalog-{auction.id}" class="pb-5">
<AuctionResult {auction} />

View File

@ -7,12 +7,14 @@ export const load = (async ({ fetch, url }) => {
try {
const searchTerm = url.searchParams.get('query') || 'watch';
const response = await fetch(API_HOST + `/upcoming?searchTerm=${searchTerm}`);
const { page, results } = await response.json();
const { page, total, results } = await response.json();
return {
pagination: {
page
page,
limit: 64,
},
total,
results
};
} catch (e) {