Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,11 @@ GH Archive ──gharchive──▶ gharchive.events ──mojo_repos──▶ m
monthly curves from `mojo.commits`, adoption of the newest version,
tooling share, the repos rising in stars), the repos by size and age
(`/repos`, sortable by lines, files or stars with `?sort=`, filterable
with `?version=1.x` and `?active=1y`), search by name, topic or
with `?version=1.x` and `?active=1y`; incidental Mojo repos, which
entered only by a pushed commit (no `language`, manifest, search, or Mojo in
the name or description) and have fewer than 50 lines of Mojo, are
left out of it and of the Overview's numbers unless `?incidental=1`:
`src/incidental.mojo`), search by name, topic or
description (`/search`), the Mojo versions they moved to over time
(`/migrations`), and a page per repository (`/repos/<owner>/<name>`:
current stars, forks and topics from the latest `mojo.repo_stats` row,
Expand Down
8 changes: 6 additions & 2 deletions bin/console.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ mojo.repo_deps, mojo.dep_forks and mojo.dep_names.

Pages: `/` the overview (cards, repos per Mojo version, growth curves),
`/repos` the repos by size and age (`?sort=lines|files|stars|forks|used_by&dir=asc|desc`,
`?version=1.x`, `?active=1y`), `/search?q=` finds repos by name, GitHub topic
`?version=1.x`, `?active=1y`, `?incidental=1` to include the incidental Mojo
repos it leaves out, `incidental.mojo`), `/search?q=` finds repos by name, GitHub topic
or description, then by meaning (the query embedded with mojo_embed's model,
which the console downloads on its first start; CONSOLE_SEMANTIC=0 turns it off), `/migrations` the migrations to each Mojo version over time,
`/how`, `/how/optimizations` and `/how/changelog` how the census is built,
Expand Down Expand Up @@ -66,7 +67,7 @@ def _check(c: Cache, t: Int64) raises -> CheckRun:
repos.append(
RepoFacts(
l.repo, l.commits, c.commits30[i], c.history[i], l.mojo_lines, l.stars,
Int64(len(l.used_by)), page^,
Int64(len(l.used_by)), page^, c.incidental[i] if i < len(c.incidental) else False,
)
)
var tops = Tops()
Expand All @@ -79,6 +80,9 @@ def _check(c: Cache, t: Int64) raises -> CheckRun:
tops.rising_used_by = c.rising_used_by.copy()
tops.rising_score = c.rising_score.copy()
tops.rising_stars = c.rising_stars.copy()
tops.starred = c.starred.copy()
tops.overview_repos = c.ov.repos
tops.overview_incidental = c.ov.incidental
# An owner/* row is checked by its repos.
for ref d in c.depended:
for m in d.members:
Expand Down
1 change: 1 addition & 0 deletions changes/268-incidental-mojo.minor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- **Incidental Mojo left out of the rankings**: repos that entered only by a pushed commit and have under 50 lines of Mojo are left out of the Repos table, the Overview and `list_repos` unless asked for with `?incidental=1`. (#268)
48 changes: 47 additions & 1 deletion src/checks.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ struct RepoFacts(Copyable, Movable):
var stars: Int64
var used_by: Int64
var page: PageFacts
var incidental: Bool
"""Incidental Mojo (`incidental.is_incidental`), which the top tables
and the Overview's numbers leave out."""


struct Tops(Movable):
Expand All @@ -105,6 +108,12 @@ struct Tops(Movable):
var rising_stars: List[Int64]
var depended: List[String]
var depended_used_by: List[Int64]
var starred: List[String]
"""Most stars' names."""
var overview_repos: Int
"""The Overview's repos and the incidental ones it left out; -1 for not
checked."""
var overview_incidental: Int

def __init__(out self):
self.active = List[String]()
Expand All @@ -118,12 +127,25 @@ struct Tops(Movable):
self.rising_stars = List[Int64]()
self.depended = List[String]()
self.depended_used_by = List[Int64]()
self.starred = List[String]()
self.overview_repos = -1
self.overview_incidental = -1


def _differs(name: String, what: String, shown: Int64, own: Int64) -> String:
return String(name, ": ", what, " ", shown, ", its own ", own)


def _none_incidental(
mut check: Check, table: String, shown: List[String], at: Dict[String, Int], repos: List[RepoFacts]
):
"""Fails `check` for each name of `shown` that is an incidental repo."""
for ref n in shown:
var k = at.get(n, -1)
if k >= 0 and repos[k].incidental:
check.fail(String(table, ": ", n, " is incidental"))


def run_checks(
repo_rows: Int, repos: List[RepoFacts], tops: Tops
) -> List[Check]:
Expand Down Expand Up @@ -273,7 +295,31 @@ def run_checks(
repos[k].used_by,
)
)
return [unique^, within^, within30^, names^, nums^, table^, lines^]
var left = Check(
"incidental_left_out",
(
"no incidental Mojo repo in Rising, Most stars, Most active or Most"
" depended on, and the Overview's repos + the incidental ones it"
" left out = the repos"
),
)
_none_incidental(left, "Rising", tops.rising, at, repos)
_none_incidental(left, "Most stars", tops.starred, at, repos)
_none_incidental(left, "Most active", tops.active, at, repos)
_none_incidental(left, "Most depended on", tops.depended, at, repos)
if tops.overview_repos >= 0:
var inc = 0
for ref r in repos:
if r.incidental:
inc += 1
if tops.overview_incidental != inc or tops.overview_repos + inc != len(repos):
left.fail(
String(
"Overview: ", tops.overview_repos, " repos and ", tops.overview_incidental,
" incidental left out; ", len(repos), " repos, ", inc, " incidental",
)
)
return [unique^, within^, within30^, names^, nums^, table^, lines^, left^]


