Skip to content

Commit

Permalink
chore: reporting requirement has expenses computed column
Browse files Browse the repository at this point in the history
  • Loading branch information
mikevespi committed Jul 13, 2022
1 parent 7befe55 commit f9caec5
Show file tree
Hide file tree
Showing 6 changed files with 160 additions and 0 deletions.
21 changes: 21 additions & 0 deletions app/schema/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -47756,6 +47756,7 @@ type ReportType implements Node {

"""created by user id"""
createdBy: Int
hasExpenses: Boolean

"""
A globally unique identifier. Can be used in various places throughout the system to identify this single value.
Expand Down Expand Up @@ -48079,6 +48080,9 @@ input ReportTypeCondition {
"""Checks for equality with the object’s `createdBy` field."""
createdBy: Int

"""Checks for equality with the object’s `hasExpenses` field."""
hasExpenses: Boolean

"""Checks for equality with the object’s `isMilestone` field."""
isMilestone: Boolean

Expand Down Expand Up @@ -48129,6 +48133,9 @@ input ReportTypeFilter {
"""Filter by the object’s `createdBy` field."""
createdBy: IntFilter

"""Filter by the object’s `hasExpenses` field."""
hasExpenses: BooleanFilter

"""Filter by the object’s `isMilestone` field."""
isMilestone: BooleanFilter

Expand Down Expand Up @@ -48167,6 +48174,7 @@ input ReportTypeInput {

"""created by user id"""
createdBy: Int
hasExpenses: Boolean

"""
Boolean value indicates if this report type record is a Milestone. There are several different milestones and this value allows for easier filtering.
Expand Down Expand Up @@ -48198,6 +48206,7 @@ input ReportTypePatch {

"""created by user id"""
createdBy: Int
hasExpenses: Boolean

"""
Boolean value indicates if this report type record is a Milestone. There are several different milestones and this value allows for easier filtering.
Expand Down Expand Up @@ -48405,6 +48414,8 @@ enum ReportTypesOrderBy {
CREATED_AT_DESC
CREATED_BY_ASC
CREATED_BY_DESC
HAS_EXPENSES_ASC
HAS_EXPENSES_DESC
IS_MILESTONE_ASC
IS_MILESTONE_DESC
NAME_ASC
Expand Down Expand Up @@ -48847,6 +48858,11 @@ type ReportingRequirement implements Node {
orderBy: [EmissionIntensityReportsOrderBy!] = [PRIMARY_KEY_ASC]
): EmissionIntensityReportsConnection!

"""
Returns the value of the has_expenses column for the report_type of the given reporting_requirement
"""
hasExpenses: Boolean

"""
A globally unique identifier. Can be used in various places throughout the system to identify this single value.
"""
Expand Down Expand Up @@ -49675,6 +49691,9 @@ input ReportingRequirementFilter {
"""Some related `emissionIntensityReportsByReportingRequirementId` exist."""
emissionIntensityReportsByReportingRequirementIdExist: Boolean

"""Filter by the object’s `hasExpenses` field."""
hasExpenses: BooleanFilter

"""
Filter by the object’s `milestoneReportsByReportingRequirementId` relation.
"""
Expand Down Expand Up @@ -49954,6 +49973,8 @@ enum ReportingRequirementsOrderBy {
REPORT_TYPE_BY_REPORT_TYPE__CREATED_AT_DESC
REPORT_TYPE_BY_REPORT_TYPE__CREATED_BY_ASC
REPORT_TYPE_BY_REPORT_TYPE__CREATED_BY_DESC
REPORT_TYPE_BY_REPORT_TYPE__HAS_EXPENSES_ASC
REPORT_TYPE_BY_REPORT_TYPE__HAS_EXPENSES_DESC
REPORT_TYPE_BY_REPORT_TYPE__IS_MILESTONE_ASC
REPORT_TYPE_BY_REPORT_TYPE__IS_MILESTONE_DESC
REPORT_TYPE_BY_REPORT_TYPE__NAME_ASC
Expand Down
98 changes: 98 additions & 0 deletions app/schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -164283,6 +164283,18 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "hasExpenses",
"description": null,
"args": [],
"type": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "id",
"description": "A globally unique identifier. Can be used in various places throughout the system to identify this single value.",
Expand Down Expand Up @@ -165354,6 +165366,16 @@
},
"defaultValue": null
},
{
"name": "hasExpenses",
"description": "Checks for equality with the object’s `hasExpenses` field.",
"type": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
},
"defaultValue": null
},
{
"name": "isMilestone",
"description": "Checks for equality with the object’s `isMilestone` field.",
Expand Down Expand Up @@ -165523,6 +165545,16 @@
},
"defaultValue": null
},
{
"name": "hasExpenses",
"description": "Filter by the object’s `hasExpenses` field.",
"type": {
"kind": "INPUT_OBJECT",
"name": "BooleanFilter",
"ofType": null
},
"defaultValue": null
},
{
"name": "isMilestone",
"description": "Filter by the object’s `isMilestone` field.",
Expand Down Expand Up @@ -165662,6 +165694,16 @@
},
"defaultValue": null
},
{
"name": "hasExpenses",
"description": null,
"type": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
},
"defaultValue": null
},
{
"name": "isMilestone",
"description": "Boolean value indicates if this report type record is a Milestone. There are several different milestones and this value allows for easier filtering.",
Expand Down Expand Up @@ -165757,6 +165799,16 @@
},
"defaultValue": null
},
{
"name": "hasExpenses",
"description": null,
"type": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
},
"defaultValue": null
},
{
"name": "isMilestone",
"description": "Boolean value indicates if this report type record is a Milestone. There are several different milestones and this value allows for easier filtering.",
Expand Down Expand Up @@ -166654,6 +166706,18 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "HAS_EXPENSES_ASC",
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "HAS_EXPENSES_DESC",
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "IS_MILESTONE_ASC",
"description": null,
Expand Down Expand Up @@ -168002,6 +168066,18 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "hasExpenses",
"description": "Returns the value of the has_expenses column for the report_type of the given reporting_requirement",
"args": [],
"type": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "id",
"description": "A globally unique identifier. Can be used in various places throughout the system to identify this single value.",
Expand Down Expand Up @@ -170848,6 +170924,16 @@
},
"defaultValue": null
},
{
"name": "hasExpenses",
"description": "Filter by the object’s `hasExpenses` field.",
"type": {
"kind": "INPUT_OBJECT",
"name": "BooleanFilter",
"ofType": null
},
"defaultValue": null
},
{
"name": "milestoneReportsByReportingRequirementId",
"description": "Filter by the object’s `milestoneReportsByReportingRequirementId` relation.",
Expand Down Expand Up @@ -172102,6 +172188,18 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "REPORT_TYPE_BY_REPORT_TYPE__HAS_EXPENSES_ASC",
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "REPORT_TYPE_BY_REPORT_TYPE__HAS_EXPENSES_DESC",
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "REPORT_TYPE_BY_REPORT_TYPE__IS_MILESTONE_ASC",
"description": null,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
-- Deploy cif:computed_columns/reporting_requirement_has_expenses to pg
-- requires: tables/report_type
-- requires: tables/reporting_requirement

begin;

create function cif.reporting_requirement_has_expenses(cif.reporting_requirement)
returns boolean as
$computed_column$
select has_expenses
from cif.report_type
where name = $1.report_type;
$computed_column$ language sql stable;

comment on function cif.reporting_requirement_has_expenses(cif.reporting_requirement) is
'Returns the value of the has_expenses column for the report_type of the given reporting_requirement';

commit;

-- create function cif.reporting_requirement_has_expenses(cif.reporting_requirement)
-- returns boolean as
-- $computed_column$
-- select has_expenses
-- from cif.report_type
-- where name = $1.report_type;
-- $computed_column$ language sql stable;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- Revert cif:computed_columns/reporting_requirement_has_expenses from pg

begin;

drop function cif.reporting_requirement_has_expenses;

commit;
1 change: 1 addition & 0 deletions schema/sqitch.plan
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,4 @@ tables/milestone_report [tables/reporting_requirement] 2022-06-22T21:01:22Z Dyla
mutations/add_milestone_to_revision [tables/reporting_requirement tables/form_change] 2022-06-23T23:26:45Z Dylan Leard <dylan@button.is> # A custom mutation chain to create form_change records for multiple tables when creating a milestone
mutations/discard_milestone_form_change [tables/form_change tables/project_revision] 2022-06-24T16:25:29Z Dylan Leard <dylan@button.is> # Custom mutation to discard a set of form_change records relating to a milestone_report
tables/funding_parameter 2022-06-23T17:34:25Z Gurjeet Matharu <gurjeet@matharuco.com> # funding parameter table
computed_columns/reporting_requirement_has_expenses [tables/report_type tables/reporting_requirement] 2022-07-06T22:31:55Z Mike Vesprini <mike@button.is> # Computed column returns true if the report type of the reporting requirement has payments associated with it
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- Verify cif:computed_columns/reporting_requirement_has_expenses on pg

BEGIN;

select pg_get_functiondef('cif.reporting_requirement_has_expenses(cif.reporting_requirement)'::regprocedure);

ROLLBACK;

0 comments on commit f9caec5

Please sign in to comment.