GithubHelp home page GithubHelp logo

metro-records / la-metro-councilmatic Goto Github PK

View Code? Open in Web Editor NEW
6.0 7.0 2.0 77.18 MB

:metro: An instance of councilmatic for LA Metro

License: MIT License

Python 55.67% CSS 1.49% HTML 39.93% Shell 0.12% JavaScript 2.40% Dockerfile 0.19% Makefile 0.21%
councilmatic la-metro legislation

la-metro-councilmatic's Introduction

Metro Board Reports

Metro Board Reports helps the Los Angeles community understand the activities of the Los Angeles County Metropolitan Transportation Authority (Metro) – a government agency that consists of several Board Members, who set policy, coordinate, plan, fund, build, and operate transit services and transportation programs throughout LA County.

The Metro Board Reports site monitors all things related to the Metro Board of Directors:

  • the board reports introduced and passed
  • its various committees and the meetings they hold
  • the board members themselves

This site ultimately encourages greater public dialogue and increased awareness about transportation issues in LA County.

Metro Board Reports is a member of the Councilmatic family. Learn how to build your own Councilmatic site!

Setup

These days, we run apps in containers for local development. More on that here.

Set-up pre-commit

We use the pre-commit framework to use Git pre-commit hooks that keep our codebase clean.

To set up Pre-Commit, install the Python package on your local machine using

python -m pip install pre-commit

If you'd rather not install pre-commit globally, create and activate a virtual environment in this repo before running the above command.

Then, run

pre-commit install

to set up the git hooks.

Since hooks are run locally, you can modify which scripts are run before each commit by modifying .pre-commit-config.yaml.

Get the Legistar API key

There should be an entry in the DataMade LastPass account called 'LA Metro - secrets.py.' Copy its contents into a file called secrets.py and place it in lametro/.

Install OS level dependencies:

Load in the data

The Metro app ingests updated data from the Legistar API several times an hour.

To import data into your local instance, copy DataMade's Legistar API token from Bitwarden (search LA Metro Legistar API Token). Next, create a copy of the secrets file and paste in the token:

cp lametro/secrets.py.example lametro/secrets.py

Then, simply run:

docker-compose run --rm scrapers

This may take a few minutes to an hour, depending on the volume of recent updates.

Run the application

First, create your own local env file:

cp .env.local.example .env.local

Next, bring up the app:

docker-compose up

When your logs indicate that your app is up and running, visit http://localhost:8001 to visit your shiny, new local application!

Optional: Populate the search index

If you wish to use search in your local install, you need a SmartLogic API key. Initiated DataMade staff may retrieve values for the SMART_LOGIC_ENVIRONMENT and SMART_LOGIC_KEY environment variables from Heroku:

heroku config:get SMART_LOGIC_ENVIRONMENT SMART_LOGIC_KEY -a la-metro-councilmatic-staging

Paste these values into your .env.local file.

Then, run the refresh_guid management command to grab the appropriate classifications for topics in the database.

docker-compose exec app python manage.py refresh_guid

Finally, add data to your search index with the update_index command from Haystack.

docker-compose run --rm app python manage.py update_index

When the command exits, your search index has been filled.

Running arbitrary scrapes

Occasionally, after a while without running an event scrape, you may find that your local app is broken. If this happens, make sure you have events in your database that are scheduled for the future, as the app queries for upcoming events in order to render the landing page.

  1. Make sure there are future events scheduled in Legistar. Go to the LA Metro Legistar page and open up the time filter for "All Years".

  2. If you notice that there are future events in Legistar, run a small windowed event scrape:

docker-compose run --rm scrapers pupa update lametro events window=0.05 --rpm=0

This will bring in a few upcoming events, and your app will be able to load the landing page.

Scraping specific bill

It's sometimes helpful to make sure you have a specific bill in your database for debugging. Here's how you can scrape a bill you need:

  1. Go to the Legistar Web API at the following URL: http://webapi.legistar.com/v1/metro/matters/?$filter=MatterFile%20eq%20%27<bill_identifier>%27 and find the <MatterId> of the bill. The identifier should be in XXXX-XXXX format, and the MatterId is a 4 digit number.

  2. Run the following command in your shell:

docker-compose run --rm scrapers pupa update lametro bills matter_ids=<bill_matter_id> --rpm=0

Connecting to AWS S3 for development

If you want to use the S3 bucket, you’ll need the AWS S3 API keys. This can be found by running:

heroku config:get AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY -a la-metro-councilmatic-staging

Grab the values for the AWS_ACCESS_KEY_ID and the AWS_SECRET_ACCESS_KEY and add them to your .env.local file.

Now you should be able to start uploading some files!

Adding a new board member

Hooray! A new member has been elected or appointed to the Board of Directors. There are a few changes you need to make so they appear correctly on the site.

