Overhaul publicreport storage layer, create unified tables
This is a huge change. I was getting really sick of the split between nuisance/water tables when more than half of the data they store is common. I finally bit off the big work of switching it all. This creates a single unified table, publicreport.report and copies the existing report data into it. It also ports existing data from the original tables into the new table. Along with all of this I also overhauled the system for handling asynchronous work to use a LISTEN/NOTIFY connection from the database and a single cache table to avoid ever losing work.
This commit is contained in:
parent
2538638c9d
commit
1e071d5ce5
109 changed files with 22903 additions and 11713 deletions
|
|
@ -31,16 +31,12 @@ type contentListCommunication struct {
|
|||
}
|
||||
|
||||
func listCommunication(ctx context.Context, r *http.Request, user platform.User, query queryParams) (*contentListCommunication, *nhttp.ErrorWithStatus) {
|
||||
nreports, err := publicreport.NuisanceReportForOrganization(ctx, user.Organization.ID())
|
||||
reports, err := publicreport.ReportsForOrganization(ctx, user.Organization.ID())
|
||||
if err != nil {
|
||||
return nil, nhttp.NewError("nuisance report query: %w", err)
|
||||
}
|
||||
wreports, err := publicreport.WaterReportForOrganization(ctx, user.Organization.ID())
|
||||
if err != nil {
|
||||
return nil, nhttp.NewError("water report query: %w", err)
|
||||
}
|
||||
comms := make([]communication, len(nreports)+len(wreports))
|
||||
for i, report := range nreports {
|
||||
comms := make([]communication, len(reports))
|
||||
for i, report := range reports {
|
||||
comms[i] = communication{
|
||||
Created: report.Created,
|
||||
History: []historyEntry{
|
||||
|
|
@ -54,20 +50,6 @@ func listCommunication(ctx context.Context, r *http.Request, user platform.User,
|
|||
Type: "nuisance",
|
||||
}
|
||||
}
|
||||
for i, report := range wreports {
|
||||
comms[i+len(nreports)] = communication{
|
||||
Created: report.Created,
|
||||
History: []historyEntry{
|
||||
historyEntry{
|
||||
Action: "created",
|
||||
Timestamp: report.Created,
|
||||
},
|
||||
},
|
||||
ID: report.PublicID,
|
||||
PublicReport: report,
|
||||
Type: "water",
|
||||
}
|
||||
}
|
||||
_by_created := func(a, b communication) int {
|
||||
if a.Created == b.Created {
|
||||
return 0
|
||||
|
|
|
|||
|
|
@ -54,6 +54,9 @@ func postPublicreportMessage(ctx context.Context, r *http.Request, user platform
|
|||
if err != nil {
|
||||
return nil, nhttp.NewError("failed to create message: %s", err)
|
||||
}
|
||||
if msg_id == nil {
|
||||
return nil, nhttp.NewError("nil message id")
|
||||
}
|
||||
return &createdMessage{
|
||||
URI: config.MakeURLNidus("/message/%s", strconv.Itoa(int(*msg_id))),
|
||||
}, nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue