• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Genfic / Ogma / 30078517903

24 Jul 2026 08:18AM UTC coverage: 1.208% (-0.06%) from 1.269%
30078517903

push

github

Atulin
Better Blogposts
- Excerpt generation is now much smarter
- Smarter for the server, since blogpost excerpt bodies are now fetched only up to the excerpt cutoff point, instead of fetching the whole body and splitting it on the client
- Smarter for the user, since they can control where the post gets cut off with `<!-- read more -->` marker (also available as a button)
- Better system for handling additional markdown toolbar buttons
- Initial database change in preparation for safety PIN
- Fixed Markdown rendering for blogposts, HTML comments are no longer visible, and spoilers now render properly
- Updated JS deppies

0 of 85 new or added lines in 11 files covered. (0.0%)

2394 existing lines in 92 files now uncovered.

358 of 29642 relevant lines covered (1.21%)

0.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/Ogma3/Infrastructure/SearchQueryParser/SearchQueryParser.cs
1
using System.Collections.Frozen;
2
using Utils.Extensions;
3

4
namespace Ogma3.Infrastructure.SearchQueryParser;
5

6
using LookupDict = FrozenDictionary<string, Func<string, bool, SearchToken>>;
7
using SubstitutionDict = FrozenDictionary<string, string>;
8

9
public static class SearchQueryParser
10
{
11
        private static readonly LookupDict FieldParsers =
×
12
                new Dictionary<string, Func<string, bool, SearchToken>>(StringComparer.OrdinalIgnoreCase)
×
13
                {
×
14
                        ["author"] = (val, neg) => new AuthorToken(val, neg),
×
15
                        ["status"] = (val, neg) => new StatusToken(val, neg),
×
UNCOV
16
                        ["rating"] = (val, neg) => new RatingToken(val, neg),
×
17
                }.ToFrozenDictionary();
×
18

UNCOV
19
        private static readonly LookupDict.AlternateLookup<ReadOnlySpan<char>> FieldLookup =
×
UNCOV
20
                FieldParsers.GetAlternateLookup<ReadOnlySpan<char>>();
×
21

22
        private static readonly SubstitutionDict NamespaceSubs = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
×
UNCOV
23
        {
×
24
                ["cw"] = "contentwarning",
×
25
                ["g"] = "genre",
×
UNCOV
26
                ["f"] = "franchise",
×
27
        }.ToFrozenDictionary();
×
28

29
        private static readonly SubstitutionDict.AlternateLookup<ReadOnlySpan<char>> SubstitutionLookup =
×
30
                NamespaceSubs.GetAlternateLookup<ReadOnlySpan<char>>();
×
31

32
        public static IReadOnlyList<SearchToken> Parse(ReadOnlySpan<char> query)
33
        {
34
                var tokens = new List<SearchToken>();
×
35

36
                var start = 0;
×
37
                var quoted = false;
×
38

UNCOV
39
                for (var i = 0; i < query.Length; i++)
×
40
                {
UNCOV
41
                        var curr = query[i];
×
UNCOV
42
                        switch (curr)
×
43
                        {
44
                                case '"':
UNCOV
45
                                        quoted = !quoted;
×
46
                                        continue;
×
UNCOV
47
                                case ',' when !quoted:
×
UNCOV
48
                                        TryAddToken(tokens, query[start..i]);
×
UNCOV
49
                                        start = i + 1;
×
50
                                        break;
51
                        }
52

53
                }
54

55
                // trailing
UNCOV
56
                TryAddToken(tokens, query[start..]);
×
57

58
                return tokens.AsReadOnly();
×
59
        }
60

61
        private static void TryAddToken(List<SearchToken> tokens, ReadOnlySpan<char> rawSegment)
62
        {
63
                var segment = rawSegment.Trim();
×
64
                if (segment.IsEmpty)
×
65
                {
66
                        return;
×
67
                }
68

69
                tokens.Add(ParseSegment(segment));
×
UNCOV
70
        }
×
71

72

73
        private static SearchToken ParseSegment(ReadOnlySpan<char> segment)
74
        {
75
                var negated = segment.StartsWith('-');
×
UNCOV
76
                segment = negated ? segment[1..] : segment;
×
77

UNCOV
78
                var colon = segment.IndexOf(':');
×
79

80
                // "some title"
81
                if (segment is ['"', .. var title, '"'])
×
82
                {
UNCOV
83
                        return new TitleToken(title.Trim().ToString());
×
84
                }
85

86
                // plain tag
UNCOV
87
                if (colon <= 0)
×
88
                {
UNCOV
89
                        return new TagToken(null, segment.Trim().ToString(), negated);
×
90
                }
91

92
                // key:value
UNCOV
93
                var key = segment[..colon].Trim();
×
UNCOV
94
                var val = segment[(colon + 1)..].Trim();
×
95

UNCOV
96
                if (FieldLookup.TryGetValue(key, out var fac))
×
97
                {
UNCOV
98
                        return fac(val.ToString(), negated);
×
99
                }
100

101
                // plain tag with namespace
UNCOV
102
                var trimmed = segment[..colon].Trim();
×
103

104
                // fast path: no spaces to remove, skip the stackalloc copy entirely
UNCOV
105
                if (trimmed.IndexOf(' ') < 0)
×
106
                {
UNCOV
107
                        var subbed = SubstitutionLookup.TryGetValue(trimmed, out var sub) ? sub : trimmed;
×
UNCOV
108
                        return new TagToken(subbed.ToString(), segment[(colon + 1)..].Trim().ToString(), negated);
×
109
                }
110

111
                // slow path: contains spaces, perform the stackalloc strip
UNCOV
112
                Span<char> buffer = stackalloc char[trimmed.Length];
×
UNCOV
113
                var ns = trimmed.RemoveChar(' ', buffer);
×
114

UNCOV
115
                var subbedClean = SubstitutionLookup.TryGetValue(ns, out var subClean) ? subClean : ns;
×
UNCOV
116
                return new TagToken(subbedClean.ToString(), segment[(colon + 1)..].Trim().ToString(), negated);
×
117
        }
118
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc