Fixes from the first round of TEST.md
SEO: a domain property (sc-domain:) covers every subdomain, so the shop, Gitea and forum were counted as the website. What ranks, the morning check, the Monday report, keywords, change candidates and the audit's traffic now read only the website's own host (with or without www). The report keeps pages worth a proposal apart from "Waiting for your yes", explains only moves past the thresholds, and says "places up/down". Also: - Feed summaries drop the posts' scripts and styles. - Spend you log can't be negative. - Test and check buttons can't be clicked twice while they run. - Previews show the site's web fonts and icon sprites. - Backups are read without leaving -wal/-shm files; deleting one removes them, and leftovers are swept at start. - The Overview's setup flags a CRM that Hermes can't reach. - Import now says what came in; adding a prospect that exists says so; prospects can be deleted. - Signal tags and brief addresses keep accented letters (Ü → u). - Page errors start with a capital; clearer messages for bad uploads, CRM retry and cancel, keywords, and the finished audit. - The module you're in stays unfolded in the sidebar. - A picked keyword can be unpicked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+15
-17
@@ -92,30 +92,27 @@ func period(d *db.DB, site string, days int) (from, to string, ok bool) {
|
||||
|
||||
// WhatRanks works out job 1 for a property, over the last RanksDays days
|
||||
// of final data. It returns nil if nothing is stored yet.
|
||||
func WhatRanks(d *db.DB, site string) (*Ranks, error) {
|
||||
from, to, ok := period(d, site, RanksDays)
|
||||
func WhatRanks(d *db.DB, sc Scope) (*Ranks, error) {
|
||||
from, to, ok := period(d, sc.Property, RanksDays)
|
||||
if !ok {
|
||||
return nil, nil
|
||||
}
|
||||
r := &Ranks{Site: site, From: from, To: to, Anonymous: -1}
|
||||
var posSum float64
|
||||
if err := d.QueryRow(`SELECT coalesce(sum(clicks), 0), coalesce(sum(impressions), 0), coalesce(sum(pos_sum), 0)
|
||||
FROM gsc_site_days WHERE site = ? AND date BETWEEN ? AND ?`, site, from, to).
|
||||
Scan(&r.Total.Clicks, &r.Total.Impressions, &posSum); err != nil {
|
||||
r := &Ranks{Site: sc.Property, From: from, To: to, Anonymous: -1}
|
||||
var err error
|
||||
if r.Total, err = siteNumbers(d, sc, from, to); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
r.Total.Position = position(posSum, r.Total.Impressions)
|
||||
|
||||
cond, args := sc.where()
|
||||
var named int
|
||||
if err := d.QueryRow(`SELECT coalesce(sum(clicks), 0) FROM gsc_query_days WHERE site = ? AND date BETWEEN ? AND ?`,
|
||||
site, from, to).Scan(&named); err != nil {
|
||||
if err := d.QueryRow(`SELECT coalesce(sum(clicks), 0) FROM gsc_query_days WHERE `+cond+` AND date BETWEEN ? AND ?`,
|
||||
append(args, from, to)...).Scan(&named); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if r.Total.Clicks > 0 {
|
||||
r.Anonymous = 100 * float64(r.Total.Clicks-min(named, r.Total.Clicks)) / float64(r.Total.Clicks)
|
||||
}
|
||||
|
||||
pages, err := pageNumbers(d, site, from, to)
|
||||
pages, err := pageNumbers(d, sc, from, to)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -127,9 +124,9 @@ func WhatRanks(d *db.DB, site string) (*Ranks, error) {
|
||||
}
|
||||
|
||||
rows, err := d.Query(`SELECT query, sum(clicks), sum(impressions), sum(pos_sum) FROM gsc_query_days
|
||||
WHERE site = ? AND date BETWEEN ? AND ? GROUP BY query
|
||||
WHERE `+cond+` AND date BETWEEN ? AND ? GROUP BY query
|
||||
HAVING sum(impressions) > 0 AND 100.0 * sum(clicks) / sum(impressions) < ?
|
||||
ORDER BY sum(impressions) DESC LIMIT 10`, site, from, to, lowCTR)
|
||||
ORDER BY sum(impressions) DESC LIMIT 10`, append(args, from, to, lowCTR)...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -167,7 +164,7 @@ func WhatRanks(d *db.DB, site string) (*Ranks, error) {
|
||||
break
|
||||
}
|
||||
pick := Pick{Page: p.Page, Numbers: p.Numbers}
|
||||
if err := mainQuery(d, site, from, to, &pick); err != nil {
|
||||
if err := mainQuery(d, sc.Property, from, to, &pick); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pick.Why = fmt.Sprintf("Shown %s times at position %.1f, %s %s.", Thousands(p.Impressions), p.Position, Thousands(p.Clicks), plural(p.Clicks, "click", "clicks"))
|
||||
@@ -180,9 +177,10 @@ func WhatRanks(d *db.DB, site string) (*Ranks, error) {
|
||||
}
|
||||
|
||||
// pageNumbers are every page's numbers over a period, most clicks first.
|
||||
func pageNumbers(d *db.DB, site, from, to string) ([]PageRow, error) {
|
||||
func pageNumbers(d *db.DB, sc Scope, from, to string) ([]PageRow, error) {
|
||||
cond, args := sc.where()
|
||||
rows, err := d.Query(`SELECT page, sum(clicks), sum(impressions), sum(pos_sum) FROM gsc_page_days
|
||||
WHERE site = ? AND date BETWEEN ? AND ? GROUP BY page ORDER BY sum(clicks) DESC, sum(impressions) DESC`, site, from, to)
|
||||
WHERE `+cond+` AND date BETWEEN ? AND ? GROUP BY page ORDER BY sum(clicks) DESC, sum(impressions) DESC`, append(args, from, to)...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user