@@ -115,7 +115,7 @@ private IMongoCollection<ConversationContentLogDocument> CreateContentLogIndex()
115115 {
116116 var collection = GetCollectionOrCreate < ConversationContentLogDocument > ( "ConversationContentLogs" ) ;
117117 var indexes = collection . Indexes . List ( ) . ToList ( ) ;
118- var createTimeIndex = indexes . FirstOrDefault ( x => x . GetElement ( "name" ) . ToString ( ) . StartsWith ( "CreateTime " ) ) ;
118+ var createTimeIndex = indexes . FirstOrDefault ( x => x . GetElement ( "name" ) . ToString ( ) . StartsWith ( "CreatedTime " ) ) ;
119119 if ( createTimeIndex == null )
120120 {
121121 var indexDef = Builders < ConversationContentLogDocument > . IndexKeys . Ascending ( x => x . CreatedTime ) ;
@@ -128,14 +128,27 @@ private IMongoCollection<ConversationStateLogDocument> CreateStateLogIndex()
128128 {
129129 var collection = GetCollectionOrCreate < ConversationStateLogDocument > ( "ConversationStateLogs" ) ;
130130 var indexes = collection . Indexes . List ( ) . ToList ( ) ;
131- var createTimeIndex = indexes . FirstOrDefault ( x => x . GetElement ( "name" ) . ToString ( ) . StartsWith ( "CreateTime " ) ) ;
131+ var createTimeIndex = indexes . FirstOrDefault ( x => x . GetElement ( "name" ) . ToString ( ) . StartsWith ( "CreatedTime " ) ) ;
132132 if ( createTimeIndex == null )
133133 {
134134 var indexDef = Builders < ConversationStateLogDocument > . IndexKeys . Ascending ( x => x . CreatedTime ) ;
135135 collection . Indexes . CreateOne ( new CreateIndexModel < ConversationStateLogDocument > ( indexDef ) ) ;
136136 }
137137 return collection ;
138138 }
139+
140+ private IMongoCollection < InstructionLogDocument > CreateInstructionLogIndex ( )
141+ {
142+ var collection = GetCollectionOrCreate < InstructionLogDocument > ( "InstructionLogs" ) ;
143+ var indexes = collection . Indexes . List ( ) . ToList ( ) ;
144+ var createTimeIndex = indexes . FirstOrDefault ( x => x . GetElement ( "name" ) . ToString ( ) . StartsWith ( "CreatedTime" ) ) ;
145+ if ( createTimeIndex == null )
146+ {
147+ var indexDef = Builders < InstructionLogDocument > . IndexKeys . Descending ( x => x . CreatedTime ) ;
148+ collection . Indexes . CreateOne ( new CreateIndexModel < InstructionLogDocument > ( indexDef ) ) ;
149+ }
150+ return collection ;
151+ }
139152 #endregion
140153 #endregion
141154
@@ -193,6 +206,6 @@ public IMongoCollection<CrontabItemDocument> CrontabItems
193206 public IMongoCollection < GlobalStatisticsDocument > GlobalStatistics
194207 => GetCollectionOrCreate < GlobalStatisticsDocument > ( "GlobalStatistics" ) ;
195208
196- public IMongoCollection < InstructionLogBetaDocument > InstructionLogs
197- => GetCollectionOrCreate < InstructionLogBetaDocument > ( "InstructionLogs" ) ;
209+ public IMongoCollection < InstructionLogDocument > InstructionLogs
210+ => CreateInstructionLogIndex ( ) ;
198211}
0 commit comments