Skip to content

Commit

Permalink
Fixes naming changes regarding thumbnail<>screenshot.
Browse files Browse the repository at this point in the history
  • Loading branch information
m2w committed Sep 25, 2013
1 parent fc700f8 commit 97fda27
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include/models.hrl
Expand Up @@ -27,7 +27,7 @@
last_modified :: unix_timestamp(),
is_banned=false :: boolean(),
flag_count=0 :: non_neg_integer(),
has_screenshot=false :: boolean()}).
has_thumbnail=false :: boolean()}).

%% @doc Contains all information on a shortened URL.
%% This includes links to all related data.
Expand Down
10 changes: 8 additions & 2 deletions src/erli_storage.erl
Expand Up @@ -167,21 +167,27 @@ setup_tables(Nodes) ->
targets_requiring_thumbnail() ->
list_missing_thumbs() ++ list_outdated_thumbs().


-spec thumbnail_generated(#target{}) -> ok.
thumbnail_generated(Target) ->
NT = Target#target{has_thumbnail=true},
ok.

%%-----------------------------------------------------------
%% Internal Methods
%%-----------------------------------------------------------

-spec list_missing_thumbs() -> [#target{}].
list_missing_thumbs() ->
mnesia:dirty_select(targets, [{#target{has_screenshot='$1', _='_'},
mnesia:dirty_select(targets, [{#target{has_thumbnail='$1', _='_'},
[{'=:=', '$1', false}], ['$_']}]).

-spec list_outdated_thumbs() -> [#target{}].
list_outdated_thumbs() ->
Lim = erli_utils:get_env(thumbnail_age_limit),
MaxAge = erli_utils:unix_timestamp() - Lim*24*60*60,
mnesia:dirty_select(targets,
[{#target{last_modified='$1', has_screenshot='$2', _='_'},
[{#target{last_modified='$1', has_thumbnail='$2', _='_'},
[{'=<', '$1', MaxAge}, {'=:=', '$2', true}],
['$_']}]).

Expand Down

0 comments on commit 97fda27

Please sign in to comment.