Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(star): return version and updated by #83

Merged
merged 1 commit into from
Feb 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions store/postgres/asset_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -605,17 +605,17 @@ func (r *AssetRepository) buildSQL(builder sq.SelectBuilder) (query string, args

func (r *AssetRepository) getAssetSQL() sq.SelectBuilder {
return sq.Select(`
a.id as "id",
a.urn as "urn",
a.type as "type",
a.name as "name",
a.service as"service",
a.description as "description",
a.data as "data",
a.labels as "labels",
a.version as "version",
a.created_at as "created_at",
a.updated_at as "updated_at",
a.id as id,
a.urn as urn,
a.type as type,
a.name as name,
a.service as service,
a.description as description,
a.data as data,
a.labels as labels,
a.version as version,
a.created_at as created_at,
a.updated_at as updated_at,
u.id as "updated_by.id",
u.email as "updated_by.email",
u.provider as "updated_by.provider",
Expand All @@ -628,19 +628,19 @@ func (r *AssetRepository) getAssetSQL() sq.SelectBuilder {

func (r *AssetRepository) getAssetVersionSQL() sq.SelectBuilder {
return sq.Select(`
a.asset_id as "id",
a.urn as "urn",
a.type as "type",
a.name as "name",
a.service as"service",
a.description as "description",
a.data as "data",
a.labels as "labels",
a.version as "version",
a.created_at as "created_at",
a.updated_at as "updated_at",
a.changelog as "changelog",
a.owners as "owners",
a.asset_id as id,
a.urn as urn,
a.type as type,
a.name as name,
a.service as service,
a.description as description,
a.data as data,
a.labels as labels,
a.version as version,
a.created_at as created_at,
a.updated_at as updated_at,
a.changelog as changelog,
a.owners as owners,
u.id as "updated_by.id",
u.email as "updated_by.email",
u.provider as "updated_by.provider",
Expand Down
34 changes: 29 additions & 5 deletions store/postgres/star_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,20 @@ func (r *StarRepository) GetAllAssetsByUserID(ctx context.Context, cfg star.Conf
a.description as description,
a.data as data,
a.labels as labels,
a.version as version,
a.created_at as created_at,
a.updated_at as updated_at
a.updated_at as updated_at,
u.id as "updated_by.id",
u.email as "updated_by.email",
u.provider as "updated_by.provider",
u.created_at as "updated_by.created_at",
u.updated_at as "updated_by.updated_at"
FROM
stars s
JOIN
INNER JOIN
assets a ON s.asset_id = a.id
LEFT JOIN
users u ON a.updated_by = u.id
WHERE
s.user_id = $1
ORDER BY
Expand Down Expand Up @@ -174,12 +182,20 @@ func (r *StarRepository) GetAllAssetsByUserEmail(ctx context.Context, cfg star.C
a.description as description,
a.data as data,
a.labels as labels,
a.version as version,
a.created_at as created_at,
a.updated_at as updated_at
a.updated_at as updated_at,
ub.id as "updated_by.id",
ub.email as "updated_by.email",
ub.provider as "updated_by.provider",
ub.created_at as "updated_by.created_at",
ub.updated_at as "updated_by.updated_at"
FROM
stars s
INNER JOIN
assets a ON s.asset_id = a.id
LEFT JOIN
users ub ON a.updated_by = ub.id
INNER JOIN
users u ON s.user_id = u.id
WHERE
Expand Down Expand Up @@ -232,12 +248,20 @@ func (r *StarRepository) GetAssetByUserID(ctx context.Context, userID string, as
a.description,
a.data,
a.labels,
a.version,
a.created_at,
a.updated_at
a.updated_at,
u.id as "updated_by.id",
u.email as "updated_by.email",
u.provider as "updated_by.provider",
u.created_at as "updated_by.created_at",
u.updated_at as "updated_by.updated_at"
FROM
stars s
JOIN
INNER JOIN
assets a ON s.asset_id = a.id
LEFT JOIN
users u ON a.updated_by = u.id
WHERE
s.user_id = $1 AND s.asset_id = $2
LIMIT 1
Expand Down