Laws.Africa Developer Guide
  • Laws.Africa Developer Guide
  • Get Started
    • Introduction
    • Quick start
    • Works and expressions
    • Webhooks
    • Changelog
  • Tutorial
    • About the tutorial
    • Module 1: Build a legislation reader
      • Introductory concepts
      • Create a basic Django app
      • Create database models
      • Fetching the data
      • Work listing page
      • Expression detail page
      • Styling with Law Widgets
      • Adding interactivity
      • Staying up to date
    • Module 2: Enrichments and interactivity
      • Basic enrichments
      • Advanced enrichments
      • Advanced interactivity
    • Module 3: Text extraction for search and analysis
      • Why extracting text is important
      • Basics of text extraction
      • Advanced text extraction
      • Extracting text for analysis and machine learning
  • Content API Reference
    • About the Content API
    • Authentication
    • Pagination
    • Places
    • All work expressions
    • Single work expression
      • Commencements
      • Embedded images
      • Publication document
      • Table of Contents
      • Timeline
    • Taxonomy topics
    • Enrichment datasets
  • AI API Reference
    • About the AI API
    • Authentication
    • Knowledge Bases
  • How-to Guides
    • How to use the Table of Contents API
    • How to download images
Powered by GitBook
On this page
  • In this section
  • Knowing when content has changed
  • Knowing when content has been removed
  1. Tutorial
  2. Module 1: Build a legislation reader

Staying up to date

Getting the latest data from the Content API.

In this section

  • Getting recently updated content from the Content API

  • Tracking deleted items

Knowing when content has changed

Legislation changes over time. As new works and expressions are added to the Laws.Africa Content API, our app needs to be kept up to date.

When we run our ingest_capetown_bylaws.py command, it would be useful to ignore any content that hasn't changed, and only process content that has changed.

The Laws.Africa Content API includes an attribute updated_at which is a timestamp of the most recent change to that work and expression. We can use that to ignore content that hasn't changed.

Here are two ways of doing this:

  1. When processing content from the Content API, compare the new updated_at with the updated_at of the work or expression already in your database. Only process the update if the new updated_at is more recent than your existing version.

  2. Keep a timestamp in your database of the last time you processed content from the API. When processing new content, import anything with a updated_at field that is more recent than the timestamp from your database.

Knowing when content has been removed

Sometimes content will be removed from the Content API, although this is rare. This usually happens when the FRBR URI for a document has to be changed.

There is no way to query the Content API for items that have been deleted. Instead, do the following:

  1. Fetch a list of all expression FRBR URIs from the Content API.

  2. Fetch a list of all expression FRBR URIs in your database.

  3. Compare the lists, and delete anything that is in your database, but is no longer included in the Content API.

PreviousAdding interactivityNextModule 2: Enrichments and interactivity

Last updated 1 year ago