Skip to content

Commit 0ecb000

Browse files
committed
Add polls query support and a test
1 parent 432547c commit 0ecb000

File tree

16 files changed

+450
-0
lines changed

16 files changed

+450
-0
lines changed

Assets/Plugins/StreamChat/Core/QueryBuilders/Filters/Polls.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System;
2+
3+
namespace StreamChat.Core.QueryBuilders.Filters.Polls
4+
{
5+
/// <summary>
6+
/// Filter by Poll CreatedAt timestamp
7+
/// </summary>
8+
public sealed class PollFieldCreatedAt : BaseFieldToFilter
9+
{
10+
public override string FieldName => "created_at";
11+
12+
/// <summary>
13+
/// Return only polls created AFTER the provided date
14+
/// </summary>
15+
public FieldFilterRule GreaterThan(DateTimeOffset date) => InternalGreaterThan(date);
16+
17+
/// <summary>
18+
/// Return only polls created AFTER OR ON the provided date
19+
/// </summary>
20+
public FieldFilterRule GreaterThanOrEquals(DateTimeOffset date) => InternalGreaterThanOrEquals(date);
21+
22+
/// <summary>
23+
/// Return only polls created BEFORE the provided date
24+
/// </summary>
25+
public FieldFilterRule LessThan(DateTimeOffset date) => InternalLessThan(date);
26+
27+
/// <summary>
28+
/// Return only polls created BEFORE OR ON the provided date
29+
/// </summary>
30+
public FieldFilterRule LessThanOrEquals(DateTimeOffset date) => InternalLessThanOrEquals(date);
31+
}
32+
}
33+

Assets/Plugins/StreamChat/Core/QueryBuilders/Filters/Polls/PollFieldCreatedAt.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using System.Collections.Generic;
2+
using System.Linq;
3+
using StreamChat.Core.StatefulModels;
4+
5+
namespace StreamChat.Core.QueryBuilders.Filters.Polls
6+
{
7+
/// <summary>
8+
/// Filter by Poll Id
9+
/// </summary>
10+
public sealed class PollFieldId : BaseFieldToFilter
11+
{
12+
public override string FieldName => "id";
13+
14+
/// <summary>
15+
/// Return only polls where Id is EQUAL to provided poll Id
16+
/// </summary>
17+
public FieldFilterRule EqualsTo(string pollId) => InternalEqualsTo(pollId);
18+
19+
/// <summary>
20+
/// Return only polls where Id is EQUAL to ANY of provided poll Ids
21+
/// </summary>
22+
public FieldFilterRule In(IEnumerable<string> pollIds) => InternalIn(pollIds);
23+
24+
/// <summary>
25+
/// Return only polls where Id is EQUAL to ANY of provided poll Ids
26+
/// </summary>
27+
public FieldFilterRule In(params string[] pollIds) => InternalIn(pollIds);
28+
29+
/// <summary>
30+
/// Return only polls where Id is EQUAL to ANY of the provided polls Id
31+
/// </summary>
32+
public FieldFilterRule In(IEnumerable<IStreamPoll> polls)
33+
=> InternalIn(polls.Select(_ => _.Id));
34+
35+
/// <summary>
36+
/// Return only polls where Id is EQUAL to ANY of the provided polls Id
37+
/// </summary>
38+
public FieldFilterRule In(params IStreamPoll[] polls)
39+
=> InternalIn(polls.Select(_ => _.Id));
40+
}
41+
}
42+

Assets/Plugins/StreamChat/Core/QueryBuilders/Filters/Polls/PollFieldId.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
namespace StreamChat.Core.QueryBuilders.Filters.Polls
2+
{
3+
/// <summary>
4+
/// Filter by Poll IsClosed status
5+
/// </summary>
6+
public sealed class PollFieldIsClosed : BaseFieldToFilter
7+
{
8+
public override string FieldName => "is_closed";
9+
10+
/// <summary>
11+
/// Return only polls where IsClosed status is EQUAL to the provided value
12+
/// </summary>
13+
public FieldFilterRule EqualsTo(bool isClosed) => InternalEqualsTo(isClosed);
14+
}
15+
}
16+

Assets/Plugins/StreamChat/Core/QueryBuilders/Filters/Polls/PollFieldIsClosed.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
namespace StreamChat.Core.QueryBuilders.Filters.Polls
2+
{
3+
/// <summary>
4+
/// Filter by Poll Name
5+
/// </summary>
6+
public sealed class PollFieldName : BaseFieldToFilter
7+
{
8+
public override string FieldName => "name";
9+
10+
/// <summary>
11+
/// Return only polls where Name is EQUAL to provided name
12+
/// </summary>
13+
public FieldFilterRule EqualsTo(string name) => InternalEqualsTo(name);
14+
15+
/// <summary>
16+
/// Return only polls where Name CONTAINS the provided substring (case-insensitive)
17+
/// </summary>
18+
public FieldFilterRule Autocomplete(string substring) => InternalAutocomplete(substring);
19+
}
20+
}
21+

Assets/Plugins/StreamChat/Core/QueryBuilders/Filters/Polls/PollFieldName.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System;
2+
3+
namespace StreamChat.Core.QueryBuilders.Filters.Polls
4+
{
5+
/// <summary>
6+
/// Filter by Poll UpdatedAt timestamp
7+
/// </summary>
8+
public sealed class PollFieldUpdatedAt : BaseFieldToFilter
9+
{
10+
public override string FieldName => "updated_at";
11+
12+
/// <summary>
13+
/// Return only polls updated AFTER the provided date
14+
/// </summary>
15+
public FieldFilterRule GreaterThan(DateTimeOffset date) => InternalGreaterThan(date);
16+
17+
/// <summary>
18+
/// Return only polls updated AFTER OR ON the provided date
19+
/// </summary>
20+
public FieldFilterRule GreaterThanOrEquals(DateTimeOffset date) => InternalGreaterThanOrEquals(date);
21+
22+
/// <summary>
23+
/// Return only polls updated BEFORE the provided date
24+
/// </summary>
25+
public FieldFilterRule LessThan(DateTimeOffset date) => InternalLessThan(date);
26+
27+
/// <summary>
28+
/// Return only polls updated BEFORE OR ON the provided date
29+
/// </summary>
30+
public FieldFilterRule LessThanOrEquals(DateTimeOffset date) => InternalLessThanOrEquals(date);
31+
}
32+
}
33+

0 commit comments

Comments
 (0)