text stringlengths 185 73.3k | repo stringlengths 7 100 | path stringlengths 4 146 | language stringclasses 7
values | hash stringlengths 16 16 | score float64 7 8.5 | stars int64 0 237k |
|---|---|---|---|---|---|---|
"""Switch image capture time to naive local and clean up camera/health columns
Converts images.uploaded_at (TIMESTAMPTZ, mistagged as UTC) to images.captured_at
(naive TIMESTAMP), interpreted under ServerSettings.timezone. Drops the dead
Camera.last_* camera-clock columns (never written by production ingestion, the
AP... | PetervanLunteren/AddaxAI-Connect | services/api/alembic/versions/20260414_captured_at_naive_local.py | .py | 6420d780e071b2d1 | 7.6 | 15 |
"""Add infrastructure alert toggles to server_settings
Two server-wide booleans controlling whether server admins get emailed when
the automated backup or the cold-tier migration fails. Both default TRUE so
the feature is on from the moment a new server has backup/cold-tier
configured. Runtime code also checks BACKUP_... | PetervanLunteren/AddaxAI-Connect | services/api/alembic/versions/20260421_infra_alert_toggles.py | .py | 2243ef8d16ae8ae7 | 7.6 | 15 |
"""Add sim_expiry_date to cameras
Adds an optional Date column so project admins can record when each
camera's SIM card runs out. The new monthly SIM expiry alert reads this
column to email admins about cameras expiring inside the next two
calendar months (or already expired).
Revision ID: 20260507_add_sim_expiry
Rev... | PetervanLunteren/AddaxAI-Connect | services/api/alembic/versions/20260507_add_camera_sim_expiry_date.py | .py | b3bf08fbe572b28b | 7.6 | 15 |
"""Add password_changed_at to users
Foundation for invalidating stale JWTs after a password change. The
JWT strategy compares each token's iat (issued-at) against this column
and rejects tokens issued before the most recent password change.
Existing rows stay NULL, which is interpreted as "never changed" so
old token... | PetervanLunteren/AddaxAI-Connect | services/api/alembic/versions/20260508_add_password_changed_at.py | .py | c81de02a3f271b3b | 7.6 | 15 |
"""Fuzz GraphQL payload traversal and record hydration from GitHub responses."""
import contextlib
import json
import logging
import sys
import atheris
from hiero_analytics.data_sources.models import (
ContributorActivityRecord,
HipReferenceRecord,
IssueRecord,
IssueTimelineEventRecord,
PullReque... | hiero-hackers/analytics | fuzz/github_payload_fuzzer.py | .py | e928497a9b7cf226 | 7.57 | 13 |
"""Fuzz the HIP proposal frontmatter parser with arbitrary repository content."""
import logging
import sys
import atheris
from hiero_analytics.data_sources.github_ingest.hip_references import parse_hip_frontmatter
def test_one_input(data: bytes) -> None:
"""Exercise frontmatter parsing; malformed input must b... | hiero-hackers/analytics | fuzz/hip_frontmatter_fuzzer.py | .py | a430ba158fef00cc | 7.57 | 13 |
"""Fuzz record deserialization and the serialize/deserialize round trip."""
import json
import logging
import sys
import atheris
from hiero_analytics.data_sources.models import (
ContributorActivityRecord,
HipReferenceRecord,
HipSpecRecord,
IssueRecord,
IssueTimelineEventRecord,
PullRequestDi... | hiero-hackers/analytics | fuzz/serialization_fuzzer.py | .py | faa15f9c074ed903 | 7.57 | 13 |
"""Fuzz free-text parsers and spreadsheet-safe CSV transformation."""
import logging
import sys
import atheris
from hiero_analytics.domain.hip_references import extract_hip_mentions
from hiero_analytics.export.csv_safety import sanitize_csv_text
from hiero_analytics.pipelines.build_affiliations import parse_maintain... | hiero-hackers/analytics | fuzz/text_processing_fuzzer.py | .py | 56289f8f39b168a9 | 7.57 | 13 |
"""Analysis functions for CODEOWNERS compliance and GitHub Actions runner workflows."""
import logging
import pandas as pd
from hiero_analytics.analysis.dataframe_utils import records_to_dataframe
from hiero_analytics.data_sources.models import CodeOwnersRecord, RunnerRecord
logger = logging.getLogger(__name__)
d... | hiero-hackers/analytics | src/hiero_analytics/analysis/codeowner_workflow_analysis.py | .py | b098e2ac13ca5419 | 7.57 | 13 |
"""Co-membership networks: repositories linked by people they share.
A bipartite (person × repo) relationship projected onto repositories. Each repo is
a node sized by its *active* members of some group (maintainers, committers, triage,
or general contributors); two repos are linked when they share members of that gro... | hiero-hackers/analytics | src/hiero_analytics/analysis/comembership.py | .py | 17af5da13d9b35df | 7.57 | 13 |
"""Build per-contributor activity profiles for the informational dashboard.
Groups each contributor's GitHub activity into three neutral *families* of work
(named for the activity, not for any role or rank):
- ``building_and_fixing`` — authoring pull requests
- ``reviewing_and_guiding`` — reviewing and merging othe... | hiero-hackers/analytics | src/hiero_analytics/analysis/contributor_activity_profile.py | .py | f6528cb190116c72 | 7.57 | 13 |
"""Contributor churn and progression analysis."""
import pandas as pd
from hiero_analytics.domain.labels import DIFFICULTY_LEVELS
# Maps difficulty name → sort rank; Unknown = -1 so it never beats a real level.
_LEVEL_ORDER: dict[str, int] = {spec.name: i for i, spec in enumerate(DIFFICULTY_LEVELS)}
_LEVEL_ORDER["Un... | hiero-hackers/analytics | src/hiero_analytics/analysis/contributor_churn.py | .py | fcdf068b6edeb05e | 7.57 | 13 |
"""Build the contributor-activity heatmap matrix (weighted monthly activity).
The ranked, score-based companion to the descriptive profiles in
``contributor_activity_profile``. Activity is weighted by action type and bucketed
by month; only activity within the displayed window is scored, so the top-N
selection, the "a... | hiero-hackers/analytics | src/hiero_analytics/analysis/contributor_heatmap.py | .py | 8897d1f989bf097d | 7.57 | 13 |
"""Generic dataframe helpers for converting and filtering records."""
from __future__ import annotations
from collections.abc import Callable, Sequence
from typing import TypeVar
import pandas as pd
from hiero_analytics.data_sources.models import IssueRecord, RepositoryRecord
def repos_to_dataframe(records: list[... | hiero-hackers/analytics | src/hiero_analytics/analysis/dataframe_utils.py | .py | cc79623dbc6bab54 | 7.57 | 13 |
"""Difficulty classification and window-selection helpers for issue analytics."""
from __future__ import annotations
from datetime import datetime
from hiero_analytics.analysis.timeseries import (
TIMELINE_EVENT_ORDER,
normalize_datetime,
)
from hiero_analytics.data_sources.models import IssueRecord, IssueTi... | hiero-hackers/analytics | src/hiero_analytics/analysis/difficulty_analysis.py | .py | ead1ad69f53593eb | 7.57 | 13 |
"""Hiero Hackers GitHub organization analytics functions.
Pure transformations on repository and contributor activity data
to produce aggregated summaries for charting.
"""
from __future__ import annotations
from datetime import UTC, datetime, timedelta
import pandas as pd
from hiero_analytics.analysis.dataframe_u... | hiero-hackers/analytics | src/hiero_analytics/analysis/hiero_hackers_analysis.py | .py | 64e5c52c22c6594d | 7.57 | 13 |
"""Transforms mapping PR HIP references onto the HIP spec inventory.
Everything here is mechanical aggregation of two record lists — no scoring, no
judgment calls. PR evidence shows where implementation work happened; whether a
HIP is *complete* stays a human decision, which is why every table traces back
to the per-P... | hiero-hackers/analytics | src/hiero_analytics/analysis/hip_implementation.py | .py | a0dfc0f35080a005 | 7.57 | 13 |
"""Analytics helpers for maintainer-pipeline role classification.
This module classifies contributor activity records, including both
pull request and issue activity, into governance roles and builds
aggregated pipeline tables.
The time views are one rule at four resolutions — a person counts for a bucket
if they wer... | hiero-hackers/analytics | src/hiero_analytics/analysis/maintainer_pipeline.py | .py | 4d718fc3e9fbcc5e | 7.57 | 13 |
"""Transformations and filters for pull request difficulty records."""
from __future__ import annotations
import pandas as pd
from hiero_analytics.analysis.dataframe_utils import records_to_dataframe
from hiero_analytics.data_sources.models import PullRequestDifficultyRecord
from hiero_analytics.domain.labels import... | hiero-hackers/analytics | src/hiero_analytics/analysis/prs.py | .py | 2bb705d5205f2899 | 7.57 | 13 |
"""Per-repository rollups derived from the combined ``role_coverage_all`` table.
These summarize a repo's permission-holders into one row per repo — an activity
overview, the maintainer-coverage view, and the review-load concentration — as
opposed to ``role_coverage``, which works per ``(repo, holder)``.
"""
from __f... | hiero-hackers/analytics | src/hiero_analytics/analysis/repo_summaries.py | .py | aedf519eed5c313c | 7.57 | 13 |
"""Role coverage: a repo's permission-holders alongside their recent activity.
Joins governance-assigned roles (triage / committer / maintainer) for a repo to
its per-repo contributor activity profile, so anyone can see which role-holders
have recent activity, which are currently ``quiet`` in that repo, and each
holde... | hiero-hackers/analytics | src/hiero_analytics/analysis/role_coverage.py | .py | 2e7741211126bdf4 | 7.57 | 13 |
"""Analysis functions for converting OpenSSF Scorecard records into DataFrames."""
from __future__ import annotations
import pandas as pd
from hiero_analytics.analysis.dataframe_utils import records_to_dataframe
from hiero_analytics.data_sources.models import ScorecardRecord
CHECK_COLUMNS = [
"Maintained",
... | hiero-hackers/analytics | src/hiero_analytics/analysis/scorecard_analysis.py | .py | 6395082999ca7173 | 7.57 | 13 |
"""Team-level activity rollups from governance team membership + activity profiles.
A team is marked **quiet** when none of its members have recent activity anywhere
within the window; ``build_team_activity_by_repo`` shows which repos each team is
active in. Descriptive — it aggregates member activity and never ranks ... | hiero-hackers/analytics | src/hiero_analytics/analysis/team_activity.py | .py | 7e1931a3d745fcda | 7.57 | 13 |
"""Time-series helpers for cumulative and historical issue-difficulty trends."""
from __future__ import annotations
from collections.abc import Iterable
from datetime import UTC, datetime, timedelta
import pandas as pd
from hiero_analytics.data_sources.models import IssueRecord, IssueTimelineEventRecord
from hiero_... | hiero-hackers/analytics | src/hiero_analytics/analysis/timeseries.py | .py | 13616378ff5a8fd6 | 7.57 | 13 |
"""Command-line entry point for hiero-analytics.
``hiero-analytics`` with no arguments (or ``hiero-analytics all``) runs the full
pipeline suite; ``hiero-analytics <pipeline>`` runs a single pipeline. The
subcommands and their options come straight from the registry in
``hiero_analytics.pipelines``, so adding a pipeli... | hiero-hackers/analytics | src/hiero_analytics/cli.py | .py | a3b1815aa16c65c4 | 7.57 | 13 |
"""Safe environment-variable parsing with fallbacks and optional bounds.
Misconfigured numeric env vars (empty, non-numeric, zero/negative) should fall
back to a sane default rather than crash at import or feed an invalid value into
something like a thread-pool size. These helpers centralize that handling.
"""
from _... | hiero-hackers/analytics | src/hiero_analytics/config/env.py | .py | 786138d8baba9ae8 | 7.57 | 13 |
"""Logging configuration helpers for ``hiero_analytics``."""
from __future__ import annotations
import logging
import os
from collections.abc import Iterable
DEFAULT_LOG_LEVEL = logging.INFO
LOG_LEVEL_ENV_VAR = "LOG_LEVEL"
LOG_MODULES_ENV_VAR = "LOG_MODULES"
LOG_FORMAT = "%(asctime)s | %(levelname)s | %(name)s | %(m... | hiero-hackers/analytics | src/hiero_analytics/config/logging_config.py | .py | 12a2f7ccd8d5c11e | 7.57 | 13 |
"""Defines configuration constants for paths and directories used in the analytics module."""
from __future__ import annotations
import os
from pathlib import Path
# Import-time *defaults* only — runners that support multiple orgs must accept an
# explicit org argument (see run_contributor_activity_org.main) rather ... | hiero-hackers/analytics | src/hiero_analytics/config/paths.py | .py | aec74b6511cffa73 | 7.57 | 13 |
"""Declarative spec for the dashboard — one module per dashboard family.
Pure data consumed by the dashboard pipeline. Each family module declares its
chart macro plus the notes/methodology/wide-chart sets for its charts; a
family with table sections (contributors, governance) also declares
``SECTION_SPECS``/``SECTION... | hiero-hackers/analytics | src/hiero_analytics/dashboard_spec/__init__.py | .py | 3234c786a969ff45 | 7.07 | 13 |
"""Assembly helpers for the dashboard-spec package.
Pure functions used by the package ``__init__`` to canonicalise each family's
chart macro and merge the per-family dicts, kept here so the ``__init__``
reads as declarative assembly only.
"""
from __future__ import annotations
from collections.abc import Sequence
f... | hiero-hackers/analytics | src/hiero_analytics/dashboard_spec/_assembly.py | .py | 418b1a7125041b69 | 8.07 | 13 |
"""Shared column vocabulary — the prose behind each tab's "how to read this".
Definitions live here once so two tabs describing the same column cannot drift
apart; each family selects the entries its own columns actually use, via
:func:`glossary_of`, so a tab never explains columns it does not show.
Pure data: the we... | hiero-hackers/analytics | src/hiero_analytics/dashboard_spec/glossary.py | .py | cf089741794994cc | 7.07 | 13 |
"""Process-wide adaptive concurrency limiter for GitHub API requests.
Caps how many requests may be in flight at once and shrinks that cap when GitHub
returns a secondary-rate-limit (403), recovering gradually as clean responses come
back. A single shared instance is used by every ``GitHubClient`` in a run, so a
throt... | hiero-hackers/analytics | src/hiero_analytics/data_sources/adaptive_limiter.py | .py | 5707b5a7a9accc41 | 7.57 | 13 |
"""File-backed cache helpers for normalized GitHub data records.
Freshness is governed by ``GITHUB_CACHE_TTL_SECONDS`` or the
``ttl_seconds`` override. A positive value expires cache entries older
than the configured number of seconds. A value of ``0`` or less
disables expiry and keeps cache entries indefinitely until... | hiero-hackers/analytics | src/hiero_analytics/data_sources/cache.py | .py | b26556c2e881ad54 | 7.57 | 13 |
"""Durable dataset store for incremental fetching.
Unlike the TTL cache (``data_sources/cache.py``), this is the *system of record*:
the full accumulated dataset for a resource, persisted under ``outputs/`` together
with the high-watermark timestamp it was fetched through. Incremental fetches pull
only records changed... | hiero-hackers/analytics | src/hiero_analytics/data_sources/dataset_store.py | .py | 63a37518f5812cd0 | 7.57 | 13 |
"""Shared engine for GitHub data ingestion.
Generic paginated and parallel fetch primitives plus the repository listing that
the resource-specific modules (``issues``, ``timeline``, ``pull_requests``,
``contributors``) build on. Keeping these here lets each resource module depend
on one shared core without importing o... | hiero-hackers/analytics | src/hiero_analytics/data_sources/github_ingest/_common.py | .py | 1f1f434919eaf61b | 7.57 | 13 |
"""Batched multi-repo GraphQL fetching via repository field aliases.
Instead of one query per repository, several repositories are combined into a
single request::
query BatchedRepos($c0: String, $c1: String, $states: [IssueState!]) {
r0: repository(owner: "org", name: "repo-a") { issues(after: $c0, ...) {.... | hiero-hackers/analytics | src/hiero_analytics/data_sources/github_ingest/batched.py | .py | 36278efd32134c5a | 7.57 | 13 |
"""Tiny stdlib HTTP client for a running MindFlock server (J1).
Used by the terminal commands (``mindflock new/ls/attach/open/events`` in
:mod:`backend.cli`) so the terminal and the web UI stay one system: the CLI
never spawns its own engine, it talks to the same ``/api/*`` the browser uses.
Server discovery order (:... | MindFlock/MindFlock | backend/client.py | .py | e2b236a59b066375 | 7.54 | 11 |
"""Port of the Go ``cmd`` package.
A thin abstraction layer over external process execution, mirroring the Go
``cmd`` package (``cmd/cmd.go`` + ``cmd/cmd_test/testutils.go``).
The Go code builds ``*exec.Cmd`` objects with ``exec.Command(name, args...)``
and passes them to an ``Executor`` whose two methods (``Run`` / ... | MindFlock/MindFlock | backend/cmd/__init__.py | .py | f4b6ebb8710fbe93 | 7.54 | 11 |
"""Configured IDE integration — which editor opens workspaces.
Productization: MindFlock historically hardcoded Cursor everywhere (launching,
window focus/close/maximize, session auto-adopt). Every consumer now resolves
the editor through this module, so linking a different IDE is one Settings
field (Settings → Advanc... | MindFlock/MindFlock | backend/config/ide.py | .py | 87362dd74443e8f0 | 7.54 | 11 |
"""Shared secret / credential resolver.
Generalizes the resolution chain that :mod:`backend.ticket_ingestion.github_auth`
pioneered for the GitHub token so every credential (GitHub PAT, Shortcut API
token, …) is resolved the same way and a new user can supply it wherever is most
convenient.
Resolution order for a sec... | MindFlock/MindFlock | backend/config/secrets.py | .py | 8e62c4e1c62589de | 7.54 | 11 |
"""Operating-system detection — the one place MindFlock branches on platform.
MindFlock's session engine runs on tmux + Unix PTYs + ``fcntl`` locks, so it
supports Linux, macOS, and Windows-via-WSL. Native Windows (PowerShell/cmd,
no tmux) is not a supported host for the engine. This module centralises the
detection s... | MindFlock/MindFlock | backend/osenv.py | .py | c80c23852ca58053 | 7.54 | 11 |
"""Repair the process ``PATH`` so a GUI-launched backend can find user CLIs.
A MindFlock backend started from a desktop launcher (Electron, a ``.desktop``
file, Finder, ``launchd``/systemd) inherits a *minimal* ``PATH`` — it never
sources the user's shell profile — so ``shutil.which("claude")`` and friends
come back e... | MindFlock/MindFlock | backend/pathenv.py | .py | 2ec5343108614e06 | 7.54 | 11 |
"""Provider-agnostic activity markers.
MindFlock reports what a coding-agent CLI is doing *right now* by having the
CLI's own lifecycle hooks write a per-session ``{state, ts}`` JSON marker, which
the web layer (:mod:`backend.web.core.agent_state`) trusts over pane-hash
guessing. The mechanism is identical across ever... | MindFlock/MindFlock | backend/providers/activity_markers.py | .py | 85b33400181078d2 | 7.54 | 11 |
"""Live plan-quota for the Google Antigravity CLI (``agy``).
agy does not persist quota to disk — its "Usage & Quota" screen asks the CLI's
embedded language server, which proxies cloudcode's
``retrieveUserQuotaSummary`` RPC (the cloud endpoint itself rejects callers
other than the CLI). That local server speaks Conne... | MindFlock/MindFlock | backend/providers/antigravity_usage_api.py | .py | 350325ad719b63eb | 7.54 | 11 |
"""Live plan-usage from Anthropic's OAuth usage endpoint (best-effort).
Claude Code's ``/usage`` screen reads this same endpoint with the user's OAuth
token (``~/.claude/.credentials.json``). We reuse it READ-ONLY to show the real
window utilization + reset time instead of a transcript-derived estimate —
the estimate'... | MindFlock/MindFlock | backend/providers/claude_usage_api.py | .py | 0eb1335f6b929cd7 | 7.54 | 11 |
"""One neutral thinking-effort ladder, translated per coding CLI.
"Use more thinking on this one" is a thing every modern coding CLI can do and no
two of them spell the same way: ``claude --effort xhigh``, ``codex -c
model_reasoning_effort=high``, ``agy --effort high``, and several CLIs (aider,
goose, cline, opencode)... | MindFlock/MindFlock | backend/providers/effort.py | .py | 3efc5f4aacb4fa54 | 7.54 | 11 |
"""Shell fragments that start ONE agent CLI, shared by every launch path.
MindFlock launches an agent from three places, and they must agree about which
CLI they are launching and how:
* the **provisioned workspace launcher** (:mod:`backend.session.provisioned`)
— the ``.mindflock_launch.sh`` script a ticket/PR... | MindFlock/MindFlock | backend/providers/launch_script.py | .py | 94853be30c6d59c2 | 7.54 | 11 |
"""Run a session's agent CLI against a LOCAL model server.
Why this exists: every bundled CLI otherwise talks to a hosted API, so running
MindFlock at all required a paid subscription or an API key, and the privacy
story stopped at "we don't send it anywhere extra" rather than "nothing leaves
the machine". Point the C... | MindFlock/MindFlock | backend/providers/local_models.py | .py | 898eff6bb2697b25 | 7.54 | 11 |
"""Model $ pricing + context windows, sourced from the AI Pricing Guru feed.
Public endpoint: ``https://www.aipricing.guru/api/pricing.json`` — ~120 models
across a dozen providers, refreshed daily (04:00 UTC) and edge-cached 1h. We
cache the payload on disk under the assistant dir and refresh at most once/day.
Every... | MindFlock/MindFlock | backend/providers/pricing.py | .py | 5a89f9d09a0c0be5 | 7.54 | 11 |
"""Per-session resume-thread markers.
Several sessions can share one working directory (in-place sessions and window
copies on the same repo). The CLIs' bulk resume flags (``claude --continue``,
``codex resume --last``) pick the NEWEST conversation for that directory, so
after a restart every sibling resumed the same ... | MindFlock/MindFlock | backend/providers/thread_markers.py | .py | cf2d4d6c32ee1390 | 7.54 | 11 |
"""Rolling-window token/cost totals across ALL Claude Code sessions.
Source of truth is Claude Code's transcripts (``~/.claude*/projects/*/*.jsonl``):
each assistant message's ``usage`` block is that turn's *incremental* tokens with
an ISO ``timestamp``. We make one pass over every transcript, summing entries into
rol... | MindFlock/MindFlock | backend/providers/usage_history.py | .py | 43c329029203a6a7 | 7.54 | 11 |
"""Detect a coding-agent CLI's "usage limit reached" screen and, when it says
so, when the limit resets — so the prompt queue can wait out the limit and
resume exactly when the window reopens (roadmap D).
Pure functions over the agent's terminal text. The patterns are deliberately
SPECIFIC (a bare "rate limit" mention... | MindFlock/MindFlock | backend/providers/usage_limits.py | .py | 304995da3c8db358 | 7.54 | 11 |
"""Parse git remote URLs into ``(host, owner, repo)`` and build forge URLs.
MindFlock never rewrites a user's remote: whatever spelling is in their git
config is the spelling we push to. But several features need to know *which*
repo a remote points at — deriving a branch/compare URL for the browser,
comparing a works... | MindFlock/MindFlock | backend/session/git/remote_url.py | .py | 37a5bea06c8b4611 | 7.54 | 11 |
"""Port of the Go ``session/git`` package's ``worktree_branch.go``.
Provides the multi-error combiner used by ``GitWorktree`` (exposed via
:class:`GitWorktreeBranchMixin`). The joined message header
(``multiple errors occurred:``) and the ``\\n - `` per-error layout match the
Go source byte-for-byte.
"""
from __futu... | MindFlock/MindFlock | backend/session/git/worktree_branch.py | .py | f61623296b668ee5 | 7.54 | 11 |
"""Hand a session's *credentials* to its shell without putting them in argv.
The problem this exists for: every launch path builds one shell string and
hands it to ``tmux new-session … sh -c <string>``. Non-secret values riding
along in that string are harmless — a port number, a cache tag. An auth
profile's API key i... | MindFlock/MindFlock | backend/session/secret_env.py | .py | 42db4c6e3bd1e466 | 7.54 | 11 |
"""Configuration settings for MyGarage application."""
import logging
import os
import re
import tomllib
from pathlib import Path
from pydantic import Field, field_validator
from pydantic_settings import BaseSettings, SettingsConfigDict
from app.utils.secret_key import get_or_create_secret_key
def get_version() ->... | homelabforge/mygarage | backend/app/config.py | .py | a9b2d06e64fea189 | 7.66 | 20 |
"""Unit vocabularies, presets, and the UnitSet model.
Data only. Nothing here reads a database, converts a value, or depends on a
request. The ten quantities are D1 of the custom-units spec; the eleventh field,
`secondary_gallon`, is D4b: it resolves which gallon a forced gallon-based
representation uses when the user... | homelabforge/mygarage | backend/app/constants/units.py | .py | 92c6ad60594dba49 | 7.66 | 20 |
"""Database configuration and session management."""
import logging
from collections.abc import AsyncGenerator
from sqlalchemy import event
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
from sqlalchemy.orm import DeclarativeBase
from app.config import settings
logger = log... | homelabforge/mygarage | backend/app/database.py | .py | b04a2d8b00f29b1d | 7.66 | 20 |
"""Custom exceptions for MyGarage application."""
from typing import Any
class SSRFProtectionError(Exception):
"""Raised when a URL fails SSRF (Server-Side Request Forgery) validation.
This exception indicates that a URL was blocked for security reasons,
either because it points to a private/internal re... | homelabforge/mygarage | backend/app/exceptions.py | .py | f2851361b1f37de4 | 7.66 | 20 |
"""Security middleware for MyGarage application.
These are written as pure ASGI middleware rather than Starlette's
`BaseHTTPMiddleware` because the latter buffers the entire response
body through an internal asyncio queue before forwarding it. That
defeats streaming responses (e.g. `FileResponse` for photos and
backup... | homelabforge/mygarage | backend/app/middleware.py | .py | 97d736884d9318c7 | 7.66 | 20 |
"""
Migration: Add VIN decoded fields to vehicles table
Adds fields from NHTSA VIN decode:
- trim, body_class, drive_type, doors, gvwr_class, displacement_l,
- cylinders, fuel_type, transmission_type, transmission_speeds
"""
import os
from pathlib import Path
from sqlalchemy import create_engine, inspect, text
def... | homelabforge/mygarage | backend/app/migrations/001_add_vin_fields.py | .py | fdea18cad7a2ca2d | 7.66 | 20 |
"""Add window sticker fields to vehicles table for sticker upload and OCR data."""
import os
from pathlib import Path
from sqlalchemy import create_engine, inspect, text
def _get_fallback_engine():
"""Build a SQLite engine from environment for standalone execution."""
db_path = os.environ.get("DAT... | homelabforge/mygarage | backend/app/migrations/003_add_window_sticker_fields.py | .py | 8b28d208ab32f7b8 | 7.66 | 20 |
"""Add enhanced window sticker fields to vehicles table for full data extraction."""
import os
from pathlib import Path
from sqlalchemy import create_engine, inspect, text
def _get_fallback_engine():
"""Build a SQLite engine from environment for standalone execution."""
db_path = os.environ.get("DATABASE_PA... | homelabforge/mygarage | backend/app/migrations/004_add_window_sticker_enhanced_fields.py | .py | c525c75a5349adde | 7.66 | 20 |
"""Add thumbnail_path column to vehicle_photos for thumbnail support."""
import os
from pathlib import Path
from sqlalchemy import create_engine, inspect, text
def _get_fallback_engine():
"""Build a SQLite engine from environment for standalone execution."""
db_path = os.environ.get("DATABASE_PATH")
if ... | homelabforge/mygarage | backend/app/migrations/005_add_vehicle_photo_thumbnails.py | .py | aebfcb8a2f5f7007 | 7.66 | 20 |
"""Update service_type CHECK constraint to include Collision and Upgrades."""
import os
from pathlib import Path
from sqlalchemy import create_engine, inspect, text
def _get_fallback_engine():
"""Build a SQLite engine from environment for standalone execution."""
db_path = os.environ.get("DATABASE... | homelabforge/mygarage | backend/app/migrations/006_update_service_type_constraint.py | .py | 142bf7c4a50962eb | 7.66 | 20 |
"""Add is_hauling column to fuel_records for tracking towing/hauling trips."""
import os
from pathlib import Path
from sqlalchemy import create_engine, inspect, text
def _get_fallback_engine():
"""Build a SQLite engine from environment for standalone execution."""
db_path = os.environ.get("DATABASE_PATH")
... | homelabforge/mygarage | backend/app/migrations/007_add_fuel_hauling_column.py | .py | 92838b51cb6da099 | 7.66 | 20 |
"""Add electric, water, and waste utility columns to spot_rentals table."""
import os
from pathlib import Path
from sqlalchemy import create_engine, inspect, text
def _get_fallback_engine():
"""Build a SQLite engine from environment for standalone execution."""
db_path = os.environ.get("DATABASE_PATH")
... | homelabforge/mygarage | backend/app/migrations/008_add_spot_rental_utilities.py | .py | be6390b4a075d16e | 7.66 | 20 |
"""Add propane_gallons column to fuel_records for tracking propane refills."""
import os
from pathlib import Path
from sqlalchemy import create_engine, inspect, text
def _get_fallback_engine():
"""Build a SQLite engine from environment for standalone execution."""
db_path = os.environ.get("DATABASE_PATH")
... | homelabforge/mygarage | backend/app/migrations/009_add_fuel_propane_column.py | .py | 9f87ea5170571073 | 7.66 | 20 |
"""Migrate password hashing from bcrypt to Argon2.
This migration marks the transition to Argon2id for password hashing.
No database schema changes are required - the existing hashed_password
column (String 255) is sufficient for both bcrypt and Argon2 hashes.
Migration strategy:
- New passwords are hashed with Argon... | homelabforge/mygarage | backend/app/migrations/010_migrate_to_argon2.py | .py | 5d8844fd4ef39a6d | 7.66 | 20 |
"""Add OIDC authentication fields to users table.
This migration adds support for OIDC/SSO authentication by adding:
- oidc_subject: The 'sub' claim from the OIDC provider (unique identifier)
- oidc_provider: Name of the OIDC provider (e.g., 'Authentik', 'Keycloak')
- auth_method: Authentication method ('local' or 'oi... | homelabforge/mygarage | backend/app/migrations/011_add_oidc_fields.py | .py | c58b1d69f3cef997 | 7.66 | 20 |
"""Security hardening migration - CSRF protection and OIDC state persistence.
This migration adds two new tables to support enhanced security:
1. csrf_tokens: Implements synchronizer token pattern for CSRF protection
2. oidc_states: Persists OIDC authentication flow state
"""
import os
from pathlib import Path
from... | homelabforge/mygarage | backend/app/migrations/012_security_hardening.py | .py | 3dbf2b6530c10382 | 7.66 | 20 |
"""Add user_id column to vehicles table for multi-user support.
This migration implements per-vehicle ownership by adding a user_id foreign key
to the vehicles table. Assigns all existing vehicles to the first user.
"""
import os
from pathlib import Path
from sqlalchemy import create_engine, inspect, text
def _get... | homelabforge/mygarage | backend/app/migrations/013_add_user_id_to_vehicles.py | .py | c598f44eba7e1aa1 | 7.66 | 20 |
"""Hydrate VehiclePhoto entries for existing filesystem photos (one-time migration)."""
import logging
import os
from pathlib import Path
from PIL import Image, ImageOps, UnidentifiedImageError
from sqlalchemy import create_engine, inspect, text
from sqlalchemy.orm import Session
logger = logging.getLogger(__name__)... | homelabforge/mygarage | backend/app/migrations/014_hydrate_legacy_photos.py | .py | 54b8ab34449498e5 | 7.66 | 20 |
"""Add OIDC pending links table for username-based account linking.
This migration adds support for username-based OIDC account linking with password
verification. When a user logs in via OIDC and their username matches an existing
local account (but no OIDC link exists), they are prompted to verify their password
bef... | homelabforge/mygarage | backend/app/migrations/015_add_oidc_pending_links.py | .py | 523c48c3ba472b8d | 7.66 | 20 |
"""Add unit preference to user settings.
This migration adds support for per-user unit system preferences (imperial vs metric).
All data remains stored in imperial units; this setting controls display conversion only.
"""
import os
from pathlib import Path
from sqlalchemy import create_engine, inspect, text
def _g... | homelabforge/mygarage | backend/app/migrations/016_add_unit_preference.py | .py | 3eec4e35c340f306 | 7.66 | 20 |
"""Add vehicle archive system.
This migration implements soft-delete functionality for vehicles with archive metadata.
"""
import os
from pathlib import Path
from sqlalchemy import create_engine, inspect, text
def _get_fallback_engine():
"""Build a SQLite engine from environment for standalone execution."""
... | homelabforge/mygarage | backend/app/migrations/017_add_vehicle_archive.py | .py | d97262ac090e3c27 | 7.66 | 20 |
"""Add spot_rental_billings table for tracking individual billing entries."""
import os
from pathlib import Path
from sqlalchemy import create_engine, inspect, text
def _get_fallback_engine():
"""Build a SQLite engine from environment for standalone execution."""
db_path = os.environ.get("DATABASE_PATH")
... | homelabforge/mygarage | backend/app/migrations/018_add_spot_rental_billings.py | .py | 91e6e3cffb2358ca | 7.66 | 20 |
"""Add Electric Vehicle support: kwh column to fuel_records and Electric/Hybrid vehicle types."""
import os
from pathlib import Path
from sqlalchemy import create_engine, inspect, text
def _get_fallback_engine():
"""Build a SQLite engine from environment for standalone execution."""
db_path = os.environ.get... | homelabforge/mygarage | backend/app/migrations/019_add_ev_support.py | .py | 77f221b15f5758b3 | 7.66 | 20 |
"""Add TravelTrailer vehicle type.
This migration adds 'TravelTrailer' as a new vehicle type option.
Background:
- TravelTrailer is for bumper-pull recreational trailers with living quarters
- FifthWheel is for gooseneck recreational trailers with living quarters
- Trailer is for utility/cargo/boat/equipment trailers... | homelabforge/mygarage | backend/app/migrations/020_add_travel_trailer_type.py | .py | 996918596ebd20ad | 7.66 | 20 |
"""Add propane tank size tracking columns.
This migration adds tank_size_lb and tank_quantity columns to fuel_records table
to support propane tank-based entry and analytics.
Background:
- Tank sizes: 20lb, 33lb, 100lb, 420lb (common RV propane tank sizes)
- Conversion: gallons = pounds ÷ 4.24
- Both fields optional ... | homelabforge/mygarage | backend/app/migrations/021_add_propane_tank_columns.py | .py | d752707d1f07d5e0 | 7.66 | 20 |
"""Redesign service_records schema: separate category from specific service type.
Changes:
1. Rename service_type → service_category (keep nullable, keep CHECK constraint)
2. Rename description → service_type (increase to 100 chars, make required)
3. Set all service_type = 'General Service' (user updates via UI later)... | homelabforge/mygarage | backend/app/migrations/022_redesign_service_type_schema.py | .py | e2905672669a8730 | 7.66 | 20 |
"""Add maintenance_templates table for tracking applied maintenance schedules."""
import os
from pathlib import Path
from sqlalchemy import create_engine, inspect, text
def _get_fallback_engine():
"""Build a SQLite engine from environment for standalone execution."""
db_path = os.environ.get("DATABASE_PATH"... | homelabforge/mygarage | backend/app/migrations/023_add_maintenance_templates.py | .py | d159e2aae6a8726d | 7.66 | 20 |
"""Add tsbs table for Technical Service Bulletin tracking."""
import os
from pathlib import Path
from sqlalchemy import create_engine, inspect, text
def _get_fallback_engine():
"""Build a SQLite engine from environment for standalone execution."""
db_path = os.environ.get("DATABASE_PATH")
if db_path:
... | homelabforge/mygarage | backend/app/migrations/024_add_tsbs_table.py | .py | 6550c4d98150517b | 7.66 | 20 |
"""Add shop finder fields to address_book and service_records."""
import os
from pathlib import Path
from sqlalchemy import create_engine, inspect, text
def _get_fallback_engine():
"""Build a SQLite engine from environment for standalone execution."""
db_path = os.environ.get("DATABASE_PATH")
if db_path... | homelabforge/mygarage | backend/app/migrations/025_add_shop_finder_fields.py | .py | c9e1595ec3a95000 | 7.66 | 20 |
"""Migration 026: Add Detailing category and repurpose TSB column.
This migration:
1. Drops the unused TSB column from service_records table
2. Adds service_category column with CHECK constraint including 'Detailing'
3. Updates existing service_category constraint to include 'Detailing'
Since the TSB column is unused... | homelabforge/mygarage | backend/app/migrations/026_add_detailing_category.py | .py | a85cb9bd3d2691c4 | 7.66 | 20 |
"""Add POI support to address_book table."""
import os
from pathlib import Path
from sqlalchemy import create_engine, inspect, text
def _get_fallback_engine():
"""Build a SQLite engine from environment for standalone execution."""
db_path = os.environ.get("DATABASE_PATH")
if db_path:
return crea... | homelabforge/mygarage | backend/app/migrations/027_add_poi_support.py | .py | af7e5ca9a5aef8c3 | 7.66 | 20 |
"""Cleanup reminders that were converted to maintenance_schedule_items in migration 028.
This migration removes reminders that were converted to schedule items but not deleted
due to the delete logic being added after the initial migration run.
"""
import os
from pathlib import Path
from sqlalchemy import create_eng... | homelabforge/mygarage | backend/app/migrations/029_cleanup_migrated_reminders.py | .py | 91bb9831dcf86c43 | 7.66 | 20 |
"""Migrate service attachments from old service_records to new service_visits.
This migration:
1. Updates the attachment CHECK constraint to include 'service_visit'
2. Maps existing 'service' attachments to 'service_visit' using date+VIN matching
3. Updates record_type and record_id accordingly
Constraint update and ... | homelabforge/mygarage | backend/app/migrations/030_migrate_service_attachments.py | .py | 2b6f31b58a3c222c | 7.66 | 20 |
"""Add tax and fees columns to service_visits table.
This migration adds:
- tax_amount: Sales tax
- shop_supplies: Shop supplies/environmental fees
- misc_fees: Miscellaneous fees (disposal, etc.)
These allow the total cost to match real-world invoices that include
additional charges beyond just parts and labor.
"""
... | homelabforge/mygarage | backend/app/migrations/031_add_service_cost_breakdown.py | .py | 0a12af0787d76b4e | 7.66 | 20 |
"""Seed DTC definitions table with SAE J2012 standard codes.
This migration loads ~3000 generic OBD-II DTC codes from the bundled JSON file.
Covers P, B, C, and U code categories.
Data sourced from: https://github.com/mytrile/obd-trouble-codes
Licensed under MIT.
Phase 1 scope: code + description + category + severi... | homelabforge/mygarage | backend/app/migrations/033_seed_dtc_definitions.py | .py | 96d7118a77645656 | 7.66 | 20 |
"""Add LiveLink settings to settings table.
This migration adds the default LiveLink configuration settings:
- livelink_enabled: Master enable/disable toggle
- livelink_global_token_hash: Hashed global API token
- livelink_telemetry_retention_days: Raw data retention period
- livelink_session_timeout_minutes: Timeout ... | homelabforge/mygarage | backend/app/migrations/034_add_livelink_settings.py | .py | df03b4b9c0a4f2be | 7.66 | 20 |
"""Add source column to odometer_records table.
This migration adds a 'source' column to track where odometer readings came from:
- 'manual': User entered manually (default)
- 'livelink': Auto-recorded from LiveLink telemetry
- 'service': Recorded during service visit
- 'fuel': Recorded during fuel fill-up
This allow... | homelabforge/mygarage | backend/app/migrations/035_add_odometer_source.py | .py | 2e70dc3cff600e4e | 7.66 | 20 |
"""Add MQTT settings for LiveLink MQTT integration.
Adds settings to support MQTT subscription from WiCAN devices
as an alternative to HTTPS POST ingestion.
"""
import os
from pathlib import Path
from sqlalchemy import create_engine, text
def _get_fallback_engine():
"""Build a SQLite engine from environment fo... | homelabforge/mygarage | backend/app/migrations/036_add_mqtt_settings.py | .py | 8280858e99593189 | 7.66 | 20 |
"""DHL Package Tracker custom component for Home Assistant."""
from __future__ import annotations
import logging
from dataclasses import dataclass
from typing import Any
import aiohttp
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
from homeassistant.cor... | ha-parcel-integrations/ha-dhl-nl | custom_components/dhl_nl/__init__.py | .py | ebeef6f1734049d3 | 7.56 | 12 |
"""Button platform for the DHL Package Tracker integration."""
from __future__ import annotations
from homeassistant.components.button import ButtonEntity
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import DhlConfigEntry
from .device import... | ha-parcel-integrations/ha-dhl-nl | custom_components/dhl_nl/button.py | .py | f96189f8322310ca | 7.56 | 12 |
"""Calendar platform for the DHL Package Tracker integration."""
from __future__ import annotations
from datetime import datetime, timedelta
from typing import Any
from homeassistant.components.calendar import CalendarEntity, CalendarEvent
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity... | ha-parcel-integrations/ha-dhl-nl | custom_components/dhl_nl/calendar.py | .py | d81b1128b8001ff0 | 7.56 | 12 |
"""Coordinator for the DHL Package Tracker integration."""
from __future__ import annotations
import logging
from datetime import datetime, timedelta, timezone
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryAuthFailed
f... | ha-parcel-integrations/ha-dhl-nl | custom_components/dhl_nl/coordinator.py | .py | a463f21ba41f94e5 | 7.56 | 12 |
"""Sample DHL API payloads shared by the test modules.
These are the **raw** shapes the API returns — what ``normalize_parcel`` and the
coordinator consume. Keep them here rather than inline in each test module:
when the payload shape turns out to differ from what we assumed, there is then
exactly one place to fix.
E... | ha-parcel-integrations/ha-dhl-nl | tests/payloads.py | .py | f6efe26367315725 | 8.06 | 12 |
"""Tests for the DHL deliveries calendar."""
from datetime import datetime, timezone
from unittest.mock import MagicMock
from custom_components.dhl_nl.calendar import DhlDeliveriesCalendar
from custom_components.dhl_nl.coordinator import normalize_parcel
USER_INFO = {"userId": "user123", "email": "test@example.com"}
... | ha-parcel-integrations/ha-dhl-nl | tests/test_calendar.py | .py | f0ab4acee31853ea | 8.06 | 12 |
"""Shared .env parsing/loading, with optional per-environment overlay files."""
import os
ENV_VAR = "ENV"
def resolve_environment(explicit=None):
"""CLI flag wins over $ENV; neither means no overlay file."""
return explicit or os.environ.get(ENV_VAR)
def _parse_env_file(path):
result = {}
if not o... | borhara/cordless | src/cordless/_env.py | .py | ab92c936ede78627 | 7.54 | 11 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.