Add new view for report counts and invalidated status
Also drop site.version from the primary key.
This commit is contained in:
parent
9525363bc8
commit
32dcc50c94
23 changed files with 1656 additions and 623 deletions
140
db/models/publicreport.organization_report_count.bob.go
Normal file
140
db/models/publicreport.organization_report_count.bob.go
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
// Code generated by BobGen psql v0.42.5. DO NOT EDIT.
|
||||
// This file is meant to be re-generated in place and/or deleted at any time.
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/Gleipnir-Technology/bob"
|
||||
"github.com/Gleipnir-Technology/bob/dialect/psql"
|
||||
"github.com/Gleipnir-Technology/bob/expr"
|
||||
"github.com/aarondl/opt/null"
|
||||
)
|
||||
|
||||
// PublicreportOrganizationReportCount is an object representing the database table.
|
||||
type PublicreportOrganizationReportCount struct {
|
||||
OrganizationID null.Val[int32] `db:"organization_id" `
|
||||
NuisanceReported null.Val[int64] `db:"nuisance_reported" `
|
||||
NuisanceReviewed null.Val[int64] `db:"nuisance_reviewed" `
|
||||
NuisanceScheduled null.Val[int64] `db:"nuisance_scheduled" `
|
||||
NuisanceTreated null.Val[int64] `db:"nuisance_treated" `
|
||||
NuisanceInvalidated null.Val[int64] `db:"nuisance_invalidated" `
|
||||
WaterReported null.Val[int64] `db:"water_reported" `
|
||||
WaterReviewed null.Val[int64] `db:"water_reviewed" `
|
||||
WaterScheduled null.Val[int64] `db:"water_scheduled" `
|
||||
WaterTreated null.Val[int64] `db:"water_treated" `
|
||||
WaterInvalidated null.Val[int64] `db:"water_invalidated" `
|
||||
}
|
||||
|
||||
// PublicreportOrganizationReportCountSlice is an alias for a slice of pointers to PublicreportOrganizationReportCount.
|
||||
// This should almost always be used instead of []*PublicreportOrganizationReportCount.
|
||||
type PublicreportOrganizationReportCountSlice []*PublicreportOrganizationReportCount
|
||||
|
||||
// PublicreportOrganizationReportCounts contains methods to work with the organization_report_count view
|
||||
var PublicreportOrganizationReportCounts = psql.NewViewx[*PublicreportOrganizationReportCount, PublicreportOrganizationReportCountSlice]("publicreport", "organization_report_count", buildPublicreportOrganizationReportCountColumns("publicreport.organization_report_count"))
|
||||
|
||||
// PublicreportOrganizationReportCountsQuery is a query on the organization_report_count view
|
||||
type PublicreportOrganizationReportCountsQuery = *psql.ViewQuery[*PublicreportOrganizationReportCount, PublicreportOrganizationReportCountSlice]
|
||||
|
||||
func buildPublicreportOrganizationReportCountColumns(alias string) publicreportOrganizationReportCountColumns {
|
||||
return publicreportOrganizationReportCountColumns{
|
||||
ColumnsExpr: expr.NewColumnsExpr(
|
||||
"organization_id", "nuisance_reported", "nuisance_reviewed", "nuisance_scheduled", "nuisance_treated", "nuisance_invalidated", "water_reported", "water_reviewed", "water_scheduled", "water_treated", "water_invalidated",
|
||||
).WithParent("publicreport.organization_report_count"),
|
||||
tableAlias: alias,
|
||||
OrganizationID: psql.Quote(alias, "organization_id"),
|
||||
NuisanceReported: psql.Quote(alias, "nuisance_reported"),
|
||||
NuisanceReviewed: psql.Quote(alias, "nuisance_reviewed"),
|
||||
NuisanceScheduled: psql.Quote(alias, "nuisance_scheduled"),
|
||||
NuisanceTreated: psql.Quote(alias, "nuisance_treated"),
|
||||
NuisanceInvalidated: psql.Quote(alias, "nuisance_invalidated"),
|
||||
WaterReported: psql.Quote(alias, "water_reported"),
|
||||
WaterReviewed: psql.Quote(alias, "water_reviewed"),
|
||||
WaterScheduled: psql.Quote(alias, "water_scheduled"),
|
||||
WaterTreated: psql.Quote(alias, "water_treated"),
|
||||
WaterInvalidated: psql.Quote(alias, "water_invalidated"),
|
||||
}
|
||||
}
|
||||
|
||||
type publicreportOrganizationReportCountColumns struct {
|
||||
expr.ColumnsExpr
|
||||
tableAlias string
|
||||
OrganizationID psql.Expression
|
||||
NuisanceReported psql.Expression
|
||||
NuisanceReviewed psql.Expression
|
||||
NuisanceScheduled psql.Expression
|
||||
NuisanceTreated psql.Expression
|
||||
NuisanceInvalidated psql.Expression
|
||||
WaterReported psql.Expression
|
||||
WaterReviewed psql.Expression
|
||||
WaterScheduled psql.Expression
|
||||
WaterTreated psql.Expression
|
||||
WaterInvalidated psql.Expression
|
||||
}
|
||||
|
||||
func (c publicreportOrganizationReportCountColumns) Alias() string {
|
||||
return c.tableAlias
|
||||
}
|
||||
|
||||
func (publicreportOrganizationReportCountColumns) AliasedAs(alias string) publicreportOrganizationReportCountColumns {
|
||||
return buildPublicreportOrganizationReportCountColumns(alias)
|
||||
}
|
||||
|
||||
// AfterQueryHook is called after PublicreportOrganizationReportCount is retrieved from the database
|
||||
func (o *PublicreportOrganizationReportCount) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
|
||||
var err error
|
||||
|
||||
switch queryType {
|
||||
case bob.QueryTypeSelect:
|
||||
ctx, err = PublicreportOrganizationReportCounts.AfterSelectHooks.RunHooks(ctx, exec, PublicreportOrganizationReportCountSlice{o})
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// AfterQueryHook is called after PublicreportOrganizationReportCountSlice is retrieved from the database
|
||||
func (o PublicreportOrganizationReportCountSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
|
||||
var err error
|
||||
|
||||
switch queryType {
|
||||
case bob.QueryTypeSelect:
|
||||
ctx, err = PublicreportOrganizationReportCounts.AfterSelectHooks.RunHooks(ctx, exec, o)
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
type publicreportOrganizationReportCountWhere[Q psql.Filterable] struct {
|
||||
OrganizationID psql.WhereNullMod[Q, int32]
|
||||
NuisanceReported psql.WhereNullMod[Q, int64]
|
||||
NuisanceReviewed psql.WhereNullMod[Q, int64]
|
||||
NuisanceScheduled psql.WhereNullMod[Q, int64]
|
||||
NuisanceTreated psql.WhereNullMod[Q, int64]
|
||||
NuisanceInvalidated psql.WhereNullMod[Q, int64]
|
||||
WaterReported psql.WhereNullMod[Q, int64]
|
||||
WaterReviewed psql.WhereNullMod[Q, int64]
|
||||
WaterScheduled psql.WhereNullMod[Q, int64]
|
||||
WaterTreated psql.WhereNullMod[Q, int64]
|
||||
WaterInvalidated psql.WhereNullMod[Q, int64]
|
||||
}
|
||||
|
||||
func (publicreportOrganizationReportCountWhere[Q]) AliasedAs(alias string) publicreportOrganizationReportCountWhere[Q] {
|
||||
return buildPublicreportOrganizationReportCountWhere[Q](buildPublicreportOrganizationReportCountColumns(alias))
|
||||
}
|
||||
|
||||
func buildPublicreportOrganizationReportCountWhere[Q psql.Filterable](cols publicreportOrganizationReportCountColumns) publicreportOrganizationReportCountWhere[Q] {
|
||||
return publicreportOrganizationReportCountWhere[Q]{
|
||||
OrganizationID: psql.WhereNull[Q, int32](cols.OrganizationID),
|
||||
NuisanceReported: psql.WhereNull[Q, int64](cols.NuisanceReported),
|
||||
NuisanceReviewed: psql.WhereNull[Q, int64](cols.NuisanceReviewed),
|
||||
NuisanceScheduled: psql.WhereNull[Q, int64](cols.NuisanceScheduled),
|
||||
NuisanceTreated: psql.WhereNull[Q, int64](cols.NuisanceTreated),
|
||||
NuisanceInvalidated: psql.WhereNull[Q, int64](cols.NuisanceInvalidated),
|
||||
WaterReported: psql.WhereNull[Q, int64](cols.WaterReported),
|
||||
WaterReviewed: psql.WhereNull[Q, int64](cols.WaterReviewed),
|
||||
WaterScheduled: psql.WhereNull[Q, int64](cols.WaterScheduled),
|
||||
WaterTreated: psql.WhereNull[Q, int64](cols.WaterTreated),
|
||||
WaterInvalidated: psql.WhereNull[Q, int64](cols.WaterInvalidated),
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue