Skip to main content

LitePolis-database-particiapi

ParticiAPI-compatible database module for LitePolis. This module extends LitePolis-database-default with ParticiAPI-specific models and functionality.

Overview

This module provides:

  • ParticiapiUser - Extended participant model with ParticiAPI fields
  • ParticipantExtended - Additional participant metadata
  • ParticiapiIssuer - OIDC issuer configuration
  • MathMain - Math results caching
  • NotificationTasks - Notification queue management

Installation

litepolis-cli deploy add-deps litepolis-database-particiapi
litepolis-cli deploy sync-deps

Configuration

This module shares database configuration with LitePolis-database-default. To customize, create a config file:

litepolis-cli deploy init-config

Then edit ~/.litepolis/litepolis.config:

[litepolis_database_default]
database_url = sqlite:///database.db
# For production:
# database_url = postgresql://user:pass@localhost:5432/litepolis
sqlalchemy_engine_pool_size = 30
sqlalchemy_pool_max_overflow = 50

Or set environment variables:

export DATABASE_URL="postgresql://user:pass@localhost:5432/litepolis"

Models

ParticiapiUser (participants table)

Column Type Description
pid INTEGER Participant ID (primary key)
uid INTEGER User ID
zid INTEGER Conversation ID
vote_count INTEGER Number of votes cast
last_interaction INTEGER Last activity timestamp (ms)
subscribed BOOLEAN Email subscription status
last_notified INTEGER Last notification timestamp (ms)
nsli INTEGER Not-since-last-interaction flag
mod INTEGER Moderation status
created DATETIME Creation timestamp

ParticipantExtended (participants_extended table)

Column Type Description
uid INTEGER User ID
zid INTEGER Conversation ID
referrer VARCHAR HTTP referrer
parent_url VARCHAR Parent page URL
created DATETIME Creation timestamp
modified DATETIME Last modified timestamp
subscribe_email BOOLEAN Email subscription
show_translation_activated BOOLEAN Translation feature
permanent_cookie VARCHAR Persistent cookie
origin VARCHAR Origin header

Quick Start

  1. Install all ParticiAPI modules:
litepolis-cli deploy add-deps litepolis-database-particiapi
litepolis-cli deploy add-deps litepolis-router-particiapi
litepolis-cli deploy add-deps litepolis-ui-particiapp
litepolis-cli deploy sync-deps
  1. Start LitePolis server:
litepolis-cli deploy serve

Usage

from litepolis_database_particiapi import DatabaseActor

# Get or create participant
participant = DatabaseActor.get_or_create_participant(zid=1, uid=1)

# Record vote
vote = DatabaseActor.do_vote(zid=1, pid=1, tid=1, vote=1)

# Get statements for conversation
statements = DatabaseActor.get_statements(zid=1)

DatabaseActor Methods

Method Description
get_or_create_participant(zid, uid) Get or create participant for conversation
do_vote(zid, pid, tid, vote) Record a vote
get_statements(zid) Get all statements for conversation
get_conversation(zid) Get conversation details
create_statement(zid, pid, text) Create new statement

Development Testing

pip install -e .
pytest tests/

Related Modules

License

MIT License

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

litepolis_database_particiapi-0.0.2.tar.gz (15.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

litepolis_database_particiapi-0.0.2-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file litepolis_database_particiapi-0.0.2.tar.gz.

File metadata

File hashes

Hashes for litepolis_database_particiapi-0.0.2.tar.gz
Algorithm Hash digest
SHA256 e60f01605f11eaeb14ed20d3be4d5dab65dc040c1db3b095ec525a7168b2fcbb
MD5 d39b88b3cde5ce64c6e94e50747731df
BLAKE2b-256 3661bf61a01544c542431b8ecf69230c8026d146c962a4dbe7c2292417ffbe0d

See more details on using hashes here.

Provenance

The following attestation bundles were made for litepolis_database_particiapi-0.0.2.tar.gz:

Publisher: python-publish.yml on NewJerseyStyle/LitePolis-database-particiapi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file litepolis_database_particiapi-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for litepolis_database_particiapi-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 dcc3f9c781b9c8b96621c6efa7afc99e982ea0153abd7223193817a1f618386a
MD5 b072574ae0e184ce598e78c661c02b0d
BLAKE2b-256 11924f86272f20efe638c38685017be0b39564838a4d348964ddee568302d2da

See more details on using hashes here.

Provenance

The following attestation bundles were made for litepolis_database_particiapi-0.0.2-py3-none-any.whl:

Publisher: python-publish.yml on NewJerseyStyle/LitePolis-database-particiapi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page