Skip to content

Commit d9aab00

Browse files
committed
Merge branch 'develop'
2 parents e75fe8e + 3567792 commit d9aab00

11 files changed

+144
-158
lines changed

build/Package.nuspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package >
33
<metadata>
44
<id>Our.Umbraco.Look</id>
5-
<version>0.3.0</version>
5+
<version>0.4.0</version>
66
<authors>Hendy Racher</authors>
77
<owners>Hendy Racher</owners>
88
<licenseUrl>https://github.com/Hendy/umbraco-look/blob/master/LICENSE</licenseUrl>

src/Our.Umbraco.Look/Interfaces/IEnumerableWithTotal.cs

-16
This file was deleted.

src/Our.Umbraco.Look/Models/EnumerableWithTotal.cs

-53
This file was deleted.

src/Our.Umbraco.Look/Models/LookQuery.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ public class LookQuery
1515
/// </summary>
1616
public TagQuery TagQuery { get; set; } = new TagQuery();
1717

18-
///// <summary>
19-
/////
20-
///// </summary>
21-
//public DateQuery DateQuery { get; set; } = new DateQuery();
18+
/// <summary>
19+
/// Set a before and/or an after date
20+
/// </summary>
21+
public DateQuery DateQuery { get; set; } = new DateQuery();
2222

2323
///// <summary>
2424
/////
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
4+
namespace Our.Umbraco.Look.Models
5+
{
6+
public class LookResult : IEnumerable<LookMatch>
7+
{
8+
private IEnumerable<LookMatch> _lookMatches;
9+
10+
/// <summary>
11+
/// Expected total number of LookMatch objects in the enumerable
12+
/// </summary>
13+
public int Total { get; }
14+
15+
/// <summary>
16+
/// Constructor
17+
/// </summary>
18+
/// <param name="lookMatches"></param>
19+
/// <param name="total"></param>
20+
internal LookResult(IEnumerable<LookMatch> lookMatches, int total)
21+
{
22+
this._lookMatches = lookMatches;
23+
this.Total = total;
24+
}
25+
26+
public IEnumerator<LookMatch> GetEnumerator()
27+
{
28+
return this._lookMatches.GetEnumerator();
29+
}
30+
31+
IEnumerator IEnumerable.GetEnumerator()
32+
{
33+
return this.GetEnumerator();
34+
}
35+
}
36+
}

src/Our.Umbraco.Look/Models/SortOn.cs

+10-5
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,26 @@ public enum SortOn
55
/// <summary>
66
/// The Lucene result score (default)
77
/// </summary>
8-
Score,
8+
Score = 0,
99

1010
/// <summary>
1111
/// A Custom Name field (alpha-numeric sorting)
1212
/// </summary>
13-
Name,
13+
Name = 1,
1414

1515
/// <summary>
16-
/// A Custom Date field
16+
/// A Custom Date field - Old to New
1717
/// </summary>
18-
Date,
18+
DateAscending = 2,
19+
20+
/// <summary>
21+
/// A Custom Date field - New to Old
22+
/// </summary>
23+
DateDescending = 3,
1924

2025
/// <summary>
2126
/// Orders by distance (only if distance data avaialble, otherwise reverts back to score)
2227
/// </summary>
23-
Distance
28+
Distance = 4
2429
}
2530
}

src/Our.Umbraco.Look/Models/TagQuery.cs

-5
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,5 @@ public class TagQuery
1616
/////
1717
///// </summary>
1818
//public string[] NotTags { get; set; } = null;
19-
20-
/// <summary>
21-
/// Flag to indicate whether to return the tag colection for each result
22-
/// </summary>
23-
public bool GetTags { get; set; } = false;
2419
}
2520
}

src/Our.Umbraco.Look/Our.Umbraco.Look.csproj

+1-2
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,13 @@
207207
</ItemGroup>
208208
<ItemGroup>
209209
<Compile Include="Events\Indexing.cs" />
210-
<Compile Include="Interfaces\IEnumerableWithTotal.cs" />
211210
<Compile Include="LookConstants.cs" />
212211
<Compile Include="Models\DateQuery.cs" />
213212
<Compile Include="Models\Distance.cs" />
214213
<Compile Include="Models\DistanceUnit.cs" />
215-
<Compile Include="Models\EnumerableWithTotal.cs" />
216214
<Compile Include="Models\Location.cs" />
217215
<Compile Include="Models\LocationQuery.cs" />
216+
<Compile Include="Models\LookResult.cs" />
218217
<Compile Include="Models\NodeQuery.cs" />
219218
<Compile Include="Models\LookMatch.cs" />
220219
<Compile Include="Models\LookQuery.cs" />

src/Our.Umbraco.Look/Properties/AssemblyInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("0.3.0.0")]
36-
[assembly: AssemblyFileVersion("0.3.0.0")]
35+
[assembly: AssemblyVersion("0.4.0.0")]
36+
[assembly: AssemblyFileVersion("0.4.0.0")]

src/Our.Umbraco.Look/Services/LookIndexService.cs

+29-14
Original file line numberDiff line numberDiff line change
@@ -187,20 +187,35 @@ internal static void Index(IPublishedContent publishedContent, Document document
187187

188188
if (date != null)
189189
{
190-
// TODO: change to storing date type
191-
var ticks = date.Value.Ticks;
192-
193-
var dateField = new NumericField(
194-
LookConstants.DateField,
195-
Field.Store.YES,
196-
false)
197-
.SetLongValue(ticks);
198-
199-
var dateSortedField = new NumericField(
200-
LuceneIndexer.SortedFieldNamePrefix + LookConstants.DateField,
201-
Field.Store.NO, //we don't want to store the field because we're only using it to sort, not return data
202-
true)
203-
.SetLongValue(ticks);
190+
var dateValue = DateTools.DateToString(date.Value, DateTools.Resolution.SECOND);
191+
192+
var dateField = new Field(
193+
LookConstants.DateField,
194+
dateValue,
195+
Field.Store.YES,
196+
Field.Index.ANALYZED,
197+
Field.TermVector.YES);
198+
199+
var dateSortedField = new Field(
200+
LuceneIndexer.SortedFieldNamePrefix + LookConstants.DateField,
201+
dateValue,
202+
Field.Store.NO,
203+
Field.Index.NOT_ANALYZED,
204+
Field.TermVector.NO);
205+
206+
//var ticks = date.Value.Ticks;
207+
208+
//var dateField = new NumericField(
209+
// LookConstants.DateField,
210+
// Field.Store.YES,
211+
// false)
212+
// .SetLongValue(ticks);
213+
214+
//var dateSortedField = new NumericField(
215+
// LuceneIndexer.SortedFieldNamePrefix + LookConstants.DateField,
216+
// Field.Store.NO, //we don't want to store the field because we're only using it to sort, not return data
217+
// true)
218+
// .SetLongValue(ticks);
204219

205220
document.Add(dateField);
206221
document.Add(dateSortedField);

0 commit comments

Comments
 (0)