🌐
Site Database
?
Overview
Barns
Active Sites
0
of 0 total sites
Total Capacity
0
head across all sites
Avg Occupancy
0%
heads on site
Alerts
0
Warning or Alert status
All
Active
Warning
Inactive
SiteStatusPremise IDLocationCapacity / OccupancyPhaseOwnerManagerActions
Barns
Dimensions, install dates and facility records per barn
Total Staff
0
labor + on-site contacts
Open Tasks
0
outstanding items
Sites Monitored
0
with health records
Sites Healthy
0
no disease flags
Site Management
Contacts, health status, staff & tasks — expand a site to view details
Active Contracts
Across all sites
Total Contracts
0
across all sites
Expiring Soon
0
within 90 days
Expired
0
awaiting renewal
Contracts by Site
Expand a site to view its contracts
Utility Accounts
0
across all sites
Utilities by Site
Expand a site to view its utility accounts
Total Feed On Hand
across all bins
Avg Lbs/Pig/Day
barn average
Low Bins
0
below alert threshold
Pending Orders
0
awaiting delivery
Bins & Readings
Inventory
Feed Orders
Click a barn to log readings or deliveries. Bins are configured from the barn database.
Overview
MMP Info
Avg Fill Level
0%
Across all pits
Near Full
0
Within 18" of capacity
Pits Monitored
0
With depth data
Avg Depth
0"
Overall pit depth
Pit Management by Site
Expand a site to view and update its manure pits
MMP Info
Manure Management Plan — upload a PDF per site to store and extract plan details
Work Orders
Order Supplies
Open
0
Awaiting action
In Progress
0
Actively being worked
Resolved
0
Completed this month
High Priority
0
Urgent items
Work Orders by Site
Expand a site to view its work orders
Order Supplies
Submit supply requests by site
Total Tank Capacity
0
gallons across all tanks
Est. Remaining
0
gallons on hand
Low Tanks
0
tanks below threshold
24-Hr Usage
0
gallons used since last import
LP Tanks by Site
Current fill level, usage history, and days to empty per tank
Previous 24 Hr
History
Distynct Sites — Live Data
Daily temp, water, pit level via Distynct API · 1 site · 4 rooms · Updated Daily
Loading…
AP Connect Sites — Live Data
Daily temp, humidity, heater & feeder runtime, water · 8 sites · 28 rooms · Updated Daily
Loading…
🌡 Agri-Alert Sites — Live Data
Daily hi/lo temp & water spill via Agri-Alert gateway · Updated every 5 min
Loading…
Barn Conditions by Site
Import your daily export below · Click any site to expand barn-level temp and water data
SUN
MON
TUE
WED
THU
FRI
SAT
📊 Reports
Period:
Site:
Loading reports…
Messaging Settings
All SMS and email — login credentials, automatic alerts, and mass communications — route through these settings.
TWILIO SMS Channel — used for login notifications, alerts & mass communications
From Number
Your Twilio number (E.164 format)
Account SID
Auth Token
GMAIL Email Channel — sends from prairieconsultingiowa@gmail.com
Google Apps Script URL
Deploy once — handles both email and SMS via Twilio. Click Setup Guide above for instructions.
Anthropic API Key (for MMP AI scanning)
Get your key at console.anthropic.com → API Keys. Used to scan MMP PDFs.
Broadcast Message
Send a one-time SMS and/or email to groups or individual users. Uses your Twilio number and Gmail above.
Group
Send Via
Message
0 chars
AP Connect Accounts
Store API keys by account name. Assign accounts to sites in Site Database — all barns on that site inherit the key.
AP Connect Room Mapping
Match each AP Connect room to its barn card in the dashboard. One-time setup — saves to Firebase.
AP Connect Room
Dashboard Site
Dashboard Barn Card
Status
LP Tank Mapping
Map LP tanks to sites and barns. A single tank can feed one barn or multiple barns.
Click Load Tanks from Firebase to pull the latest LP readings and map them to your sites.