def when(secs: Int64) -> String:
Expand Down
6 changes: 5 additions & 1 deletion src/console_api.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ from flare.http import Request, Response, internal_error, not_found, ok_json, re

from days import day_text
from deps import other_owners
from incidental import is_incidental
from jscan import micros_to_iso
from committype import typed_commits
from contributors import RepoContributors
Expand Down Expand Up @@ -48,6 +49,7 @@ def overview_json(req: Request, c: Cache) raises -> Response:
'{"as_of":', _q(micros_to_iso(c.sources.as_of_ms * 1000)),
',"days_loaded":', c.sources.days, ',"first_day":', _q(c.sources.first_day),
',"last_day":', _q(c.sources.last_day), ',"repos":', ov.repos,
',"incidental_repos_left_out":', ov.incidental,
',"repos_with_history":', ov.with_history, ',"repos_30d_ago":', ov.repos_30_ago,
',"coverage":{"repos":', ov.repos, ',"repos_with_history":', ov.with_history,
',"gharchive_days_loaded":', min(c.sources.archive_days, archive_days_due(c.built_day)),
Expand Down Expand Up @@ -218,7 +220,9 @@ def _lib_json(l: Library, category: String = String()) -> String:
'{"repo":', _q(l.repo), ',"description":', _q(l.description),
',"created_at":', _q(micros_to_iso(l.created_at) if l.created_at else ""),
',"first_seen":', _q(micros_to_iso(l.first_seen)),
',"found_by":', _q(l.found_by), ',"stars":', l.stars,
',"found_by":', _q(l.found_by),
',"incidental":', "true" if is_incidental(l.found_by, l.mojo_lines, l.commits) else "false",
',"stars":', l.stars,
',"forks":', l.forks, ',"license":', _q(l.license),
',"size_kb":', l.size_kb, ',"commits":', l.commits,
',"mojo_lines":', l.mojo_lines, ',"mojo_files":', l.mojo_files,
Expand Down
29 changes: 25 additions & 4 deletions src/console_cache.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ from measures import Measure, latest_measures
from issues import RepoIssues, add_issue_months, read_issue_rows, summarize
from similar import Embeddings, Neighbor, nearest, read_embeddings
from categories import categorize
from incidental import is_incidental, without_incidental


