Z.Flat (Portico/Z v0.1.0)

Context for "flattened" data tables.

A "flattened" table is one that has been de-normalized (related tables have been pulled into columns). This is typically done for performance or analytics.

NOTE: These tables should be considered "read-only" for general use. These CRUD functions exist only to synchronize these tables from elsewhere in the EXPLO system.

Link to this section Summary

Functions

Returns an %Ecto.Changeset{} for tracking bus route changes.

Returns an %Ecto.Changeset{} for tracking contact changes.

Returns an %Ecto.Changeset{} for tracking course changes.

Returns an %Ecto.Changeset{} for tracking credit provider changes.

Returns an %Ecto.Changeset{} for tracking enrollment changes.

Returns an %Ecto.Changeset{} for tracking session changes.

Creates a bus route.

Creates a contact.

Creates a course.

Creates a credit provider.

Creates an enrollment.

Creates/updates a bus route.

Creates/updates a contact.

Creates/updates a course.

Creates/updates a credit provider.

Creates/updates an enrollment.

Creates/updates a session.

Creates a session.

Deletes a bus route.

Deletes a contact.

Deletes a course.

Deletes a credit provider.

Delete all empty contacts from the database.

Deletes a enrollment

Deletes a session

Gets a single bus route, by portico_id.

Gets a single bus route, by portico_id.

Gets a single contact, by portico_contact_id.

Gets a single contact, by portico_contact_id.

Gets a single course, by portico_course_id.

Gets a single course, by portico_course_id.

Gets a single credit provider, by portico_id.

Gets a single credit provider, by portico_id.

Gets a single enrollment by sis_enrollment_id

Gets a single enrollment by sis_enrollment_id

Gets a single session by portico_session_id

Gets a single session by portico_session_id

Returns the list of bus routes.

Returns the list of contacts.

Returns the list of courses.

Returns the list of credit providers.

Returns the list of enrollments

Returns the list of sessions

Generates a query of ZSchemas.Flat.Course records that have active_session_ids which overlap what is passed to this function

Generates a query of ZSchemas.Flat.Course records where min_grade and max_grade complement a given grade.

Generates a query of ZSchemas.Flat.Course records where language_level is <= the passed level (as an integer)

Updates a bus route.

Updates a contact.

Updates a course.

Updates an enrollment

Updates a session

Link to this section Functions

Link to this function

change_bus_route(bus_route, attrs \\ %{})

Returns an %Ecto.Changeset{} for tracking bus route changes.

Examples

iex> change_bus_route(bus_route)
%Ecto.Changeset{data: %BusRoute{}}
Link to this function

change_contact(contact, attrs \\ %{})

Returns an %Ecto.Changeset{} for tracking contact changes.

Examples

iex> change_contact(contact)
%Ecto.Changeset{data: %Contact{}}
Link to this function

change_course(course, attrs \\ %{})

Returns an %Ecto.Changeset{} for tracking course changes.

Examples

iex> change_course(course)
%Ecto.Changeset{data: %Course{}}
Link to this function

change_credit_provider(credit_provider, attrs \\ %{})

Returns an %Ecto.Changeset{} for tracking credit provider changes.

Examples

iex> change_credit_provider(credit_provider)
%Ecto.Changeset{data: %CreditProvider{}}
Link to this function

change_enrollment(enrollment, attrs \\ %{})

Returns an %Ecto.Changeset{} for tracking enrollment changes.

Examples

iex> change_enrollment(enrollment)
%Ecto.Changeset{data: %Enrollment{}}
Link to this function

change_session(session, attrs \\ %{})

Returns an %Ecto.Changeset{} for tracking session changes.

Examples

iex> change_session(session)
%Ecto.Changeset{data: %Session{}}
Link to this function

create_bus_route(attrs \\ %{})

Creates a bus route.

Examples

iex> create_bus_route(%{field: value})
{:ok, %BusRoute{}}

iex> create_bus_route(%{field: bad_value})
{:error, %Ecto.Changeset{}}
Link to this function

create_contact(attrs \\ %{})

Creates a contact.

Examples

iex> create_contact(%{field: value})
{:ok, %Contact{}}

iex> create_contact(%{field: bad_value})
{:error, %Ecto.Changeset{}}
Link to this function

create_course(attrs \\ %{})

Creates a course.

Examples

iex> create_course(%{field: value})
{:ok, %Course{}}

iex> create_course(%{field: bad_value})
{:error, %Ecto.Changeset{}}
Link to this function

create_credit_provider(attrs \\ %{})

Creates a credit provider.

Examples

iex> create_credit_provider(%{field: value})
{:ok, %CreditProvider{}}

iex> create_credit_provider(%{field: bad_value})
{:error, %Ecto.Changeset{}}
Link to this function

create_enrollment(attrs \\ %{})

Creates an enrollment.

Examples

iex> create_enrollment(%{field: value})
{:ok, %Enrollment{}}

iex> create_enrollment(%{field: bad_value})
{:error, %Ecto.Changeset{}}
Link to this function

create_or_update_bus_route(attrs \\ %{})

