{"id":15707218,"url":"https://github.com/manfred/scopes-revisited","last_synced_at":"2025-03-30T16:15:17.708Z","repository":{"id":519461,"uuid":"147678","full_name":"Manfred/scopes-revisited","owner":"Manfred","description":"Temporary project looking at different ways to implement scopes in Active Record","archived":false,"fork":false,"pushed_at":"2009-04-08T21:33:47.000Z","size":100,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-02-05T17:38:52.945Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Manfred.png","metadata":{"files":{"readme":"README.markdown","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2009-03-10T19:53:55.000Z","updated_at":"2019-08-13T14:08:15.000Z","dependencies_parsed_at":"2022-08-16T10:30:09.105Z","dependency_job_id":null,"html_url":"https://github.com/Manfred/scopes-revisited","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Manfred%2Fscopes-revisited","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Manfred%2Fscopes-revisited/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Manfred%2Fscopes-revisited/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Manfred%2Fscopes-revisited/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Manfred","download_url":"https://codeload.github.com/Manfred/scopes-revisited/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246342994,"owners_count":20761947,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T20:38:16.499Z","updated_at":"2025-03-30T16:15:17.682Z","avatar_url":"https://github.com/Manfred.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Scopes Revisited\n\nTrying to find better ways to implement scopes in Active Record.\n\nSee [http://github.com/Manfred/rails/tree/scopes](http://github.com/Manfred/rails/tree/scopes) for the actual merge with Rails.\n\n## Objectives\n\n* Make scope stack merging more transparent (ie. not in a method with 5-level-deep nested if statements)\n* Make scopes thread-safe\n* Re-evaluate method and variable naming\n\n## Ideas\n\n* Merge scope stacks as late as possible to enable smarter merging\n* Delegate and federate stack merging (ie. Scopes don't need to know how associations merge their query parameters)\n\n## TODO\n\n* Refactor existing named scope tests and make them run\n- Implement default scopes (AR::Base.default_scope)\n- Implement dynamic scopes (AR::Base#scoped)\n- Write a whole gang of new tests for merging scope stacks\n- Start adding tests for hard to merge scope stacks\n- Start adding tests for smart merging stacks (see tickets below)\n- Scout Lighthouse and gather tests for existing problems with scopes and fix them\n  - Merge string conditions if possible, otherwise raise a sensible exception\n    [http://rails.lighthouseapp.com/projects/8994/tickets/2199](http://rails.lighthouseapp.com/projects/8994/tickets/2199)\n  - Merge order scope options instead of overriding them\n    [http://rails.lighthouseapp.com/projects/8994/tickets/2253](http://rails.lighthouseapp.com/projects/8994/tickets/2253)\n  - Make associations respect the default scope\n    [http://rails.lighthouseapp.com/projects/8994/tickets/2297](http://rails.lighthouseapp.com/projects/8994/tickets/2297)\n  - All scope definitions of _any_ kind should override default scopes\n    [http://rails.lighthouseapp.com/projects/8994/tickets/2257](http://rails.lighthouseapp.com/projects/8994/tickets/2257)\n  - Default scope should accept a proc\n    [http://rails.lighthouseapp.com/projects/8994/tickets/1812](http://rails.lighthouseapp.com/projects/8994/tickets/1812)\n  - Find a way to merge :select query parameters in count queries.\n    [http://rails.lighthouseapp.com/projects/8994/tickets/1334](http://rails.lighthouseapp.com/projects/8994/tickets/1334)\n  - Implement #many? on scopes and associations so they don't load the entire collection.\n    [http://rails.lighthouseapp.com/projects/8994/tickets/1500](http://rails.lighthouseapp.com/projects/8994/tickets/1500)\n\n## DONE\n\n- Start merging the new scope implementation into Rails and get some simple queries running\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanfred%2Fscopes-revisited","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmanfred%2Fscopes-revisited","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanfred%2Fscopes-revisited/lists"}