@@ -90,17 +90,16 @@ def next_set(token_string)
9090 # select a subset of the result set, and return it with a
9191 # resumption token to get the next subset
9292 def select_partial ( token )
93- if 0 == token . last
94- oaitoken = OaiToken . find_or_create_by ( token : token . to_s )
95- if oaitoken . new_record_before_save ?
96- OaiToken . connection . execute ( "insert into " +
97- " #{ OaiEntry . table_name } (oai_token_id, record_id) " +
98- "select #{ oaitoken . id } , id from #{ model . table_name } where " +
99- " #{ OaiToken . sanitize_sql ( token_conditions ( token ) ) } " )
100- end
93+ oaitoken = OaiToken . find_by ( token : token . to_s )
94+
95+ if 0 == token . last && oaitoken . nil ?
96+ oaitoken = OaiToken . create! ( token : token . to_s )
97+ OaiToken . connection . execute ( "insert into " +
98+ " #{ OaiEntry . table_name } (oai_token_id, record_id) " +
99+ "select #{ oaitoken . id } , id from #{ model . table_name } where " +
100+ " #{ OaiToken . sanitize_sql ( token_conditions ( token ) ) } " )
101101 end
102102
103- oaitoken = OaiToken . find_by_token ( token . to_s )
104103 raise ResumptionTokenException . new unless oaitoken
105104
106105 PartialResult . new (
@@ -111,7 +110,7 @@ def select_partial(token)
111110 end
112111
113112 def sweep_cache
114- OaiToken . destroy_all ( [ "created_at < ?" , Time . now - expire ] )
113+ OaiToken . where ( [ "created_at < ?" , Time . now - expire ] ) . destroy_all
115114 end
116115
117116 def hydrate_records ( records )
0 commit comments