Creates/updates a bus route.

Examples

iex> create_or_update_bus_route(%{field: value})
{:ok, %BusRoute{}}

iex> create_or_update_bus_route(%{field: bad_value})
{:error, %Ecto.Changeset{}}
Link to this function

create_or_update_contact(attrs \\ %{})

Creates/updates a contact.

Examples

iex> create_or_update_contact(%{field: value})
{:ok, %Contact{}}

iex> create_or_update_contact(%{field: bad_value})
{:error, %Ecto.Changeset{}}
Link to this function

create_or_update_course(attrs \\ %{})

Creates/updates a course.

Examples

iex> create_or_update_course(%{field: value})
{:ok, %Course{}}

iex> create_or_update_course(%{field: bad_value})
{:error, %Ecto.Changeset{}}
Link to this function

create_or_update_credit_provider(attrs \\ %{})

Creates/updates a credit provider.

Examples

iex> create_or_update_credit_provider(%{field: value})
{:ok, %CreditProvider{}}

iex> create_or_update_credit_provider(%{field: bad_value})
{:error, %Ecto.Changeset{}}
Link to this function

create_or_update_enrollment(attrs \\ %{})

Creates/updates an enrollment.

Examples

iex> create_or_update_enrollment(%{field: value})
{:ok, %Enrollment{}}

iex> create_or_update_contact(%{field: bad_value})
{:error, %Ecto.Changeset{}}
Link to this function

create_or_update_session(attrs \\ %{})

Creates/updates a session.

Examples

iex> create_or_update_session(%{field: value})
{:ok, %Session{}}

iex> create_or_update_contact(%{field: bad_value})
{:error, %Ecto.Changeset{}}
Link to this function

create_session(attrs \\ %{})

Creates a session.

Examples

iex> create_session(%{field: value})
{:ok, %Session{}}

iex> create_session(%{field: bad_value})
{:error, %Ecto.Changeset{}}
Link to this function

delete_bus_route(bus_route)

Deletes a bus route.

Examples

iex> delete_bus_route(bus_route)
{:ok, %BusRoute{}}

iex> delete_bus_route(bus_route)
{:error, %Ecto.Changeset{}}
Link to this function

delete_contact(contact)

Deletes a contact.

Examples

iex> delete_contact(contact)
{:ok, %Contact{}}

iex> delete_contact(contact)
{:error, %Ecto.Changeset{}}
Link to this function

delete_course(course)

Deletes a course.

Examples

iex> delete_course(course)
{:ok, %Course{}}

iex> delete_course(course)
{:error, %Ecto.Changeset{}}
Link to this function

delete_credit_provider(credit_provider)

Deletes a credit provider.

Examples

iex> delete_credit_provider(credit_provider)
{:ok, %CreditProvider{}}

iex> delete_credit_provider(credit_provider)
{:error, %Ecto.Changeset{}}
Link to this function

delete_empty_contacts()

Delete all empty contacts from the database.

Empty contacts sometimes make it in because they're merged or deleted in Portico, which makes their cache record have an empty first/last name. We keep the cache record in Portico so we know what happened, but just pull them from the cache in Z so that they don't show up in searches etc.

Link to this function

delete_enrollment(enrollment)

Deletes a enrollment

Examples

iex> delete_enrollment(enrollment)
{:ok, %Enrollment{}}

iex> delete_enrollment(enrollment)
{:error, %Ecto.Changeset{}}
Link to this function

delete_session(session)

Deletes a session

Examples

iex> delete_session(session)
{:ok, %Session{}}

iex> delete_session(session)
{:error, %Ecto.Changeset{}}
Link to this function

get_bus_route(portico_id)

Gets a single bus route, by portico_id.

Returns nil if the BusRoute does not exist.

Examples

iex> get_bus_route("portico_id")
%BusRoute{}

iex> get_bus_route("bad_id")
nil
Link to this function

get_bus_route!(portico_id)

Gets a single bus route, by portico_id.

Raises Ecto.NoResultsError if the BusRoute does not exist.

Examples

iex> get_bus_route!("portico_id")
%BusRoute{}

iex> get_bus_route!("bad_id")
** (Ecto.NoResultsError)
Link to this function

get_contact(portico_contact_id)

Gets a single contact, by portico_contact_id.

Returns nil if the Contact does not exist.

Examples

iex> get_contact("portico_contact_id")
%Contact{}

iex> get_contact("bad_id")
nil
Link to this function

get_contact!(portico_contact_id)

Gets a single contact, by portico_contact_id.

Raises Ecto.NoResultsError if the Contact does not exist.

Examples

iex> get_contact!("portico_contact_id")
%Contact{}

iex> get_contact!("bad_id")
** (Ecto.NoResultsError)
Link to this function

get_course(portico_course_id)

Gets a single course, by portico_course_id.

Returns nil if the Course does not exist.

Examples

iex> get_course("portico_course_id")
%Course{}

iex> get_course("bad_id")
nil
Link to this function

get_course!(portico_course_id)

Gets a single course, by portico_course_id.

Raises Ecto.NoResultsError if the Course does not exist.