Update the scraper

  • Add the new member to the VOTING_POSTS object in the Metro person scraper. Once your PR is reviewed, merge your changes, pull them into our scrapers fork, and follow the steps to deploy your change.
    • Example: opencivicdata/scrapers-us-municipal#337
    • Tip: Once your scraper change is deployed. Run docker-compose run --rm scrapers pupa import lametro people --rpm=0 to capture the change locally.
  • After the revised person scrape runs, remove any board memberships for the new member that were created without a post.
    from lametro.models import Person
    Person.objects.get(family_name='<MEMBER LAST NAME>').memberships.filter(organization__name='Board of Directors', post__isnull=True).delete()

Check your work

To confirm your changes worked, run the app locally and confirm the following:

  • View the Board of Directors listing and confirm the new member is listed with the correct post, e.g., Los Angeles Country Board Supervisor, District 1.
    • If you only see Board Member, the new member's post has not been added. Double check that you updated the VOTING_POSTS object in the person scraper (e.g., does the member's name as it appears in the API match the key you added?), that your changes to the scraper have been deployed, and that a person scrape has been run since the deployment.

A note on tests

LA Metro Councilmatic has a basic test suite. If you need to run it, simply run:

docker-compose -f docker-compose.yml -f tests/docker-compose.yml run --rm app

Load testing

LA Metro Councilmatic uses Locust for load testing. There is a starter script in locustfile.py that visits the homepage, event listing, and an event detail page at random intervals between 60 and 90 seconds. This script was derived from user behavior in Google Analytics. (If needed, request analytics access from Metro.)

You can run the load tests using the locust service in docker-compose.locust.yml:

docker-compose -f docker-compose.yml -f docker-compose.locust.yml run --service-ports --rm locust

This will start the Locust web server on http://localhost:8089. For more details, see the Locust documentation.

Review Apps

This repo is set up to deploy review apps on Heroku, and those pull from the staging database to match the experience of deploying as closely as possible! However, note that in order to prevent unapproved model changes from effecting the staging database, migrations are prevented from running on review apps. So those will still have to be reviewed locally.

Errors / Bugs

If something is not behaving intuitively, it is a bug, and should be reported. Report it here: https://github.com/datamade/la-metro-councilmatic/issues

Note on Patches/Pull Requests

  • Fork the project.
  • Make your feature addition or bug fix.
  • Commit, do not mess with rakefile, version, or history.
  • Send a pull request. Bonus points for topic branches.

Copyright

Copyright (c) 2023 DataMade. Released under the MIT License.

la-metro-councilmatic's People

Contributors

antidipyramid avatar beamalsky avatar cathydeng avatar derekeder avatar evz avatar fgomez828 avatar fgregg avatar hancush avatar jeancochrane avatar jmithani avatar reginafcompton avatar xmedr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

camachoo

la-metro-councilmatic's Issues

Bill detail view: add/fix sponsors table.

Fix this.

And....do we want to add more information to the "Sponsors" table in the Bill Detail View?

The sponsors table does not have a thumbnail image, nor does it have municipal district. Do we want to add additional information?

LA Metro
screen shot 2016-10-13 at 2 57 00 pm

Chicago
screen shot 2016-10-13 at 2 58 27 pm

Improve tags

The tags currently point to the sponsors. Can these instead point to terms? (Check Open Civic Data to see what we have, first.)

Get descriptions for committees

Lines 242-253

We need to add descriptions for each committee in settings_jurisdiction.py.

Can we get these from the folks at LA Metro?

dedupe committee list on board member detail pages

this is a recurring issue with memberships on this project bc la metro data repeats for each term in office; probably worth a second look to make sure our query sets are taking term dates into account wherever memberships are being used to populate a list or count, etc.

map of post titles to board members

@fgregg i've also included in parentheses the posts held by each board member that fulfill the membership requirement, in case we need to incorporate that

Mayor of Los Angeles:
Eric Garcetti

Los Angeles County Supervisors:
Hilda L. Solis - district 1
Mark Ridley-Thomas - district 2
Sheila Kuehl - district 3
Don Knabe - district 4
Michael Antonovich - district 5

Appointee of Mayor of Los Angeles (two members of public, one city council member):
Jacquelyn Dupont-Walker
Mike Bonin (Council Member, City of Los Angeles)
Paul Krekorian (Council Member, City of Los Angeles)

Appointee of Governor of California:
Carrie Bowen (Caltrans District 7 Director)

Appointee of League of California Cities ("each of whom shall be a mayor or a member of a city council"):
John Fasana - San Gabriel Valley sector (Council Member, City of Duarte)
James Butts - Southwest Corridor sector (Mayor, City of Inglewood)
Diane DuBois - Southeast Long Beach sector (Council Member, City of Lakewood)
Ara Najarian - North County/San Fernando Valley sector (Council Member, City of Glendale)

