Skip to content

Commit

Permalink
Update - Ajout de la recherche du nom du producteur pour search products
Browse files Browse the repository at this point in the history
  • Loading branch information
noelmugnier committed Nov 11, 2020
1 parent 03986e8 commit c134f78
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Sheaft.Application.Queries/ProductQueries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public async Task<ProductsSearchDto> SearchAsync(SearchTermsInput terms, Request
SearchMode = SearchMode.Any,
Top = terms.Take,
Skip = (terms.Page - 1) * terms.Take,
SearchFields = new List<string> { "partialProductName" },
SearchFields = new List<string> { "partialProductName", "partialProducerName" },
Select = new List<string>()
{
"product_id", "product_name", "product_onSalePricePerUnit", "product_onSalePrice", "product_rating", "product_ratings_count", "product_image", "product_tags", "producer_id", "producer_name", "producer_email", "producer_phone", "producer_zipcode", "producer_city", "producer_longitude", "producer_latitude", "product_returnable", "product_unit", "product_quantityPerUnit", "product_conditioning", "product_available"
Expand Down
2 changes: 1 addition & 1 deletion Sheaft.Infrastructure.Persistence/Data/init.txt
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@
migrationBuilder.Sql("CREATE VIEW [app].StoresPerDepartment AS select DepartmentId, DepartmentCode, DepartmentName, RegionId, RegionCode, RegionName, sum(Active) AS Active, sum(Created) as Created from ( select d.Id as DepartmentId, d.Code as DepartmentCode, d.Name as DepartmentName, r.Id as RegionId, r.Code as RegionCode, r.Name as RegionName, case when count(p.Uid) > 0 then 1 else 0 end as Active, count(distinct(c.Uid)) as Created from app.Departments d join app.Regions r on r.Uid = d.RegionUid left join app.UserAddresses ca on d.Uid = ca.DepartmentUid left join app.Users c on c.Uid = ca.UserUid and c.Kind = 1 left join app.Products p on c.Uid = p.ProducerUid group by c.Kind, d.Id, d.Code, d.Name, r.Id, r.Code, r.Name, c.RemovedOn ) cc group by DepartmentId, DepartmentCode, DepartmentName, RegionId, RegionCode, RegionName");

migrationBuilder.Sql("CREATE VIEW [app].ProducersSearch as select r.Id as producer_id , r.Name as producer_name , r.Name as partialProducerName , r.Email as producer_email , r.Picture as producer_picture , r.Phone as producer_phone , ra.Line1 as producer_line1 , ra.Line2 as producer_line2 , ra.Zipcode as producer_zipcode , ra.City as producer_city , app.InlineMax(r.CreatedOn, app.InlineMax(r.UpdatedOn, t.UpdatedOn)) as last_update , case when r.RemovedOn is null then 0 else 1 end as removed , '[' + STRING_AGG('\"' + LOWER(t.Name) + '\"', ',') + ']' as producer_tags , ra.Longitude as producer_longitude , ra.Latitude as producer_latitude , geography::STGeomFromText('POINT('+convert(varchar(20),ra.Longitude)+' '+convert(varchar(20),ra.Latitude)+')',4326) as producer_geolocation , count(p.Id) as producer_products_count from app.Users r join app.UserAddresses ra on r.Uid = ra.UserUid left join app.ProducerTags ct on r.Uid = ct.ProducerUid left join app.Tags t on t.Uid = ct.TagUid left join app.Products p on p.ProducerUid = r.Uid where r.Kind = 0 and r.OpenForNewBusiness = 1 group by r.Id, r.Name, r.Email, r.Picture, r.Phone, ra.Line1, ra.Line2, ra.Zipcode, ra.City, app.InlineMax(r.CreatedOn, app.InlineMax(r.UpdatedOn, t.UpdatedOn)), case when r.RemovedOn is null then 0 else 1 end, ra.Longitude, ra.Latitude");
migrationBuilder.Sql("CREATE VIEW [app].ProductsSearch as select p.Id as product_id , p.Name as product_name , p.Name as partialProductName , CAST(p.QuantityPerUnit as float) as product_quantityPerUnit , case when p.Unit = 1 then 'mL' when p.Unit = 2 then 'L' when p.Unit = 3 then 'g' when p.Unit = 4 then 'kg' end as product_unit , CAST(p.OnSalePricePerUnit as float) as product_onSalePricePerUnit , CAST(p.OnSalePrice as float) as product_onSalePrice , CAST(p.Rating as float) as product_rating , p.RatingsCount as product_ratings_count , case when pa.Uid is not null then cast(1 as bit) else cast(0 as bit) end as product_returnable , r.Id as producer_id , r.Name as producer_name , r.Email as producer_email , r.Phone as producer_phone , ra.Zipcode as producer_zipcode , ra.City as producer_city , p.Picture as product_image , p.Available as product_available , p.VisibleToConsumers as product_searchable , case when p.Conditioning = 1 then 'BOX' when p.Conditioning = 2 then 'BULK' when p.Conditioning = 3 then 'BOUQUET' when p.Conditioning = 4 then 'BUNCH' when p.Conditioning = 5 then 'PIECE' when p.Conditioning = 6 then 'BASKET' end as product_conditioning , app.InlineMax(app.InlineMax(app.InlineMax(p.UpdatedOn, r.UpdatedOn), t.UpdatedOn), p.CreatedOn) as last_update , case when (app.InlineMax(p.RemovedOn, r.RemovedOn)) is not null or r.CanDirectSell = 0 then 1 else 0 end as removed , '[' + STRING_AGG('\"' + LOWER(t.Name) + '\"', ',') + ']' as product_tags , ra.Longitude as producer_longitude , ra.Latitude as producer_latitude , geography::STGeomFromText('POINT('+convert(varchar(20),ra.Longitude)+' '+convert(varchar(20),ra.Latitude)+')',4326) as producer_geolocation from app.Products p join app.Users r on r.Uid = p.ProducerUid and r.Kind = 0 join app.UserAddresses ra on r.Uid = ra.UserUid left join app.ProductTags pt on p.Uid = pt.ProductUid left join app.Returnables pa on pa.Uid = p.ReturnableUid left join app.Tags t on t.Uid = pt.TagUid group by p.Id, p.Name, case when p.Unit = 1 then 'mL' when p.Unit = 2 then 'L' when p.Unit = 3 then 'g' when p.Unit = 4 then 'kg' end, CAST(p.QuantityPerUnit as float), CAST(p.OnSalePricePerUnit as float), CAST(p.OnSalePrice as float), CAST(p.WholeSalePrice as float), CAST(p.Rating as float), p.RatingsCount, case when pa.Uid is not null then cast(1 as bit) else cast(0 as bit) end, r.Id, r.Name, r.Email, p.Picture, case when p.Conditioning = 1 then 'BOX' when p.Conditioning = 2 then 'BULK' when p.Conditioning = 3 then 'BOUQUET' when p.Conditioning = 4 then 'BUNCH' when p.Conditioning = 5 then 'PIECE' when p.Conditioning = 6 then 'BASKET' end, r.Id, r.Phone, p.Available, p.VisibleToConsumers, ra.Zipcode, ra.City, app.InlineMax(app.InlineMax(app.InlineMax(p.UpdatedOn, r.UpdatedOn), t.UpdatedOn), p.CreatedOn), case when (app.InlineMax(p.RemovedOn, r.RemovedOn)) is not null or r.CanDirectSell = 0 then 1 else 0 end, ra.Longitude, ra.Latitude");
migrationBuilder.Sql("CREATE VIEW [app].ProductsSearch as select p.Id as product_id , p.Name as product_name , p.Name as partialProductName , CAST(p.QuantityPerUnit as float) as product_quantityPerUnit , case when p.Unit = 1 then 'mL' when p.Unit = 2 then 'L' when p.Unit = 3 then 'g' when p.Unit = 4 then 'kg' end as product_unit , CAST(p.OnSalePricePerUnit as float) as product_onSalePricePerUnit , CAST(p.OnSalePrice as float) as product_onSalePrice , CAST(p.Rating as float) as product_rating , p.RatingsCount as product_ratings_count , case when pa.Uid is not null then cast(1 as bit) else cast(0 as bit) end as product_returnable , r.Id as producer_id , r.Name as producer_name, r.Name as partialProducerName , r.Email as producer_email , r.Phone as producer_phone , ra.Zipcode as producer_zipcode , ra.City as producer_city , p.Picture as product_image , p.Available as product_available , p.VisibleToConsumers as product_searchable , case when p.Conditioning = 1 then 'BOX' when p.Conditioning = 2 then 'BULK' when p.Conditioning = 3 then 'BOUQUET' when p.Conditioning = 4 then 'BUNCH' when p.Conditioning = 5 then 'PIECE' when p.Conditioning = 6 then 'BASKET' end as product_conditioning , app.InlineMax(app.InlineMax(app.InlineMax(p.UpdatedOn, r.UpdatedOn), t.UpdatedOn), p.CreatedOn) as last_update , case when (app.InlineMax(p.RemovedOn, r.RemovedOn)) is not null or r.CanDirectSell = 0 then 1 else 0 end as removed , '[' + STRING_AGG('\"' + LOWER(t.Name) + '\"', ',') + ']' as product_tags , ra.Longitude as producer_longitude , ra.Latitude as producer_latitude , geography::STGeomFromText('POINT('+convert(varchar(20),ra.Longitude)+' '+convert(varchar(20),ra.Latitude)+')',4326) as producer_geolocation from app.Products p join app.Users r on r.Uid = p.ProducerUid and r.Kind = 0 join app.UserAddresses ra on r.Uid = ra.UserUid left join app.ProductTags pt on p.Uid = pt.ProductUid left join app.Returnables pa on pa.Uid = p.ReturnableUid left join app.Tags t on t.Uid = pt.TagUid group by p.Id, p.Name, case when p.Unit = 1 then 'mL' when p.Unit = 2 then 'L' when p.Unit = 3 then 'g' when p.Unit = 4 then 'kg' end, CAST(p.QuantityPerUnit as float), CAST(p.OnSalePricePerUnit as float), CAST(p.OnSalePrice as float), CAST(p.WholeSalePrice as float), CAST(p.Rating as float), p.RatingsCount, case when pa.Uid is not null then cast(1 as bit) else cast(0 as bit) end, r.Id, r.Name, r.Email, p.Picture, case when p.Conditioning = 1 then 'BOX' when p.Conditioning = 2 then 'BULK' when p.Conditioning = 3 then 'BOUQUET' when p.Conditioning = 4 then 'BUNCH' when p.Conditioning = 5 then 'PIECE' when p.Conditioning = 6 then 'BASKET' end, r.Id, r.Phone, p.Available, p.VisibleToConsumers, ra.Zipcode, ra.City, app.InlineMax(app.InlineMax(app.InlineMax(p.UpdatedOn, r.UpdatedOn), t.UpdatedOn), p.CreatedOn), case when (app.InlineMax(p.RemovedOn, r.RemovedOn)) is not null or r.CanDirectSell = 0 then 1 else 0 end, ra.Longitude, ra.Latitude");
migrationBuilder.Sql("CREATE VIEW [app].StoresSearch as select r.Id as store_id , r.Name as store_name , r.Name as partialStoreName , r.Email as store_email , r.Picture as store_picture , r.Phone as store_phone , ra.Line1 as store_line1 , ra.Line2 as store_line2 , ra.Zipcode as store_zipcode , ra.City as store_city , app.InlineMax(r.CreatedOn, app.InlineMax(r.UpdatedOn, t.UpdatedOn)) as last_update , case when r.RemovedOn is null then 0 else 1 end as removed , '[' + STRING_AGG('\"' + LOWER(t.Name) + '\"', ',') + ']' as store_tags , ra.Longitude as store_longitude , ra.Latitude as store_latitude , geography::STGeomFromText('POINT('+convert(varchar(20),ra.Longitude)+' '+convert(varchar(20),ra.Latitude)+')',4326) as store_geolocation from app.Users r join app.UserAddresses ra on r.Uid = ra.UserUid left join app.StoreTags ct on r.Uid = ct.StoreUid left join app.Tags t on t.Uid = ct.TagUid where r.Kind = 1 and r.OpenForNewBusiness = 1 group by r.Id, r.Name, r.Email, r.Picture, r.Phone, ra.Line1, ra.Line2, ra.Zipcode, ra.City, app.InlineMax(r.CreatedOn, app.InlineMax(r.UpdatedOn, t.UpdatedOn)), case when r.RemovedOn is null then 0 else 1 end, ra.Longitude, ra.Latitude");

migrationBuilder.Sql("CREATE SCHEMA [Cache]");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,21 @@ POST https://sheaft-search.search.windows.net/indexes?api-version=2020-06-30&all
"synonymMaps": [],
"fields": []
},
{
"name": "partialProducerName",
"type": "Edm.String",
"facetable": false,
"filterable": false,
"key": false,
"retrievable": false,
"searchable": true,
"sortable": false,
"analyzer": null,
"indexAnalyzer": "prefixCmAnalyzer",
"searchAnalyzer": "standardCmAnalyzer",
"synonymMaps": [],
"fields": []
},
{
"name": "packaging_name",
"type": "Edm.String",
Expand Down
Loading

0 comments on commit c134f78

Please sign in to comment.