comptime REFRESH_SECS = 1800
Expand Down Expand Up @@ -112,6 +113,10 @@ struct Cache(Movable):
var news: List[Int]
"""Bits of `listing.new_bit` for when each repo's first Mojo commit was."""
var active: List[Bool]
var incidental: List[Bool]
"""Whether each repo is incidental Mojo (`incidental.is_incidental`):
the Repos table, the Overview's numbers and its top tables leave those
out unless asked."""
var ov: Overview
var details: Dict[String, RepoData]
"""Per repo: the lists its page shows, all read at once at each build."""
Expand Down Expand Up @@ -191,6 +196,7 @@ struct Cache(Movable):
self.est_families = List[String]()
self.news = List[Int]()
self.active = List[Bool]()
self.incidental = List[Bool]()
self.ov = Overview()
self.details = Dict[String, RepoData]()
self.loaded = List[String]()
Expand Down Expand Up @@ -229,7 +235,14 @@ struct Cache(Movable):
def _build(mut self, today: Int, var src: Sources) raises:
var b = Builder(today)
var libs = libraries(b)
var ov = b.finish(len(libs))
var incidental = List[Bool]()
var skip = Dict[String, Bool]()
for ref l in libs:
var inc = is_incidental(l.found_by, l.mojo_lines, l.commits)
incidental.append(inc)
if inc:
skip[l.repo] = True
var ov = b.finish(len(libs), skip)
# Per repo in `libs`' order (biggest first), joined by name: `b.accs`
# is in mojo.repos' order, so its index is no repo's index in `libs`.
var names = List[String]()
Expand Down Expand Up @@ -315,6 +328,13 @@ struct Cache(Movable):
self.starred_gain = List[Int64]()
self.starred_forks = List[Int64]()
self.starred_used_by = List[Int64]()
# The top tables rank no incidental repo.
score_list = without_incidental(score_list, incidental)
var top_stars = without_incidental(stars, incidental)
var top_commits30 = without_incidental(commits30, incidental)
var top_users = List[List[String]]()
for i in range(len(libs)):
top_users.append(List[String]() if incidental[i] else users[i].copy())
for i in top_gains(score_list, RISING_SHOWN):
var g = gains.get(libs[i].repo, Gain(0, 0))
self.rising.append(libs[i].repo)
Expand All @@ -323,13 +343,13 @@ struct Cache(Movable):
self.rising_used_by.append(Int64(len(libs[i].used_by)))
self.rising_score.append(score_list[i])
self.rising_stars.append(libs[i].stars)
for i in top_gains(stars, STARRED_SHOWN):
for i in top_gains(top_stars, STARRED_SHOWN):
self.starred.append(libs[i].repo)
self.starred_stars.append(libs[i].stars)
self.starred_gain.append(gains.get(libs[i].repo, Gain(0, 0)).stars)
self.starred_forks.append(libs[i].forks)
self.starred_used_by.append(Int64(len(libs[i].used_by)))
self.depended = most_depended(names, users, stars, forks, DEPENDED_SHOWN)
self.depended = most_depended(names, top_users, stars, forks, DEPENDED_SHOWN)
var details = Dict[String, RepoData]()
for e in histories().items():
if _duplicate(e.key, key_of, name_of):
Expand Down Expand Up @@ -386,7 +406,7 @@ struct Cache(Movable):
self.active_repos = List[String]()
self.active_commits = List[Int64]()
self.active_lines = List[Int64]()
for i in top_gains(commits30, ACTIVE_SHOWN):
for i in top_gains(top_commits30, ACTIVE_SHOWN):
self.active_repos.append(libs[i].repo)
self.active_commits.append(commits30[i])
self.active_lines.append(lines_delta[i])
Expand All @@ -402,6 +422,7 @@ struct Cache(Movable):
self.est_families = est_families^
self.news = news^
self.active = active^
self.incidental = incidental^
self.libs = libs^
self.history = history^
var keep = Dict[String, Bool]()
Expand Down
54 changes: 51 additions & 3 deletions src/console_list.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ from listing import (
with_active,
with_category,
with_estimate,
with_incidental,
with_new,
with_version,
)
from model import Library, day
from categories import category_keys, category_title
from incidental import INCIDENTAL_LINES
from querymodel import Related, related
from search import names_score, url_decode, url_encode

Expand Down Expand Up @@ -91,6 +93,7 @@ def _list_query(req: Request) -> ListQuery:
req.query_param("sort"), req.query_param("dir"),
url_decode(req.query_param("version")), req.query_param("active"),
req.query_param("new"), req.query_param("estimate"), req.query_param("category"),
req.query_param("incidental"),
)


