Skip to content

Commit

Permalink
Add display name support to addons
Browse files Browse the repository at this point in the history
  • Loading branch information
NavidK0 committed Feb 24, 2021
1 parent f713580 commit b579996
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 10 deletions.
1 change: 1 addition & 0 deletions server/src/@types/db-types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ interface DbAddon {
user_id: string,
resource_id: string,
type: addon_t,
display_name: string,
description: string,
author: string,
tags: string[],
Expand Down
1 change: 1 addition & 0 deletions server/src/@types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ interface Addon {
userId: string,
resourceId: string,
type: AddonType,
displayName: string,
description: string,
author: string,
tags: string[],
Expand Down
2 changes: 2 additions & 0 deletions server/src/controllers/analytics-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ export class AnalyticsController extends Controller {
this.mixpanel.track('viewed profile', {
distinct_id: profile.userId,
profile: profile.id,
handle: profile.handle
});
} else {
await this.analyticsService.createAnonymousVisit("page");
Expand All @@ -194,6 +195,7 @@ export class AnalyticsController extends Controller {
this.mixpanel.track('viewed profile', {
distinct_id: Constants.ANONYMOUS_USER_ID,
profile: profile.id,
handle: profile.handle
});
}

Expand Down
2 changes: 2 additions & 0 deletions server/src/controllers/marketplace-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ export class MarketplaceController extends Controller {
if (this.mixpanel)
this.mixpanel.track('addon viewed', {
distinct_id: request.body.authUser.id,
addon: addon.id,
name: addon.displayName ?? undefined
});

if (request.body.detailed)
Expand Down
24 changes: 14 additions & 10 deletions server/src/services/marketplace-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,10 @@ export class MarketplaceService extends DatabaseService {
*/
async createAddon(addon: Partial<Addon>): Promise<Addon> {
//language=PostgreSQL
let queryStr = `insert into marketplace.addons(user_id, resource_id, type, description, author, tags, price,
let queryStr = `insert into marketplace.addons(user_id, resource_id, type, display_name, description, author, tags,
price,
payment_frequency, global, version, last_updated)
values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, current_timestamp)
values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, current_timestamp)
returning *`;

if (!addon.global) {
Expand All @@ -103,6 +104,7 @@ export class MarketplaceService extends DatabaseService {
addon.userId,
addon.resourceId,
addon.type,
addon.displayName,
addon.description,
addon.author,
addon.tags,
Expand All @@ -126,14 +128,15 @@ export class MarketplaceService extends DatabaseService {
let queryStr = `update marketplace.addons
set resource_id=coalesce($2, resource_id),
type=coalesce($3, type),
description=$4,
author=$5,
tags=$6,
featured_sorting=coalesce($7, featured_sorting),
price=$8,
payment_frequency=$9,
global=coalesce($10, global),
version=$11,
display_name=$4,
description=$5,
author=$6,
tags=$7,
featured_sorting=coalesce($8, featured_sorting),
price=$9,
payment_frequency=$10,
global=coalesce($11, global),
version=$12,
last_updated=current_timestamp
where id = $1
returning *`;
Expand All @@ -143,6 +146,7 @@ export class MarketplaceService extends DatabaseService {
addon.id,
addon.resourceId,
addon.type,
addon.displayName,
addon.description,
addon.author,
addon.tags,
Expand Down
2 changes: 2 additions & 0 deletions server/src/sql/setup-marketplace.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ create table if not exists marketplace.addons
user_id bigint references app.users (id) on update cascade on delete no action,
resource_id bigint unique not null, -- The id of the resource this addon is related to
type addon_t not null, -- The type of resource this is
display_name text, -- The name of this resource
description text,
author text,
tags text[],
Expand All @@ -26,6 +27,7 @@ create table if not exists marketplace.addons
);

create index if not exists addons_type on marketplace.addons (type);
create index if not exists addons_display_name on marketplace.addons (display_name);
create index if not exists addons_description on marketplace.addons (description);
create index if not exists addons_author on marketplace.addons (author);
create index if not exists addons_tags on marketplace.addons (tags);
Expand Down
1 change: 1 addition & 0 deletions server/src/utils/db-type-converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export class DbTypeConverter {
userId: addon.user_id,
resourceId: addon.resource_id,
type: addon.type,
displayName: addon.display_name,
description: addon.description,
author: addon.author,
tags: addon.tags,
Expand Down

0 comments on commit b579996

Please sign in to comment.