Skip to content

Commit

Permalink
fix conflict statement
Browse files Browse the repository at this point in the history
  • Loading branch information
benny-conn committed Oct 16, 2023
1 parent d44d9d4 commit e3eaa53
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
3 changes: 2 additions & 1 deletion db/migrations/core/000112_contract_l1.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ update contracts set l1_chain = 0;
alter table contracts alter column l1_chain set not null;
update contracts set l1_chain = 4 where chain = 4;
create index contracts_l1_chain_idx on contracts (address,chain,l1_chain) where deleted = false;
create unique index contracts_l1_chain_unique_idx on contracts (address,l1_chain) where deleted = false;
create unique index contracts_l1_chain_unique_idx on contracts (l1_chain,address) where parent_id is null;
create unique index contracts_l1_chain_parent_unique_idx on contracts (l1_chain,parent_id,address) where parent_id is not null;

drop view if exists contract_creators;

Expand Down
6 changes: 2 additions & 4 deletions service/persist/postgres/contract_gallery.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,14 @@ func NewContractGalleryRepository(db *sql.DB, queries *db.Queries) *ContractGall

upsertByAddressStmt, err := db.PrepareContext(ctx, `
insert into contracts (id,version,address,symbol,name,owner_address,chain,l1_chain,description,profile_image_url) values ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10)
on conflict (address,chain) where parent_id is null do update set
on conflict (address,l1_chain) where parent_id is null do update set
version = $2,
address = $3,
symbol = coalesce(nullif(contracts.symbol, ''), nullif($4, '')),
name = coalesce(nullif(contracts.name, ''), nullif($5, '')),
description = coalesce(nullif(contracts.description, ''), nullif($9, '')),
profile_image_url = coalesce(nullif(contracts.profile_image_url, ''), nullif($10, '')),
owner_address = case when nullif(contracts.owner_address, '') is null then $6 else contracts.owner_address end,
chain = $7,
l1_chain = $8
owner_address = case when nullif(contracts.owner_address, '') is null then $6 else contracts.owner_address end
returning id;
`)
checkNoErr(err)
Expand Down
2 changes: 1 addition & 1 deletion service/recommend/userpref/personalize.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ func (p *Personalization) update(ctx context.Context) {

if p.pM == nil {
logger.For(ctx).Infof("no data loaded, reading from cache")
p.readCache(ctx)
// p.readCache(ctx)
return
}

Expand Down

0 comments on commit e3eaa53

Please sign in to comment.