Examples

iex> get_course!("portico_course_id")
%Course{}

iex> get_course!("bad_id")
** (Ecto.NoResultsError)
Link to this function

get_credit_provider(portico_id)

Gets a single credit provider, by portico_id.

Returns nil if the CreditProvider does not exist.

Examples

iex> get_credit_provider("portico_id")
%CreditProvider{}

iex> get_credit_provider("bad_id")
nil
Link to this function

get_credit_provider!(portico_id)

Gets a single credit provider, by portico_id.

Raises Ecto.NoResultsError if the CreditProvider does not exist.

Examples

iex> get_credit_provider!("portico_id")
%CreditProvider{}

iex> get_credit_provider!("bad_id")
** (Ecto.NoResultsError)
Link to this function

get_enrollment(sis_enrollment_id)

Gets a single enrollment by sis_enrollment_id

Returns nil if none are found

Examples

iex> get_enrollment("abc")
%Enrollment{}

iex> get_enrollment("123")
nil
Link to this function

get_enrollment!(sis_enrollment_id)

Gets a single enrollment by sis_enrollment_id

(Portico uses a compound key for this)

Raises Ecto.NoResultsError if the Enrollment does not exist.

Examples

iex> get_enrollment("abc")
%Enrollment{}

iex> get_enrollment("123")
** (Ecto.NoResultsError)
Link to this function

get_session(portico_session_id)

Gets a single session by portico_session_id

Returns nil if none are found

Examples

iex> get_session("abc")
%Session{}

iex> get_session("123")
nil
Link to this function

get_session!(portico_session_id)

Gets a single session by portico_session_id

(Portico uses a compound key for this)

Raises Ecto.NoResultsError if the Session does not exist.

Examples

iex> get_session("abc")
%Session{}

iex> get_session("123")
** (Ecto.NoResultsError)
Link to this function

list_bus_routes()

Returns the list of bus routes.

Examples

iex> list_bus_routes()
[%BusRoute{}, ...]
Link to this function

list_contacts()

Returns the list of contacts.

Examples

iex> list_contacts()
[%Contact{}, ...]

Returns the list of courses.

Examples

iex> list_courses()
[%Course{}, ...]
Link to this function

list_credit_providers()

Returns the list of credit providers.

Examples

iex> list_credit_providers()
[%CreditProvider{}, ...]
Link to this function

list_enrollments()

Returns the list of enrollments

Examples

iex> list_enrollments()
[%Enrollment{}, ...]
Link to this function

list_sessions()

Returns the list of sessions

Examples

iex> list_sessions()
[%Session{}, ...]
Link to this function

query_courses_for_active_session_ids(active_session_ids, opts \\ [])

Generates a query of ZSchemas.Flat.Course records that have active_session_ids which overlap what is passed to this function

Returns an Ecto.Query for re-use in other searches

Opts

This function takes the following opts:

Link to this function

query_courses_for_grade(grade, opts \\ [])

Generates a query of ZSchemas.Flat.Course records where min_grade and max_grade complement a given grade.

Returns an Ecto.Query for re-use in other searches

Opts

This function takes the following opts:

Link to this function

query_courses_for_language_level(level, opts \\ [])

Generates a query of ZSchemas.Flat.Course records where language_level is <= the passed level (as an integer)

See sis_data::language_levels in Portico for the map of integers to fluency.

Returns an Ecto.Query for re-use in other searches

Opts

This function takes the following opts:

Link to this function

update_bus_route(bus_route, attrs)

Updates a bus route.

Examples

iex> update_bus_route(bus_route, %{field: new_value})
{:ok, %BusRoute{}}

iex> update_bus_route(bus_route, %{field: bad_value})
{:error, %Ecto.Changeset{}}
Link to this function

update_contact(contact, attrs)

Updates a contact.

Examples

iex> update_contact(contact, %{field: new_value})
{:ok, %Contact{}}

iex> update_contact(contact, %{field: bad_value})
{:error, %Ecto.Changeset{}}
Link to this function

update_course(course, attrs)

Updates a course.

Examples

iex> update_course(course, %{field: new_value})
{:ok, %Course{}}

iex> update_course(course, %{field: bad_value})
{:error, %Ecto.Changeset{}}
Link to this function

update_credit_provider(credit_provider, attrs)

Updates a credit provider.

Examples

iex> update_credit_provider(credit_provider, %{field: new_value})
{:ok, %CreditProvider{}}

iex> update_credit_provider(credit_provider, %{field: bad_value})
{:error, %Ecto.Changeset{}}
Link to this function

update_enrollment(enrollment, attrs)

Updates an enrollment

Examples

iex> update_enrollment(enrollment, %{field: new_value})
{:ok, %Enrollment{}}

iex> update_enrollment(enrollment, %{field: bad_value})
{:error, %Ecto.Changeset{}}
Link to this function

update_session(session, attrs)

Updates a session

Examples

iex> update_session(session, %{field: new_value})
{:ok, %Session{}}

iex> update_session(session, %{field: bad_value})
{:error, %Ecto.Changeset{}}