How it works: Your daily LP email gets forwarded to prairieconsultingiowa@gmail.com → the Cloud Function parses it → readings appear here → you assign each tank to a site once → from then on, levels update automatically every day.
Work Order Email Recipients
New work orders are automatically emailed to these addresses from prairieconsultingiowa@gmail.com. Admin only.
Changes save automatically and take effect immediately for all new work orders.
Work Order Permissions
Control which users can submit work orders for each site. Admins always have full access.
Open Admin tab to load.
Total Users
0
Registered accounts
Active Sessions
1
Currently logged in
Administrators
0
Full access accounts
Restricted Users
0
Site-limited access
Users
Select a user to edit permissions
Select a user to edit their permissions
Integrator Contacts
Store contact info per integrator. Auto-populates the Contracts tab when an integrator is selected.
Integrator
Contact Name
Title
Email
Phone
No contacts yet. Click + Add Contact to begin.
Notification Preferences
Control which users receive email notifications for each event type and site.
Open Admin tab to load.
🌽 Feed Notifications
Configure who receives low feed and Thursday reminder alerts. Only individuals tied to the generating site will be notified.
Biosecurity / BSPL Notifications
Automatic alerts when sites change BSPL status — Hold, PED Positive, or return to Negative.
Variance Notifications
Daily email at 6:00 AM CST — water usage variance alerts across all sites.
🐷 Polaris Sync
Sync pig inventory, placements, and movements from Seaboard Polaris into the dashboard and calendar.
📌 Step 1 — Add the Polaris Sync button to your bookmarks
Drag this button to your Chrome bookmarks bar. When you're logged into Polaris, click it to fetch all data and auto-sync it to this dashboard.
🚀 Sync Polaris to Dashboard
Manual Token Fallback (optional)
The bookmarklet above handles everything automatically. This field is only a backup if you want to test a token manually. Tokens expire after ~1 hour.
Step 3 — Choose What to Sync
Farm Number → Site Mapping
Maps Seaboard farm numbers to Prairie site IDs. Edit if a farm is incorrectly matched.
🔁 How to Refresh the Polaris Token (when daily sync fails with 401)
When does this need to happen?
The Apps Script polarisSyncDaily runs automatically every night and rotates its own refresh token each time it runs — so under normal operation you do nothing. But if the chain ever gets broken (typically because Polaris sat unused for 30+ days, or you manually logged out everywhere, or the daily trigger failed for too long), the next run will fail with Token refresh failed: 400 invalid_grant or 401. You'll get an automatic error email from Apps Script. When that happens, follow the steps below.
Step-by-step
  1. Open Polaris in Chrome and log in (Growing Pig Farm Manager or any Polaris app).
  2. Open DevTools: press F12. Click the Network tab at the top of DevTools.
  3. Filter for token requests: in the filter box at the top of the Network panel, type token.
  4. Trigger a token request: click around in Polaris (change a date, navigate to a different farm, or just wait 30-60 seconds). A row named token with path /multipass/api/oauth2/token will appear in the list.
  5. Click that token row. A panel opens on the right with tabs: Headers / Payload / Preview / Response.
  6. Click the Response tab (NOT Payload — Payload has the OLD token being sent up; Response has the NEW token coming back).
  7. You'll see JSON like:
    {
      "access_token": "eyJ...long...",
      "refresh_token": "Ax9pQ8...short...",   ← copy this
      "expires_in": 3600,
      "token_type": "bearer"
    }
    Copy the value of refresh_token. It's a short string, usually 20-30 characters.
  8. Open the Apps Script editor: go to script.google.com → open Prairie Consulting AutomationPolarisSync.gs file.
  9. Find setupPolarisAuth() (around line 50). You'll see a line like:
    var refreshToken = 'oldTokenValueHere';
    Replace the value between the quotes with the new refresh token you just copied. Save (Ctrl+S).
  10. From the function dropdown at the top of Apps Script, select setupPolarisAuth. Click Run. Watch the Execution log at the bottom — should show:
    ✅ Setup complete. Got access token starting: eyJ...
  11. Test the full sync by selecting polarisSyncDaily from the dropdown and clicking Run. Should write ~135+ records to Firebase.
  12. Done. The daily trigger will keep working from here. You don't need to touch the trigger or anything else.
Heads up: using a refresh token in Apps Script invalidates your current Chrome Polaris session within ~1 hour. After that, you'll need to log into Polaris in Chrome again. This is normal — it's the trade-off for permanent automation.
Pig Intake Metrics
Reference growth & water intake curves. Edit phase values to adjust the daily water chart.
Typical Commercial Pig Growth Curve (extension-based averages)
Age
Approx Weight
Typical Water Intake (gallons per pig per day)
Pig Type / Weight
Gal / Day
Industry Standard Daily Water Consumption by Day of Life
🟦 Nursery · Days 1–56
🟩 Grower · Days 57–83
🟨 Finisher · Days 84–200
■ Nursery (1–56) ■ Grower (57–83) ■ Finisher (84–182)
Daily Water Values — All 200 Days
Day
Gal/Day
Day
Gal/Day
Day
Gal/Day
Phase
Barn Conditions Card Color Thresholds
Water usage is compared to expected gal/head × inventory using the curve above and the site's animal age. Grow-Finish sites automatically add 56 days to reported age.
🟢 Normal — below amber
Actual ≤ expected + amber %
🟡 Amber — elevated
% above expected
🔴 Red — high alert
% above expected
Weight Estimation Formula
Est. Weight (lb) = pigWeightValues[adjustedDay - 1]
Where adjustedDay = reported ageInDays from AP Connect
   + 56 days if site Phase = Grow-Finish
