241 Commits
Author SHA1 Message Date
Brenda Wallace 4d53b24e9a Enhance photo and seed resources with new attributes and filters
- Added `label` computed attribute to `PhotoResource` to indicate the side of the seed packet.
- Introduced `needs_ocr` filter in `PhotoResource` to identify photos awaiting OCR processing.
- Updated `SeedResource` to associate photos with seeds.
- Modified `photos_request_spec` to include seed relationships and test for photo labels.
- Added filtering tests for photos needing OCR in `photos_request_spec`.
- Removed obsolete Rake task for listing photos needing OCR.
- Updated `read_packets.py` to fetch photos needing OCR from the API.
2026-10-28 23:20:42 +13:00
Brenda Wallace a5e5ce4988 Merge remote-tracking branch 'origin/main' into seed-packet-photo-sides
# Conflicts:
#	db/schema.rb
2026-10-28 21:57:32 +13:00
Brenda Wallace 96e37b6c90 feat: Enhance photo handling in posts with new features and UI updates 2026-10-28 21:50:26 +13:00
Brenda Wallace 232a62c3a8 feat: Enhance post editor with link suggestions for crops, members, and plantings 2026-10-28 21:50:26 +13:00
Brenda Wallace cd6f8f1876 feat: add packet labeling functionality and awaiting text scope for seed photos 2026-10-28 20:44:37 +13:00
Brenda Wallace 1701f77723 Add OCR task for seed packet photos and related specs
- Introduced a Rake task `packets:needing_ocr` to list photos of seed packets that lack text, outputting results as JSON lines.
- Created a Python script `read_packets.py` to process the output of the Rake task, downloading images and performing OCR to extract text.
- Updated model specs for `Crop` to ensure proper handling of photos associated with different seeds.
- Refactored API request specs for `Photos` and `Seeds`, removing unnecessary attributes from the response.
- Added tests for the new Rake task to ensure correct functionality and output format.
2026-10-28 20:23:35 +13:00
9ff8a5491b Run photos:prune_404s rake task monthly (#5107)
* Run photos:prune_404s task monthly on the 1st of the month

Assuming Heroku Scheduler invokes the task daily, check if today is
the first day of the month before pruning 404 photos. Also add spec to test this behavior.

Co-authored-by: CloCkWeRX <365751+CloCkWeRX@users.noreply.github.com>

* Delete spec/tasks/photos_prune_404s_spec.rb

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2026-10-26 23:26:38 +10:30
Daniel O'Connor ca4e1961e7 Run wikidata maintenance as cropbot (#5106) 2026-10-26 23:21:51 +10:30
Brenda Wallace dfffafca52 Add harvest reminders feature and update related specs and locales 2026-10-26 19:38:38 +13:00
Brenda Wallace 948cc59d1b Remove Sidekiq integration and update mailer delivery methods to deliver immediately 2026-10-26 19:38:38 +13:00
Brenda Wallace 3c8645ce05 Add planting reminders feature and corresponding tests 2026-10-26 19:38:38 +13:00
Brenda Wallace 6332f26c58 Merge pull request #4994 from Growstuff/crop-job-templates-admin
Admin for crop job templates, a tidier crop wrangling page, and crop and template seeds
2026-10-23 13:26:33 +10:30
Brenda Wallace a0b24381ac Refactor activities to jobs across the application
- Renamed all instances of 'Activity' to 'Job' in views, controllers, and models.
- Updated routes to reflect the change from activities to jobs.
- Modified database schema to rename the activities table to jobs and adjusted related columns.
- Updated locale files to change activity-related translations to jobs.
- Adjusted tests to ensure they reference jobs instead of activities.
- Removed the category field from jobs as they are now a plain list.
- Updated seed data and sample data generation to create jobs instead of activities.
2026-10-22 17:16:25 +13:00
Brenda Wallace 977a984c24 Remove Elasticsearch integration and related code
- Deleted Elasticsearch gems from Gemfile and Gemfile.lock.
- Updated README and TECH documentation to reflect the removal of Elasticsearch.
- Removed Elasticsearch-related code from models, controllers, services, and factories.
- Adjusted tests to eliminate dependencies on Elasticsearch.
- Cleaned up Docker configuration and environment variables related to Elasticsearch.
- Added a TODO file for future gem reviews and potential removals.
2026-10-22 15:37:03 +13:00
Brenda Wallace cd9aa9f651 Remove Elasticsearch configuration and related scripts 2026-10-22 15:37:03 +13:00
Brenda Wallace 793759c7af Remove unused bluecloth gem (#4968)
* Remove unused bluecloth gem

Last released in 2011. It was only required, never called; kramdown
renders the markdown.

* Add specs for Tilt markdown rendering and posts markdown partial
2026-10-19 19:36:32 +10:30
Brenda Wallace 48fa6a6eec Enhance home page layout with new post thumbnail and photo display features; update recent posts section for improved visibility and accessibility. 2026-10-12 21:59:11 +13:00
Brenda Wallace a06b281a1d overlay modal forms for the homepage 2026-10-12 21:45:53 +13:00
Brenda Wallace be38339b02 Refactor member location updates and improve error handling
- Updated MemberLocationsController to use a hash for location updates, ensuring coordinates are not geocoded again.
- Changed response status codes in member_locations_spec to use symbols for better readability.
- Modified PlacesController to use parentheses for defining MEMBER_FIELDS.
- Enhanced SuggestionsController to disable Rails/SkipsModelValidations for update_columns.
- Updated SeasonsHelper to use compact_blank for cleaner output.
- Refactored MemberDashboard service for improved readability and performance.
- Adjusted migration files to use parentheses for index definitions.
- Updated schema.rb to maintain consistency in index definitions.
- Added SampleData class to generate sample data for development.
- Cleaned up sample_data.rake task to utilize the new SampleData class.
- Updated tests in member_dashboard_spec and place_suggester_spec for consistency and readability.
2026-10-12 19:30:21 +13:00
Brenda Wallace 0fef10e45c Refactor home page styles and add sample data task for development 2026-10-12 14:32:08 +13:00
Brenda Wallace 3d64118cdf Merge pull request #4837 from Growstuff/feat/fluent-crop-icons
Give crops icons from Fluent Emoji, chosen by crop wranglers
2026-09-22 18:45:45 +09:30
Daniel O'Connorandgoogle-labs-jules[bot] d3e9da077b Optimize Wikidata rake task using find_each and eager loading (#4812)
- Replace Crop.all.each with Crop.includes(:scientific_names).find_each
- Avoid per-crop N+1 queries when looking up Wikidata IDs from scientific names
- Add RSpec tests for wikidata:import_alternate_names task

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2026-09-20 17:27:11 +09:30
748847edbc Optimize markdownify allocations with in-place gsub! and combined regex (#4805)
* Optimize markdownify allocations with in-place gsub and combined regex

Avoid chaining multiple full-string copies during markdown parsing. Duplicate
the input string once in ApplicationHelper#markdownify and modify it in-place
using gsub! in GrowstuffMarkdown#expand_crops! and #expand_members!.
Combine MEMBER_REGEX and MEMBER_AT_REGEX with Regexp.union to parse member
mentions in a single pass.

Co-authored-by: CloCkWeRX <365751+CloCkWeRX@users.noreply.github.com>

* Apply suggestion from @CloCkWeRX

* Apply suggestion from @CloCkWeRX

* Optimize markdownify allocations with in-place gsub and combined regex

Avoid chaining multiple full-string copies during markdown parsing. Duplicate
the input string once in ApplicationHelper#markdownify and modify it in-place
using gsub! in GrowstuffMarkdown#expand_crops! and #expand_members!.
Combine MEMBER_REGEX and MEMBER_AT_REGEX with Regexp.union to parse member
mentions in a single pass.

Co-authored-by: CloCkWeRX <365751+CloCkWeRX@users.noreply.github.com>

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2026-09-20 14:41:13 +09:30
Brenda WallaceandClaude Sonnet 5 23e83b1a5f Add rake tasks to pull crops and a member's data from production (#4803)
* Add rake tasks to pull crops and a member's data from production

crops:pull_from_production copies approved crops, and
members:pull_from_production copies one member's gardens, plantings and
planting photos, from growstuff.org into a local database. Both refuse to
run in a production environment.

They are built to be gentle on a server that has been struggling: one
request at a time with a pause between requests, exponential backoff
(honouring Retry-After) on timeouts, 429s and 5xx, and a hard stop rather
than endless retries. The client also stops if a server keeps sending the
same page, and will not follow a next link to another host.

Gardens and plantings come from the site's own JSON, which carries every
column; the JSON:API only exposes a garden's name, and its related
resource endpoints return the wrong records. Only the crops that a
member's plantings use are fetched. Flickr photos are stored as records
pointing at Flickr's image URLs, as on production, so nothing is
downloaded from Flickr.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Add ACTIVE_ONLY option to the member import

ACTIVE_ONLY=true leaves out the site's all=1 flag, so production lists only
the member's active gardens and current (not finished, not failed)
plantings. The server does the filtering, so it also means fewer requests,
and no crops or photos are fetched for plantings that are skipped.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-20 14:06:01 +09:30
fa7f460510 Refactor Plantings to remove Elasticsearch dependency (#4686)
* Refactor Plantings to remove Elasticsearch dependency

This commit refactors the Plantings controller, model, and views to use
ActiveRecord instead of Searchkick/Elasticsearch.

Key changes:
- Refactored `PlantingsController#index` to use an ActiveRecord-based
  `plantings` method.
- Moved `homepage_records` logic from `SearchPlantings` concern to the
  `Planting` model using ActiveRecord scopes.
- Removed `SearchPlantings` concern and deleted the file.
- Updated `home/_plantings.html.haml` and `plantings/index.rss.haml` to
  use dot notation for `Planting` object attributes.
- Updated specs to remove Searchkick-related setup and assertions.

Co-authored-by: CloCkWeRX <365751+CloCkWeRX@users.noreply.github.com>

* Fix Planting.reindex

* Fix test

* Mark test pending

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2026-06-24 22:26:49 +09:30
6e7cf1c813 Refactor Seeds to remove Elasticsearch dependency (#4684)
* Refactor Seeds to remove Elasticsearch dependency

This commit refactors the `SeedsController` and `Seed` model to remove
dependency on Elasticsearch and Searchkick.

Key changes:
- Removed `SearchSeeds` concern from the `Seed` model.
- Reimplemented `Seed.homepage_records` using ActiveRecord.
- Refactored `SeedsController#index` to use ActiveRecord for filtering,
  eager loading, and pagination.
- Deleted `app/models/concerns/search_seeds.rb`.
- Updated relevant specs to remove Searchkick-specific tags and setup.

Co-authored-by: CloCkWeRX <365751+CloCkWeRX@users.noreply.github.com>

* Remove Seed.reindex

* Remove trait

* Fix tests

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2026-06-24 21:54:43 +09:30
Daniel O'Connor 3edd2510d8 Merge pull request #4683 from Growstuff/refactor-harvests-remove-elasticsearch-14630838429921835504
Refactor harvests to remove Elasticsearch
2026-06-24 20:26:22 +09:30
google-labs-jules[bot]andCloCkWeRX e423e6ac79 Add weekly harvest reminder emails and scheduled task
- Added `send_harvest_reminder` preference to Member model and settings UI.
- Implemented `harvest_in_next_week?` in PredictHarvest concern.
- Created `harvest_reminder` email with localized templates.
- Added `growstuff:send_harvest_reminders` Rake task to run weekly.
- Refactored existing and new reminder tasks to use `deliver_later` for scalability.
- Added unit tests for prediction logic and mailer.
- Fixed a bug in the existing planting reminder task where it was using an uninitialized constant `Notifier`.

Co-authored-by: CloCkWeRX <365751+CloCkWeRX@users.noreply.github.com>
2026-04-30 04:09:26 +00:00
7160f50ac1 Refactor Activity model to remove Elasticsearch integration (#4576)
* Refactor Activity model to remove Elasticsearch integration

- Removed `SearchActivities` concern and Searchkick from `Activity` model.
- Implemented `Activity.homepage_records` using ActiveRecord with `DISTINCT ON` for PostgreSQL.
- Updated `ActivitiesController#index` to use ActiveRecord queries with eager loading and pagination.
- Added `active` scope to `Activity`.
- Added unit tests for `Activity` model.
- Deleted `app/models/concerns/search_activities.rb`.

Co-authored-by: CloCkWeRX <365751+CloCkWeRX@users.noreply.github.com>

* Fix NoMethodError: undefined method 'reindex' for class Activity

- Removed all calls to `Activity.reindex` in migrations, rake tasks, and spec helpers.
- These were causing failures after the removal of Searchkick from the Activity model.

Co-authored-by: CloCkWeRX <365751+CloCkWeRX@users.noreply.github.com>

* Fix ambiguous column id in homepage_records query

- Updated `Activity.homepage_records` to use `activities.id` instead of `id` in the subquery.
- This resolves the `PG::AmbiguousColumn: ERROR: column reference "id" is ambiguous` error.

Co-authored-by: CloCkWeRX <365751+CloCkWeRX@users.noreply.github.com>

* Fix ambiguous created_at in homepage_records query

- Use `unscoped` in the subquery for `Activity.homepage_records` to bypass the default scope from `Ownable` concern.
- This prevents the join with the `members` table in the subquery, which was causing `PG::AmbiguousColumn: ERROR: column reference "created_at" is ambiguous`.

Co-authored-by: CloCkWeRX <365751+CloCkWeRX@users.noreply.github.com>

* Complete refactoring of Activity model to remove Elasticsearch

- Removed SearchActivities concern and searchkick integration.
- Updated ActivitiesController#index to use ActiveRecord queries.
- Implemented performant Activity.homepage_records using DISTINCT ON (PostgreSQL).
- Added Activity.active scope.
- Added no-op Activity.reindex (class and instance methods) for backward compatibility.
- Cleaned up leftover reindex calls in rake tasks, migrations, and spec helpers.
- Added unit tests for new Activity model logic.
- Updated factories to include no-op reindex traits.

Co-authored-by: CloCkWeRX <365751+CloCkWeRX@users.noreply.github.com>

* Less eager loading

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2026-04-28 17:51:01 +09:30
Daniel O'Connor 3127f45d0f Merge pull request #4578 from Growstuff/member-inactive-delete
Delete inactive members with no activity in 3 years
2026-04-27 02:15:17 +09:30
8e7dd25e98 Add rake task to cleanup inactive members (#4574)
* Add members:cleanup_inactive rake task

This task identifies and deletes members who have not logged in for over
24 months and have no gardens, plantings, or other activity (posts,
comments, seeds, harvests, etc).

Includes support for DRY_RUN=true to preview deletions.
Added tests in spec/tasks/members_spec.rb.

Co-authored-by: CloCkWeRX <365751+CloCkWeRX@users.noreply.github.com>

* Refactor activity check to Member#has_activity? and update rake task

- Added `Member#has_activity?` to encapsulate the check for gardens, plantings, and other activity.
- Updated `members:cleanup_inactive` rake task to use `Member#has_activity?`.
- Maintained `DRY_RUN` support and existing tests.

Co-authored-by: CloCkWeRX <365751+CloCkWeRX@users.noreply.github.com>

* Apply suggestion from @CloCkWeRX

* Apply suggestions from code review

Co-authored-by: Daniel O'Connor <daniel.oconnor@gmail.com>

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2026-04-27 01:40:54 +09:30
Daniel O'Connor d625eb2dbd Rubocop: Style/FrozenStringLiteralComment 2026-04-23 14:30:02 +00:00
google-labs-jules[bot] 72e7b7323f feat(rake): Prioritize scientific_names.wikidata_id in task
Improves the `wikidata:import_alternate_names` Rake task to first use the `wikidata_id` from the `scientific_names` table.

- Checks for a `wikidata_id` on a crop's `scientific_names`.
- Falls back to the existing `en_wikipedia_url` if no `wikidata_id` is found.
- Adds logging to indicate the source of the Wikidata ID.
- Improves error handling.
2025-12-01 12:52:49 +00:00
google-labs-jules[bot] 87f79fb071 feat(rake): Prioritize scientific names in Wikidata task
Improves the `wikidata:import_alternate_names` Rake task to first look up a crop's Wikidata ID using its scientific names.

- Iterates through a crop's scientific names to find a Wikidata ID.
- Falls back to the existing `en_wikipedia_url` if no ID is found via scientific names.
- Adds more detailed logging to the task.
- Improves error handling by checking for non-existent Wikipedia pages and using `.dig` for safer hash access.
2025-12-01 12:44:46 +00:00
google-labs-jules[bot] 620337fbac Merge pull request #4353 from Growstuff/feat/import-australian-food-data
Add Rake Task to Import Australian Food Data
2025-12-01 19:43:14 +10:30
Daniel O'Connor cf8380029a Rubocop 2025-09-10 10:19:08 +00:00
google-labs-jules[bot] 4d3c4ca10d Merge pull request #4154 from Growstuff/finish-expired-seeds-task
Add maintenance task to finish expired seeds
2025-08-28 00:16:16 +09:30
google-labs-jules[bot] 8e74d1796a This rake task iterates through all photos and removes any that have a 404 status on their fullsize_url. This will help to keep the database clean of broken photo references. 2025-08-24 23:17:26 +00:00
google-labs-jules[bot]andDaniel O'Connor ac1463e2cf Add international alternate names for crops (#4132)
* I will add the international alternate names for the crops.

* Mark required

* Update factory

* Add placeholder

* Fix seeds

* Add language, though hardcoded to EN in most places

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: Daniel O'Connor <daniel.oconnor@gmail.com>
2025-08-24 21:44:41 +09:30
Daniel O'Connor e1367613e6 Merge branch 'dev' into remove-twitter-auth 2025-08-24 17:08:19 +09:30
Daniel O'Connor 6131fdf141 Delete lib/tasks/openfarm.rake 2025-08-24 17:07:02 +09:30
Daniel O'Connor 44101e07fb Merge branch 'mainline' into dev 2025-08-24 16:40:08 +09:30
Daniel O'Connor b4c1104af0 Merge branch 'dev' into remove-twitter-auth 2025-08-24 16:36:42 +09:30
google-labs-jules[bot] 0b639d5940 Remove twitter authentication
This change removes the twitter authentication feature from the application.

It removes the `omniauth-twitter` gem and all related code from controllers, views, and tests. It also removes the twitter icon and environment variable settings.
2025-08-24 07:03:20 +00:00
google-labs-jules[bot] b72aeab136 Amend delete_pictures rake task to remove legacy S3 photos
The `delete_pictures` rake task in `openfarm.rake` is amended to
also remove Photos where the `fullsize_url` starts with
`https://s3.amazonaws.com/openfarm-project/`.

This change helps in cleaning up legacy photos that are no longer
needed. The task description has also been updated to reflect this
change.
2025-08-24 06:21:19 +00:00
Daniel O'Connor 5da8f815d3 Fix stupid mistake 2025-08-10 02:27:36 +00:00
Daniel O'Connor 67a2005f1e Swap to iteration for now, so callbacks are happy 2025-08-10 02:21:39 +00:00
Daniel O'Connor 3b17265a92 Swap to iteration for now, so callbacks are happy 2025-08-10 02:05:29 +00:00
Daniel O'Connor 8006d26c6e Fix source 2025-08-10 01:45:29 +00:00
google-labs-jules[bot] 4829d5513c This commit adds a rake task to delete all pictures that have 'OpenFarm' as their source. This is useful for cleaning up data imported from OpenFarm. 2025-08-10 00:58:03 +00:00