Add a resource for getting service requests

This commit is contained in:
Eli Ribble 2026-04-14 19:59:32 +00:00
parent 28ec1c3d67
commit 4a440e3022
No known key found for this signature in database
18 changed files with 387 additions and 51 deletions

27
platform/sync.go Normal file
View file

@ -0,0 +1,27 @@
package platform
import (
"context"
"fmt"
"github.com/Gleipnir-Technology/bob/dialect/psql/sm"
"github.com/Gleipnir-Technology/nidus-sync/db"
"github.com/Gleipnir-Technology/nidus-sync/db/models"
"github.com/Gleipnir-Technology/nidus-sync/platform/types"
)
func SyncList(ctx context.Context, user User, limit int) ([]*types.Sync, error) {
syncs, err := models.FieldseekerSyncs.Query(
models.SelectWhere.FieldseekerSyncs.OrganizationID.EQ(user.Organization.ID),
sm.OrderBy(models.FieldseekerSyncs.Columns.Created).Desc(),
).All(ctx, db.PGInstance.BobDB)
if err != nil {
return nil, fmt.Errorf("query sync: %w", err)
}
results := make([]*types.Sync, len(syncs))
for i, s := range syncs {
r := types.SyncFromModel(s)
results[i] = &r
}
return results, nil
}