File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -316,4 +316,28 @@ defmodule Algora.Settings do
316
316
def set_subscription_price ( price ) do
317
317
set ( "subscription" , % { "price" => Algora.MoneyUtils . serialize ( price ) } )
318
318
end
319
+
320
+ def get_campaign_timestamp do
321
+ case get ( "campaign_timestamp" ) do
322
+ % { "timestamp" => timestamp } when is_binary ( timestamp ) -> timestamp
323
+ _ -> nil
324
+ end
325
+ end
326
+
327
+ def set_campaign_timestamp ( timestamp ) when is_binary ( timestamp ) do
328
+ set ( "campaign_timestamp" , % { "timestamp" => timestamp } )
329
+ end
330
+
331
+ def update_campaign_timestamp do
332
+ timestamp = DateTime . utc_now ( ) |> format_timestamp ( )
333
+ set_campaign_timestamp ( timestamp )
334
+ end
335
+
336
+ defp format_timestamp ( datetime ) do
337
+ datetime
338
+ |> DateTime . to_string ( )
339
+ |> String . replace ( ~r/ \D / , "-" )
340
+ |> String . replace ( ~r/ -+/ , "-" )
341
+ |> String . trim_trailing ( "-" )
342
+ end
319
343
end
Original file line number Diff line number Diff line change
1
+ defmodule Algora.Repo.Migrations.AddCampaignTimestampToTalents do
2
+ use Ecto.Migration
3
+
4
+ def change do
5
+ alter table ( :talents ) do
6
+ add :campaign_timestamp , :string
7
+ end
8
+ end
9
+ end
You can’t perform that action at this time.
0 commit comments