Git Product home page Git Product logo

api's Introduction

Participedia

Welcome to Participedia!

A global community sharing knowledge and stories about public participation and democratic innovations.

Documentation formerly in the README has been updated and moved to the Wiki for ease of maintenance and organization.

Read our Code of Conduct


Support for cross-browser testing provided by: Browser Stack

api's People

Contributors

ascott avatar davidascher avatar dependabot[bot] avatar dethe avatar greenkeeper[bot] avatar paninee avatar ramzialselwi avatar vitaly-t avatar zphingphong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

api's Issues

Documentation errors

There are some cut-and-paste errors that result in some APIs for Methods or Organizations looking like duplicates of Case APIs and being grouped erroneously.

Database: Merge all migrations into one schema

Having a stack of migrations is good during early development because if anything breaks it can be backed out or tested individually, but as the structure stabilizes we should dump out one schema to be based on going forward.

Finish populating Case JSON from subtables

The first cut at generating JSON from Postgres was focussed on getting things working. Now we need to flesh it out. We currently pull in data from the main cases table, case___authors, case__localized_texts, and geolocation, but we want to also pull in:

  • case__attachments
  • case__methods
  • case__tags
  • case_videos

An in-range update of tape-watch is breaking the build 🚨

Version 2.3.0 of tape-watch just got published.

Branch Build failing 🚨
Dependency tape-watch
Current Version 2.2.4
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

As tape-watch is a direct dependency of this project this is very likely breaking your project right now. If other packages depend on you it’s very likely also breaking them.
I recommend you give this issue a very high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details
Commits

The new version differs by 6 commits .

  • 99449c8 Merge pull request #116 from lsanwick/ls/add-clear-option
  • db015ef Merge pull request #144 from rstacruz/greenkeeper-debug-2.6.0
  • c318e11 chore(package): update debug to version 2.6.0
  • cc2c1ca Release v2.2.4
  • 424134b Update README
  • 65ecc0f [Feature] Add clear option to clear console between test runs

See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Create proxy

We are having trouble accessing Auth0 API from within localhost:3000
@dethe suggested creating a proxy might be a soluction.

To replicate the issue you can go to the frontend's branch called profiles and visit http://localhost:3000/en-US/otherprofile open the console and click on text "click to get info of a user".
You should see:

image

Search: handle both facets AND full text query

Currently if there is a facet present in the search, any full-text query is ignored. We should be able to handle both, and multiple facets.

Be prepared to treat objectType as a facet as well.

Related objects

Wire all the related cases/methods/organizations into api return values:

Each case, method, organization can return:

  • related cases
  • related methods
  • related organizations

and also

  • cases which this is a related X for
  • methods which this is a related X for
  • organizations which this is a related X for

The tables are defined (in https://github.com/participedia/api/tree/35_complete_add_apis) already, but still need to be added to the query results.

Move all AWS config variables to a config file

currently controllers have code like:


AWS.config.update({
  profile: "ppadmin",
  region: "us-east-1"
});

That should all be centralized in a shared module, which looks up the profile and region in environment vars.

to figure out

error: Error deleting bookmark error: invalid input syntax for integer: "'1109'"
    at Connection.parseE (/Users/da/src/participedia/api/node_modules/pg/lib/connection.js:539:11)
    at Connection.parseMessage (/Users/da/src/participedia/api/node_modules/pg/lib/connection.js:366:17)
    at Socket.<anonymous> (/Users/da/src/participedia/api/node_modules/pg/lib/connection.js:105:22)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:191:7)
    at readableAddChunk (_stream_readable.js:176:18)
    at Socket.Readable.push (_stream_readable.js:134:10)
    at TCP.onread (net.js:563:20)

lead_image in user results needs to be jsonified

If you look at the data for http://api.participedia.xyz/user/134860 you'll notice:

id: 4387,
type: "case",
title: "Marrickville Infrastructure Citizens' Jury",
lead_image: "(Marrickville.JPG,,)"
},

We need it to be:

id: 4387,
type: "case",
title: "Marrickville Infrastructure Citizens' Jury",
lead_image: {
   url: "Marrickville.JPG",
   title: null,
   size: null
},

(just like cases and the like are usually returned)

(need this for profile and user views)

Prepare PostgreSQL schema

For converting our site from Amazon Document to Amazon RDS for PostgreSQL we will need:

  • Schema for existing data
  • Script to convert from existing data (as JSON) to SQL (after suitable cleanup)
  • Full instructions for connecting API server to PostgreSQL

Currently looking at the node-postgres-promises library for connecting, there is an tutorial for using this: Designing a REST-ful API with Node and Postgres.

Feasibility of relying on PostgreSQL full text search rather than ElasticSearch is based on Postgres full-text search is Good Enough!.

Amazon RDS pre-installs the extensions needed for full-text search, and for GIS: General PostgreSQL Extensions Supported on Amazon RDS

Make api docs work better

The web site for the API (api.participedia.xyz) contains docs, but currently they're not very helpful in understanding things like the minimal content of body for POST/PUT calls for methods/cases/etc.

