Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
emranemran committed Feb 27, 2024
1 parent 09e50d1 commit 8bb0cfa
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
22 changes: 20 additions & 2 deletions packages/api/src/controllers/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -635,8 +635,18 @@ const fieldsMap = {
} as const;

app.get("/", authorizer({}), async (req, res) => {
let { limit, cursor, all, allUsers, order, filters, count, cid, ...otherQs } =
toStringValues(req.query);
let {
limit,
cursor,
all,
allUsers,
order,
filters,
count,
cid,
projectId,
...otherQs
} = toStringValues(req.query);
const fieldFilters = _(otherQs)
.pick("playbackId", "sourceUrl", "phase")
.map((v, k) => ({ id: k, value: decodeURIComponent(v) }))
Expand Down Expand Up @@ -664,6 +674,14 @@ app.get("/", authorizer({}), async (req, res) => {
query.push(sql`asset.data->>'deleted' IS NULL`);
}

if (projectId) {
query.push(sql`asset.data->>'projectId' = ${projectId}`);
} else {
query.push(
sql`(asset.data->>'projectId' IS NULL OR asset.data->>'projectId' = '')`
);
}

let output: WithID<Asset>[];
let newCursor: string;
if (req.user.admin && allUsers && allUsers !== "false") {
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/controllers/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ app.post("/", authorizer({}), async (req, res) => {
const id = uuid();
await db.project.create({
id: id,
name: "foo",
name: name,
userId: req.user.id,
createdAt: Date.now(),
});
Expand Down
1 change: 0 additions & 1 deletion packages/api/src/schema/api-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,6 @@ components:
additionalProperties: false
required:
- name
- projectId
properties:
name:
type: string
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/store/asset-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export default class AssetTable extends Table<WithID<Asset>> {
query.push(sql`asset.data->>'projectId' = ${projectId}`);
} else {
query.push(
sql`(asset.data->>'projectId' IS NULL OR NOT asset.data ? 'projectId')`
sql`(asset.data->>'projectId' IS NULL OR asset.data->>'projectId' = '')`
);
}
console.log("XXX: HERE");
Expand Down

0 comments on commit 8bb0cfa

Please sign in to comment.