Expand All @@ -107,12 +110,27 @@ def _raw_query(req: Request) -> String:
return s^


def _left_out(q: ListQuery, c: Cache, i: Int) -> Bool:
"""Whether repo `i` is incidental and `q` leaves those out."""
return not q.incidental and i < len(c.incidental) and c.incidental[i]


def incidental_count(c: Cache) -> Int:
var n = 0
for b in c.incidental:
if b:
n += 1
return n


def _filter_options(q: ListQuery, c: Cache) -> String:
"""The version families and the activity filter as links, with how many
repos each has under the other filter; the ones in use are marked."""
var per = Dict[String, Int]()
var total = 0
for i in range(len(c.libs)):
if _left_out(q, c, i):
continue
if q.active and not c.active[i]:
continue
if q.new.byte_length() > 0 and c.news[i] & new_bit(q.new) == 0:
Expand Down Expand Up @@ -155,6 +173,8 @@ def _filter_options(q: ListQuery, c: Cache) -> String:
var cats = Dict[String, Int]()
var all = 0
for i in range(len(c.libs)):
if _left_out(q, c, i):
continue
if q.active and not c.active[i]:
continue
if q.new.byte_length() > 0 and c.news[i] & new_bit(q.new) == 0:
Expand Down Expand Up @@ -185,10 +205,28 @@ def _filter_options(q: ListQuery, c: Cache) -> String:
"<a class='chip", " on" if q.new == news[k] else "", "' href='",
html_escape(list_url(with_new(q, news[k]))), "'>", titles[k], "</a>",
)
var inc = incidental_count(c)
if inc > 0:
h.write(
"<span class=label title='", incidental_title(), "'>Incidental Mojo</span>",
"<a class='chip", " on" if not q.incidental else "", "' href='",
html_escape(list_url(with_incidental(q, False))), "'>left out</a>",
"<a class='chip", " on" if q.incidental else "", "' href='",
html_escape(list_url(with_incidental(q, True))), "'>included (", inc, ")</a>",
)
h.write("</div>")
return h^


def incidental_title() -> String:
"""What incidental Mojo means, in a line for a tooltip."""
return String(
"Repos that entered the census only through a pushed commit that changed a .mojo file, with no Mojo in",
" their name or description, and have fewer than ",
INCIDENTAL_LINES, " lines of Mojo",
)


def _filter_chips(q: ListQuery) -> String:
"""The filters in use, each a chip that removes it."""
if not q.has_filter():
Expand Down Expand Up @@ -231,7 +269,7 @@ def repos_page(req: Request, c: Cache) raises -> Response:
q, c.lines, c.files, c.stars,
c.est_buckets if q.estimate else c.buckets, c.active,
c.est_families if q.estimate else c.families, c.news, c.commits30,
c.forks, c.used_by, c.categories,
c.forks, c.used_by, c.categories, c.incidental,
)
var h = String(
"<h1>Mojo repos</h1><p class=sub>Mojo repos, versions and growth, counted",
Expand All @@ -247,10 +285,20 @@ def repos_page(req: Request, c: Cache) raises -> Response:
)
)
return _page("Repos", h^, "repos", description=page_line("/repos"), alternate=page_json("/repos"))
var inc = incidental_count(c)
var counted = len(c.libs) if q.incidental else len(c.libs) - inc
var inc_note = String()
if inc > 0:
inc_note = String(
" <a href='", html_escape(list_url(with_incidental(q, not q.incidental))), "' title='",
incidental_title(), "'>", String(inc) if not q.incidental else String("The"), " incidental Mojo ",
"repo" if inc == 1 and not q.incidental else "repos",
String(" left out") if not q.incidental else String(" are included"), "</a>.",
)
h.write(
"<p class=lead><strong>", len(idx), " repo" if len(idx) == 1 else " repos",
"</strong>", " of " if q.has_filter() else "", String(len(c.libs)) if q.has_filter() else "",
" found in GH Archive.",
"</strong>", " of " if q.has_filter() else "", String(counted) if q.has_filter() else "",
" found in GH Archive.", inc_note,
_help(
"h-repos", "the Repos table",
"Size is lines of Mojo at the last commit read; age is since GitHub created the"
Expand Down
Loading
Loading