Safe Haskell | None |
---|---|
Language | Haskell2010 |
- pqSearchString :: Lens' PaginationQuery String
- pqOffset :: Lens' PaginationQuery Word64
- pqLimit :: Lens' PaginationQuery Word64
- prTotalCount :: forall a. Lens' (PaginationResults a) Word64
- prTimestamp :: forall a. Lens' (PaginationResults a) UTCTime
- prResults :: forall a a. Lens (PaginationResults a) (PaginationResults a) [a] [a]
- prOffset :: forall a. Lens' (PaginationResults a) Word64
- pvValue :: forall a a. Lens (CacheVal a) (CacheVal a) a a
- pvShouldStore :: forall a. Lens' (CacheVal a) Bool
- pvQuery :: forall a. Lens' (CacheVal a) PaginationQuery
- data PaginationQuery = PaginationQuery {}
- data PaginationResults a = PaginationResults {
- _prOffset :: Word64
- _prTotalCount :: Word64
- _prTimestamp :: UTCTime
- _prResults :: [a]
- type PaginationCache k v = Map k [CacheVal v]
- type PaginationInput k = (k, PaginationQuery)
- type PaginationOutput k v = (k, Maybe (CacheVal v))
- data CacheVal a = CacheVal {
- _pvQuery :: PaginationQuery
- _pvShouldStore :: Bool
- _pvValue :: a
- data PQParams = PQParams {}
- paginatedQuery :: forall t m k a. (MonadWidget t m, Show k, Ord k, FromJSON a) => PQParams -> (String -> a -> Bool) -> String -> Event t (Map String ByteString, PaginationInput k) -> m (Event t (Maybe (PaginationResults a)))
- addToCache :: Ord k => PQParams -> PaginationOutput k (PaginationResults v) -> PaginationCache k (PaginationResults v) -> PaginationCache k (PaginationResults v)
- prune :: Ord k => Int -> PaginationCache k (PaginationResults v) -> PaginationCache k (PaginationResults v)
- cachedQuery :: (MonadWidget t m, Show k, Ord k, FromJSON a) => (String -> a -> Bool) -> String -> PaginationCache k (PaginationResults a) -> (Map String ByteString, PaginationInput k) -> m (Event t (PaginationOutput k (PaginationResults a)))
- isSubSearch :: PaginationQuery -> CacheVal (PaginationResults a) -> Bool
Documentation
pqSearchString :: Lens' PaginationQuery String Source
pqOffset :: Lens' PaginationQuery Word64 Source
pqLimit :: Lens' PaginationQuery Word64 Source
prTotalCount :: forall a. Lens' (PaginationResults a) Word64 Source
prTimestamp :: forall a. Lens' (PaginationResults a) UTCTime Source
prResults :: forall a a. Lens (PaginationResults a) (PaginationResults a) [a] [a] Source
prOffset :: forall a. Lens' (PaginationResults a) Word64 Source
pvShouldStore :: forall a. Lens' (CacheVal a) Bool Source
pvQuery :: forall a. Lens' (CacheVal a) PaginationQuery Source
data PaginationQuery Source
General data structure needed for running queries with paginated results.
Eq PaginationQuery Source | |
Ord PaginationQuery Source | |
Read PaginationQuery Source | |
Show PaginationQuery Source | |
Default PaginationQuery Source | |
ToJSON PaginationQuery Source | |
FromJSON PaginationQuery Source |
data PaginationResults a Source
Data structure wrapping results.
PaginationResults | |
|
Eq a => Eq (PaginationResults a) Source | |
Ord a => Ord (PaginationResults a) Source | |
Read a => Read (PaginationResults a) Source | |
Show a => Show (PaginationResults a) Source | |
ToJSON a => ToJSON (PaginationResults a) Source | |
FromJSON a => FromJSON (PaginationResults a) Source |
type PaginationCache k v = Map k [CacheVal v] Source
type PaginationInput k = (k, PaginationQuery) Source
type PaginationOutput k v = (k, Maybe (CacheVal v)) Source
Along with the query results we also need to store the PaginationQuery structure that generated it as well as a flag indicating whether this data should be stored in the cache. This prevents results that are sub-searches of a previous search from overwriting the results of a more general query.
CacheVal | |
|
PQParams | |
|
:: (MonadWidget t m, Show k, Ord k, FromJSON a) | |
=> PQParams | |
-> (String -> a -> Bool) | |
-> String | |
-> Event t (Map String ByteString, PaginationInput k) | Param map and pagination structure. k is any additional information that you need to disambiguate multiple PaginationQuery entries. |
-> m (Event t (Maybe (PaginationResults a))) |
Paginated querying with built-in search and results caching.
addToCache :: Ord k => PQParams -> PaginationOutput k (PaginationResults v) -> PaginationCache k (PaginationResults v) -> PaginationCache k (PaginationResults v) Source
prune :: Ord k => Int -> PaginationCache k (PaginationResults v) -> PaginationCache k (PaginationResults v) Source
Prunes the PaginationCache of the oldest n entries. This is not the oldest (k,v) pairs. It is the oldest vs out of all the (k,[v]) pairs.
cachedQuery :: (MonadWidget t m, Show k, Ord k, FromJSON a) => (String -> a -> Bool) -> String -> PaginationCache k (PaginationResults a) -> (Map String ByteString, PaginationInput k) -> m (Event t (PaginationOutput k (PaginationResults a))) Source
Checks a cache and makes a request to the supplied URL if the cached data cannot be used to serve the results of the current requested query.
:: PaginationQuery | |
-> CacheVal (PaginationResults a) | Cached query results |
-> Bool |
Checks whether a previous cached search string is a substring of the current search string. In this case we don't need to requery the server.