getUserIfExists() fails on test data

Because we're logging in with real credentials (via auth0), but the user table is populated with fake user data (including fake emails), getUserIfExists (which assumes that if there is an (authenticated) user, that user's email should be in the table and looks them up by email, fails.

I'd noticed this in a test where I'd accidentally included authentication on a GET request, but now see it whenever trying to view an object (case/method/organization) while logged in. It shouldn't be a problem on production (where our Auth0 users correspond to users in the database, but it's a pain in out test environment.

I think the easiest solution is a migration to add all of us developing and testing to the database, so we can be found by email lookup. I personally don't care too much if my email is checked into Github in the code of a migration (it's been publicly available on the internet for decades), but should probably get buy-in from others before doing this.

Another option is to pull down the users dynamically from the old Participedia and directly into Postgres without storing that data in Github at all, which might be worth investigating.

Update json cleanup script and extract metadata

In addition to raw conversion, we'd like to have:

  • Schema in human and machine-readable formats
  • Some detailed stats on how often each field is used and what the typical and outlier values are

Cleanup includes:

  • splitting up list properly (including json-reencoded lists)
  • not re-encoding json lists and dicts as strings in the json
  • ensure all dates are ISO-8601 (no unix timestamps)
  • extracting fields out of structured HTML blobs (i.e., "file_attachments")

Next Steps:

  • make it machine readable
  • re-apply David's key renaming
  • Clean up inconsistencies (not all lat/longs are in the same format)
  • Parse "file_attachments" into json objects
  • Converting Yes/No into booleans
  • Do something useful with id cross-referencing

Create NEWS schema

Title, images & videos, description, author.

should show up in searches.

Add more fields to user table

  • affiliation (text)
  • title (text)
  • bio (text)
  • location (geolocation data type)
  • Should be returned in the /user/* calls.

Body text truncated after migration

I was truncating text for readability during debugging, forgot to disable that when exporting data. Also, seeing escaped ampersands "&" in text and titles.

bookmarked value is misencoded

currently on a case GET, there's a fragment of JSON that looks like:

bookmarked: {
   case: false
}

I think it should instead be just:

bookmarked: false

Call postgres instead of dynamodb/elasticsearch

Replace API call interface to the database and search engine with ones to postgres. The frontend should be able to remain relatively stable, unless we want to restructure the JSON we return.

Switch to new database setup

  • switch ES endpoint in api/helpers/es.js to point to the new elasticsearch cluster search-pp-stage-37xn6cdq7tj7ehv5rjrgxgrjhq.us-east-1.es.amazonaws.com
  • check API code to use the new indices, etc.
  • change front-end code to use the new schema
  • change API backend to do non-search queries in dynamodb
  • review AWS roles and permissions to lock down ES
  • create API endpoints for methods, organizations, users
  • create front-ends for methods, organizations, users

Rebuild Search API on top of Postgres

Search has three arguments:

  1. query: either an empty string, the 'geo_country: [Country]' pair, or a user-typed query.
  2. category: "Cases", "Methods", "Organizations" or "All"
  3. sort: "chronological", "featured", or "alphabetical"

Front-end PR 122 depends on this

Need to be able to restrict payloads of search to small # of fields

In the map display, I need to be able to efficiently get all of the title + locations of all of the cases for example, but without fetching body, and all of the other metadata on cases.

This will be a frequent query, as it'll happen on the home page. I suspect we want a simplified version of search_cases.sql etc which only returns fields we know we need. A hackier version is to do the full SQL search, but trim the results before they go over the slow wire.

Fields to return for search results:

  • id
  • title
  • type (case/method/organization)
  • lead image
  • last updated
  • (original) author name
  • (original) author id
  • bookmarked by current user?

Figure out full text indices for localized text tables

Reading 12.2.2 on https://www.postgresql.org/docs/9.5/static/textsearch-tables.html#TEXTSEARCH-TABLES-INDEX makes me feel that we probably want to encode language in the localized text tables using the postgres version of languages, so we can do

CREATE INDEX body_idx ON case__localized_texts USING GIN (to_tsvector(language, body));

but today language values are things like 'en', while postgres knows how to deal with:

 pg_catalog | danish     | configuration for danish language
 pg_catalog | dutch      | configuration for dutch language
 pg_catalog | english    | configuration for english language
 pg_catalog | finnish    | configuration for finnish language
 pg_catalog | french     | configuration for french language
 pg_catalog | german     | configuration for german language
 pg_catalog | hungarian  | configuration for hungarian language
 pg_catalog | italian    | configuration for italian language
 pg_catalog | norwegian  | configuration for norwegian language
 pg_catalog | portuguese | configuration for portuguese language
 pg_catalog | romanian   | configuration for romanian language
 pg_catalog | russian    | configuration for russian language
 pg_catalog | simple     | simple configuration
 pg_catalog | spanish    | configuration for spanish language
 pg_catalog | swedish    | configuration for swedish language
 pg_catalog | turkish    | configuration for turkish language

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.