p.s. would a list of cities in each sector be useful?

Questions for LA Metro

List of questions for LA Metro:

  • Is "Legislation" the correct word?
  • Committees, but not individual board members sponsor legislation. How do we want to deal with this? Related to #20
  • Board Members seem to have overlapping administrative districts/geographies. We removed the maps. Is this the way to go? Related to #7 and #6
  • Can we get some content for the About page and also descriptions of the various committees? Related to #18 and #15
  • What should we use as the icon?
  • What should we do for Board Member head shots? Related to #11

Question about Board Report PDF

The folks at LA Metro would like to have the PDF for Board Reports available on the Bill detail view.

Currently, we only display the plain text (under "Report Text"):

https://lametro.datamade.us/board-report/2016-0878-914bb1b5593a/

A PDF of the "Board Report" is often available on Legistar:

https://metro.legistar.com/LegislationDetail.aspx?ID=2882011&GUID=CD9EA9DF-C99F-420D-88D7-8F6F6F4A522E&Options=ID|Text|&Search=2016-0878

However, we do not have that document in the ocd api (assumed to be under "versions" with the other attachments):

http://ocd.datamade.us/ocd-bill/0e886916-deef-4f59-9e66-914bb1b5593a/

Is there a reason to omit the Board Report PDF in the api? Or am I overlooking something?

Ad-hoc committee: questions

We need some clarification on the definition of "Ad-hoc."

Typically, when and why does La Metro create an "Ad-hoc"?

How do we know if an ad-hoc committee is "active"? I ask, because the members of Ad-Hoc committees do not have start and end dates.....why is this?

We decided to give each Ad-hoc committee a detail view, considering the number of legislative acts linked to these committees.

Do these committees have a "cycle," which might affect memberships (could members be duplicated)?

@derekeder
@fgregg
@hancush

Some final comments from LA Metro

Map

Looks good, but need more feedback from the Board and others. In addition, we might have some data errors (fixes are forthcoming).

Add some explanatory text, e.g., as a hover tooltip on toggle.

Homepage

When does the “next board meeting” date and time change?

Can we add a “current meeting” subsection, i.e., during the hour when the meeting is taking place? (Add a link to watch the current meeting: this would link to a video player in Legistar.)

Launch

Date: week before Christmas

URL: board.metro.net (TBD)

add placeholder padding for Google translate

Since the Google Translate dropdown loads via javascript, there's a time when the page is loading that makes the navbar shift to the left:

la-metro-translate

Let's put some placeholder padding for this element and set a min-width

Edit the ABOUT page.

I see at least one instance of the word "Chicago" on the ABOUT page. Check for and remove "Chicago" elsewhere.

Unanswered question: "legislation"?

Is "legislation" the right term? We brought this question to the attention of LA Metro, but did not get a definitive answer. Remind them again.

Sort by date by default

In views.py, find "CouncilmaticFacetedSearchView" and append ".order_by('-last_action_date')" to the sqs variable, for example:

    except:
            kwargs['searchqueryset'] = sqs.order_by('-last_action_date')

Get content for pages

Get content for About, Index, etc.

Can someone at LA Metro or elsewhere provide some text for this?

Order people.

The committee and board members should be in the following order:

Chair
Vice Chair
Member
Non-voting Member

This might be the order, in which the legistar lists them.....

Add a map?

Should we include a map for displaying LA Metro board members?

PDF consolidation

We will create a multi-part process for consolidating the event and bill documents into DPF "packets": (1) board_agenda_packet, and (2) event_packet.

get headshots

request from la metro? (and/or ask whether they want them)

Complete ABOUT page.

We need to add descriptions of the legislation types (table), and we need to flesh out the content for all subsections.

Can someone from LA Metro provide some text an descriptions?

decide what kind of legislation feed (if any) to include on person detail page

legislative items (in most cases) don't appear to be sponsored by people but rather by the board/committees. i wrote a property in lametroperson that gathers recent activity from committees to which the person belongs, with the option to omit board-sponsored items, as they are common to all board members/not that useful (?) to include on each member page. the problem: committees don't do much, and many are ad hoc/inactive, so when you omit items sponsored by the board, recent activity is not that recent. let's chat when i get back friday about what will be most useful to users, i'll implement it (and adjust the template, too), and we can merge my branch back into master.

consistent title

On the home page, we have several incorrect references:

screen shot 2016-10-21 at 4 48 23 pm

Los Angeles => LA Metro
LA Councilmatic => LA Metro Councilmatic (for now, we will likely not use the Councilmatic branding)
Search Los Angeles Legislation => Search LA Metro Reports & Items

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.