-
-
Save cobodo/485fd132a23e37fd76be7672023c7303 to your computer and use it in GitHub Desktop.
add query value 'has_media' patch for Krile 3.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/StarryEyes/Filters/Expressions/Values/Statuses/Booleans.cs b/StarryEyes/Filters/Expressions/Values/S | |
tatuses/Booleans.cs | |
index 39b2227..8b2c76c 100644 | |
--- a/StarryEyes/Filters/Expressions/Values/Statuses/Booleans.cs | |
+++ b/StarryEyes/Filters/Expressions/Values/Statuses/Booleans.cs | |
@@ -51,4 +51,35 @@ namespace StarryEyes.Filters.Expressions.Values.Statuses | |
} | |
} | |
+ public sealed class StatusHasMedia : ValueBase | |
+ { | |
+ public override IEnumerable<FilterExpressionType> SupportedTypes | |
+ { | |
+ get | |
+ { | |
+ yield return FilterExpressionType.Boolean; | |
+ } | |
+ } | |
+ public override Func<TwitterStatus, bool> GetBooleanValueProvider() | |
+ { | |
+ return st => | |
+ { | |
+ foreach (var entity in st.Entities) | |
+ { | |
+ if (entity.EntityType == EntityType.Media) return true; | |
+ } | |
+ return false; | |
+ }; | |
+ } | |
+ | |
+ public override string GetBooleanSqlQuery() | |
+ { | |
+ return "(SELECT COUNT(Id) FROM StatusEntity WHERE StatusEntity.ParentId = Status.Id AND StatusEntity | |
.EntityType = 0) > 0"; | |
+ } | |
+ | |
+ public override string ToQuery() | |
+ { | |
+ return "has_media"; | |
+ } | |
+ } | |
} | |
diff --git a/StarryEyes/Filters/Parsing/QueryCompiler.cs b/StarryEyes/Filters/Parsing/QueryCompiler.cs | |
index 92388db..a286ab2 100644 | |
--- a/StarryEyes/Filters/Parsing/QueryCompiler.cs | |
+++ b/StarryEyes/Filters/Parsing/QueryCompiler.cs | |
@@ -678,6 +678,8 @@ namespace StarryEyes.Filters.Parsing | |
case "source": | |
case "client": | |
return new StatusSource(); | |
+ case "has_media": | |
+ return new StatusHasMedia(); | |
default: | |
throw CreateUnexpectedTokenError(value, value + " " + reader.RemainQuery); | |
} | |
diff --git a/StarryEyes/Globalization/Filters/QueryCompletionResources.ja.resx b/StarryEyes/Globalization/Filters/QueryCompletionResources.ja.resx | |
index a14dc11..5f109f5 100644 | |
--- a/StarryEyes/Globalization/Filters/QueryCompletionResources.ja.resx | |
+++ b/StarryEyes/Globalization/Filters/QueryCompletionResources.ja.resx | |
@@ -216,6 +216,9 @@ | |
<data name="VariableFavorites" xml:space="preserve"> | |
<value>[Num/Set] 被お気に入り登録数/お気に入り登録済みユーザー</value> | |
</data> | |
+ <data name="VariableHasMedia" xml:space="preserve"> | |
+ <value>[Boolean] ステータスにメディアが添付されているか</value> | |
+ </data> | |
<data name="VariableId" xml:space="preserve"> | |
<value>[Numeric] ツイートのID</value> | |
</data> | |
diff --git a/StarryEyes/Globalization/Filters/QueryCompletionResources.resx b/StarryEyes/Globalization/Filters/QueryCompletionResources.resx | |
index dfdec9e..5b321f2 100644 | |
--- a/StarryEyes/Globalization/Filters/QueryCompletionResources.resx | |
+++ b/StarryEyes/Globalization/Filters/QueryCompletionResources.resx | |
@@ -216,6 +216,9 @@ | |
<data name="VariableFavorites" xml:space="preserve"> | |
<value>[Num/Set] Favorited count/favorited user ids</value> | |
</data> | |
+ <data name="VariableHasMedia" xml:space="preserve"> | |
+ <value>[Boolean] Status has media</value> | |
+ </data> | |
<data name="VariableId" xml:space="preserve"> | |
<value>[Numeric] ID of tweet</value> | |
</data> | |
diff --git a/StarryEyes/Views/Controls/QueryEditor.cs b/StarryEyes/Views/Controls/QueryEditor.cs | |
index 165ebe2..188197d 100644 | |
--- a/StarryEyes/Views/Controls/QueryEditor.cs | |
+++ b/StarryEyes/Views/Controls/QueryEditor.cs | |
@@ -347,6 +347,7 @@ namespace StarryEyes.Views.Controls | |
case "from": | |
case "source": | |
case "client": | |
+ case "has_media": | |
return true; | |
} | |
#endregion | |
@@ -380,7 +381,8 @@ namespace StarryEyes.Views.Controls | |
new CompletionData("to", QueryCompletionResources.VariableTo), | |
new CompletionData("favs", QueryCompletionResources.VariableFavorites), | |
new CompletionData("rts", QueryCompletionResources.VariableRetweets), | |
- new CompletionData("list", QueryCompletionResources.VariableList) | |
+ new CompletionData("list", QueryCompletionResources.VariableList), | |
+ new CompletionData("has_media", QueryCompletionResources.VariableHasMedia) | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment