Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

search: no more duplicates

  • Loading branch information...
commit 446cb00d4a1e4cc9d56aefe4d7b0478323172656 1 parent e5bd8c8
@Martikos Martikos authored
Showing with 14 additions and 4 deletions.
  1. +14 −4 Views/Search.aspx.cs
View
18 Views/Search.aspx.cs
@@ -242,14 +242,19 @@ private List<Listing> searchWithTag(string word)
List<Listing> returnList = new List<Listing>();
List<Tag> taglist = TagDataService.getTagsByName(word);
+ HashSet<int> set = new HashSet<int>();
foreach (Tag tag in taglist)
{
String id = tag.id.ToString();
List<int> listingIds = ListingDataService.getListingOfTag(id);
foreach (int listingId in listingIds)
{
- Listing listing = ListingDataService.getListing(listingId.ToString());
- returnList.Add(listing);
+ if (!set.Contains(listingId))
+ {
+ Listing listing = ListingDataService.getListing(listingId.ToString());
+ returnList.Add(listing);
+ set.Add(listingId);
+ }
}
}
@@ -286,10 +291,15 @@ protected void doQuery(String q)
}
results.InnerHtml = all_results.Count + " results found";
+ HashSet<int> set = new HashSet<int>();
foreach (Listing listing in all_results)
{
- string objectHTML = createSearchItemDiv(listing);
- results.InnerHtml += objectHTML;
+ if (!set.Contains(listing.ListingId))
+ {
+ string objectHTML = createSearchItemDiv(listing);
+ results.InnerHtml += objectHTML;
+ set.Add(listing.ListingId);
+ }
}
}

0 comments on commit 446cb00

Please sign in to comment.
Something went wrong with that request. Please try again.