Entity

This document provides the API references for the entities in the database.

API

class models.Entity

An entity is any company or institution that is enrolled in the database that are related trough contracts.

All the fields of this model are directly retrieved from Base. They are:

name

The name of the entity.

base_id

The primary key of the entity on the Base database. It is “unique”.

nif

The fiscal identification number of the entity.

country

The country it is registered. It may be “null” when there is no such information.

It has the following getters:

total_earned()

Returns the total earned, in € cents, a value stored in EntityData.

total_expended()

Returns the total expended, in € cents, a value stored in EntityData.

get_base_url()

Returns the url of this entity in Base.

get_absolute_url()

Returns the url of this entity on this website.

And the following setters:

compute_data()

Computes two aggregations and stores them in its EntityData:

  1. the total value in € of the contracts where it is a contractor
  2. the total value in € of the contracts where it is contracted

This method is used when the crawler updates new contracts.

class models.EntityData

Data of an entity that is not retrieved from Base, i.e, it is computed with existing data. It is a kind of cache, but more persistent. This may become a proper cache in future.

It has a OneToOne relationship with Entity.

As the following attributes:

total_earned

The money, in cents, the entity earned so far.

total_expended

The money, in cents, the entity expended so far.