kopia lustrzana https://github.com/bugout-dev/moonstream
				
				
				
			
						commit
						d075aec465
					
				|  | @ -84,6 +84,8 @@ async def get_transaction_in_blocks( | |||
|         .filter(filters) | ||||
|     ) | ||||
| 
 | ||||
|     ethereum_transactions = ethereum_transactions_in_subscriptions | ||||
| 
 | ||||
|     # If not start_time and end_time not present | ||||
|     # Get latest transaction | ||||
|     if boundaries.end_time == 0: | ||||
|  | @ -92,10 +94,11 @@ async def get_transaction_in_blocks( | |||
|                 text("timestamp desc") | ||||
|             ).limit(1) | ||||
|         ).one_or_none() | ||||
|         boundaries.end_time = ethereum_transaction_start_point[-1] | ||||
|         boundaries.start_time = ( | ||||
|             ethereum_transaction_start_point[-1] - DEFAULT_STREAM_TIMEINTERVAL | ||||
|         ) | ||||
|         if ethereum_transaction_start_point: | ||||
|             boundaries.end_time = ethereum_transaction_start_point[-1] | ||||
|             boundaries.start_time = ( | ||||
|                 ethereum_transaction_start_point[-1] - DEFAULT_STREAM_TIMEINTERVAL | ||||
|             ) | ||||
| 
 | ||||
|     if boundaries.start_time != 0 and boundaries.end_time != 0: | ||||
|         if boundaries.start_time > boundaries.end_time: | ||||
|  | @ -105,7 +108,7 @@ async def get_transaction_in_blocks( | |||
|             ) | ||||
| 
 | ||||