Clamped to days 1–200. Value is per pig, not total weight.
Prairie Daily Water Consumption by Day of Life
Real-world gal/head data collected from all AP Connect sites. Each point = one barn-day. Automatically excludes flagged records. Temperature shown as overlay.
● Prairie Gal/Head — Industry Standard — Hi Temp °F (÷10 scale)
Recent Records
DATE
SITE
BARN
DOL
HEAD
GAL
GAL/HD
HI°F
EXCL
Toggle EXCL to flag wash cycles or inventory errors. Excluded records are hidden from the chart but preserved in the database.
Estimated Weight Curve (lbs per pig · same phase structure as water)
Feed Conversion Ratio (FCR)
Lbs of feed required per 1 lb of weight gain. Used with placement weight + feed data to calculate estimated current weight. Typical grow-finish: 2.6–3.0.
🟦 Nursery · Days 1–56
🟩 Grower · Days 57–83
🟨 Finisher · Days 84–200
■ Nursery (1–56) ■ Grower (57–83) ■ Finisher (84–182)
Daily Weight Values — All 200 Days
Day
Lbs
Day
Lbs
Day
Lbs
Phase
Import Site Fields
Upload a CSV or XLSX to fill in Premise ID, owner contact info, address, etc. Default: only empty fields are updated. Check "Replace existing values" to overwrite everything from the spreadsheet.
Columns matched by name (flexible order): Site ID or Site Name · Premise ID · Owner Entity · Owner Name · Owner Address · Owner City · Owner State · Owner Zip · Owner Phone · Owner Email
Data Backup & Restore
Export all data to a file to back it up or transfer to a new version of this app. Import to restore.
Firebase Cloud Sync Local only
Sync all data across devices in real time using Firebase Realtime Database.
Paste your Firebase Realtime Database URL above, then click Connect.
How to set up Firebase (free, 5 minutes)
1 Go to console.firebase.google.com and sign in with your Google account.
2 Click Add Project, give it a name (e.g. Prairie Consulting), and complete the setup wizard.
3 In the left sidebar click Build → Realtime DatabaseCreate Database → choose your region → select Start in test mode → click Enable.
4 You'll see a URL at the top of the Realtime Database page like: https://prairie-consulting-default-rtdb.firebaseio.com — copy it.
5 Fix database rules (critical step): In the Firebase console go to Realtime Database → Rules tab. Replace everything with:
{"rules":{".read":true,".write":true}} Then click Publish. Without this step the connection will be denied.
6 Paste the URL in the field above and click Connect. All your data will sync automatically across every device.
⚠️ Important: Firebase sync only works when the file is served from a web server — not opened directly from your desktop (file://). The easiest options:
  • Drag this file to app.netlify.com/drop for free instant hosting
  • Or host it on any web server / shared drive that serves HTTP
Pit Gallons Formula
Formula used to calculate gallons from pit measurements. Variables: width, length, level (all in feet after conversion).
Default formula: width * length * level / 12 * 7.48 — pit floor area (ft²) × depth (ft) × 7.48 gal/ft³. Post Pumping Minimum Level is the inches that must remain after pumping — used to calculate pumpable gallons on each pit card.
Application Rate Formulas
Formulas used to calculate application rates. Variables: n, p, k, countyYield, suppN, gallons.
County Yields
🔒
DANGER ZONE — AUTHORIZED USERS ONLY
Authorization by Troy Pflughaupt required for all actions below
⚠️ Clear All Data
Permanently deletes ALL site data and starts fresh. Cannot be undone — export a backup first.
⚠️ Clear Sites Only
Deletes all sites from the database. Other data (users, work orders, etc.) is preserved.
Total Head Placed
0
across all barns
Current Inventory
0
placed − mort − marketed
Total Deads
0
cumulative all barns
Total Euthanized
0
cumulative all barns
Total Marketed
0
cumulative all barns
Total Culls
0
cumulative all barns
Barn Group Tracking
Per-barn livestock inventory, mortality & marketing records
No barns added yet. Click Auto-populate from Barns to create entries for all barns, or + Add Barn to add one manually.
Medication Alerts
0
barns requiring medication
Active Withdrawals
0
pending drug-free dates
Drug-Free Barns
0
no active withdrawal
Barns Tracked
0
with vet records
Barn Veterinary Records
Per-barn medication tracking, withdrawal times & drug-free dates
No barns added yet. Click + Add Barn to begin tracking veterinary records.