|     if boundaries.end_time: | ||||
|         ethereum_transactions = ethereum_transactions_in_subscriptions.filter( | ||||
|         ethereum_transactions = ethereum_transactions.filter( | ||||
|             include_or_not_lower( | ||||
|                 EthereumBlock.timestamp, boundaries.include_end, boundaries.end_time | ||||
|             ) | ||||
|  |  | |||
|  | @ -60,10 +60,10 @@ app.add_middleware(BroodAuthMiddleware, whitelist=whitelist_paths) | |||
| async def search_transactions( | ||||
|     request: Request, | ||||
|     q: str = Query(""), | ||||
|     start_time: Optional[int] = Query(0),  # Optional[int] = Query(0),  # | ||||
|     end_time: Optional[int] = Query(0),  # Optional[int] = Query(0),  # | ||||
|     include_start: bool = Query(False), | ||||
|     include_end: bool = Query(False), | ||||
|     start_time: Optional[int] = Query(0), | ||||
|     end_time: Optional[int] = Query(0), | ||||
|     include_start: Optional[bool] = Query(False), | ||||
|     include_end: Optional[bool] = Query(False), | ||||
|     db_session: Session = Depends(db.yield_db_session), | ||||
| ): | ||||
| 
 | ||||
|  | @ -87,8 +87,6 @@ async def search_transactions( | |||
|         for resource in user_subscriptions_resources.resources | ||||
|     } | ||||
| 
 | ||||
|     # transactions: List[Any] = [] | ||||
| 
 | ||||
|     boundaries = data.PageBoundary( | ||||
|         start_time=start_time, | ||||
|         end_time=end_time, | ||||
|  | @ -97,17 +95,14 @@ async def search_transactions( | |||
|         include_start=include_start, | ||||
|         include_end=include_end, | ||||
|     ) | ||||
|     print(boundaries) | ||||
| 
 | ||||
|     if address_to_subscriptions: | ||||
|         print("address_to_subscriptions") | ||||
|         response = await actions.get_transaction_in_blocks( | ||||
|             db_session=db_session, | ||||
|             query=q, | ||||
|             user_subscriptions_resources_by_address=address_to_subscriptions, | ||||
|             boundaries=boundaries, | ||||
|         ) | ||||
|         print(response.boundaries) | ||||
| 
 | ||||
|         return response | ||||
|     else: | ||||
|  |  | |||
|  | @ -174,12 +174,6 @@ const EntriesNavigation = () => { | |||
|   //   }
 | ||||
|   // };
 | ||||
| 
 | ||||
|   useEffect(() => { | ||||
|     if (!streamBoundary.start_time && !streamBoundary.end_time) { | ||||
|       refetch(); | ||||
|     } | ||||
|   }, [streamBoundary]); | ||||
| 
 | ||||
|   const setFilterProps = useCallback( | ||||
|     (filterIdx, props) => { | ||||
|       const newFilterProps = [...newFilterState]; | ||||
|  | @ -192,7 +186,7 @@ const EntriesNavigation = () => { | |||
|   useEffect(() => { | ||||
|     if ( | ||||
|       subscriptionsCache.data?.subscriptions[0]?.id && | ||||
|       newFilterState[0].value === null | ||||
|       newFilterState[0]?.value === null | ||||
|     ) { | ||||
|       setFilterProps(0, { | ||||
|         value: subscriptionsCache?.data?.subscriptions[0]?.address, | ||||
|  | @ -556,17 +550,19 @@ const EntriesNavigation = () => { | |||
|                   "" // some strange behaivior without else condition return 0 wich can see on frontend page
 | ||||
|                 )} | ||||
|               </Stack> | ||||
|               {entries.map((entry, idx) => ( | ||||
|                 <StreamEntry | ||||
|                   key={`entry-list-${idx}`} | ||||
|                   entry={entry} | ||||
|                   disableDelete={!canDelete} | ||||
|                   disableCopy={!canCreate} | ||||
|                   filterCallback={handleFilterStateCallback} | ||||
|                   filterConstants={{ DIRECTIONS, CONDITION, FILTER_TYPES }} | ||||
|                 /> | ||||
|               ))} | ||||
|               {streamBoundary.previous_event_time || isFetching ? ( | ||||
|               {entries | ||||
|                 ?.sort((a, b) => b.timestamp - a.timestamp) // TODO(Andrey) improve that for bi chunks of data sorting can take time
 | ||||
|                 .map((entry, idx) => ( | ||||
|                   <StreamEntry | ||||
|                     key={`entry-list-${idx}`} | ||||
|                     entry={entry} | ||||
|                     disableDelete={!canDelete} | ||||
|                     disableCopy={!canCreate} | ||||
|                     filterCallback={handleFilterStateCallback} | ||||
|                     filterConstants={{ DIRECTIONS, CONDITION, FILTER_TYPES }} | ||||
|                   /> | ||||
|                 ))} | ||||
|               {streamBoundary.previous_event_time && !isFetching ? ( | ||||
|                 <Center> | ||||
|                   <Button | ||||
|                     onClick={() => { | ||||
|  | @ -584,9 +580,20 @@ const EntriesNavigation = () => { | |||
|                   </Button> | ||||
|                 </Center> | ||||
|               ) : ( | ||||
|                 "" | ||||
|                 <Center> | ||||
|                   {!isFetching ? ( | ||||
|                     "Тransactions not found. You can subscribe to more addresses in Subscriptions menu." | ||||
|                   ) : ( | ||||
|                     <Button | ||||
|                       isLoading | ||||
|                       loadingText="Loading" | ||||
|                       variant="outline" | ||||
|                       colorScheme="suggested" | ||||
|                     ></Button> | ||||
|                   )} | ||||
|                 </Center> | ||||
|               )} | ||||
|               {streamBoundary.previous_event_time && isLoading && ( | ||||
|               {streamBoundary.previous_event_time && isLoading ? ( | ||||
|                 <Center> | ||||
|                   <Spinner | ||||
|                     //hidden={!isFetchingMore}
 | ||||
|  | @ -598,6 +605,8 @@ const EntriesNavigation = () => { | |||
|                     speed="1.5s" | ||||
|                   /> | ||||
|                 </Center> | ||||
|               ) : ( | ||||
|                 "" | ||||
|               )} | ||||
|             </Flex> | ||||
|           </Flex> | ||||
|  |  | |||
|  | @ -59,7 +59,7 @@ const SubscriptionsList = () => { | |||
|           {subscriptionsCache.data.subscriptions.map((subscription) => { | ||||
|             let iconLink; | ||||
|             switch (subscription.subscription_type_id) { | ||||
|               case "1": | ||||
|               case "0": | ||||
|                 iconLink = | ||||
|                   "https://ethereum.org/static/c48a5f760c34dfadcf05a208dab137cc/31987/eth-diamond-rainbow.png"; | ||||
|                 break; | ||||
|  |  | |||
|  | @ -43,6 +43,7 @@ const useJournalEntries = ({ | |||
|       //refetchInterval: refreshRate,
 | ||||
|       ...queryCacheProps, | ||||
|       keepPreviousData: true, | ||||
|       retry: 3, | ||||
|       onSuccess: (response) => { | ||||
|         // response is object which return condition in getStream
 | ||||
|         // TODO(andrey): Response should send page parameters inside "boundary" object (can be null).
 | ||||
|  |  | |||
|  | @ -9,15 +9,32 @@ export const getStream = ({ | |||
|   end_time, | ||||
|   include_start, | ||||
|   include_end, | ||||
| }) => | ||||
|   http({ | ||||
| }) => { | ||||
|   let params = {}; | ||||
| 
 | ||||
|   if (searchTerm) { | ||||
|     params.q = encodeURIComponent(searchTerm); | ||||
|   } | ||||
| 
 | ||||
|   if (start_time) { | ||||
|     params.start_time = encodeURIComponent(start_time); | ||||
|   } | ||||
| 
 | ||||
|   if (end_time) { | ||||
|     params.end_time = encodeURIComponent(end_time); | ||||
|   } | ||||
| 
 | ||||
|   if (include_start) { | ||||
|     params.include_start = encodeURIComponent(true); | ||||
|   } | ||||
| 
 | ||||
|   if (include_end) { | ||||
|     params.include_end = encodeURIComponent(true); | ||||
|   } | ||||
| 
 | ||||
|   return http({ | ||||
|     method: "GET", | ||||
|     url: `${API}/streams/`, | ||||
|     params: { | ||||
|       q: searchTerm, | ||||
|       start_time: start_time, | ||||
|       end_time: end_time, | ||||
|       include_start: include_start, | ||||
|       include_end: include_end, | ||||
|     }, | ||||
|     params: params, | ||||
|   }); | ||||
| }; | ||||
|  |  | |||
		Ładowanie…
	
		Reference in New Issue
	
	 Neeraj Kashyap
						Neeraj Kashyap