-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9932762
commit 5bea13c
Showing
3 changed files
with
19 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,23 +39,26 @@ public static class NyforvarvslistanFunction | |
}); | ||
|
||
private static readonly ElasticClient Client = new ElasticClient(ConnectionSettings); | ||
private static DateTime? lastRunDate = null; | ||
|
||
[FunctionName("NyforvarvslistanFunction")] | ||
public static void Run([TimerTrigger("0 0 7 * * *", RunOnStartup = true)] TimerInfo myTimer, ILogger log) | ||
{ | ||
try | ||
{ | ||
bool isStartup = myTimer.IsPastDue; | ||
|
||
if (isStartup || DateTime.UtcNow.Day == 1) | ||
if (lastRunDate != DateTime.UtcNow.Date && DateTime.UtcNow.Day == 1) | ||
{ | ||
lastRunDate = DateTime.UtcNow.Date; | ||
|
||
SetBackMinervaLastRun(log); | ||
Check warning on line 53 in func-nyforvarvslistan/NyforvarvslistanFunction.cs GitHub Actions / build-and-deploy
Check warning on line 53 in func-nyforvarvslistan/NyforvarvslistanFunction.cs GitHub Actions / build-and-deploy
|
||
Task.Delay(30000).Wait(); | ||
CreateLists(log); | ||
|
||
log.LogInformation("CreateLists executed successfully."); | ||
} | ||
else | ||
{ | ||
SetBackMinervaLastRun(log); | ||
log.LogInformation("CreateLists has already run today. Skipping execution."); | ||
} | ||
} | ||
catch (RequestFailedException ex) | ||
|
@@ -149,7 +152,7 @@ public static void CreateLists(ILogger log) | |
Description = source.SearchResultItem.Description, | ||
LibraryId = source.SearchResultItem.LibraryId, | ||
Category = getCategoryBasedOnClassification(source.Classification), | ||
PublicationCategory = source.PublicationCategories, | ||
// PublicationCategory = source.PublicationCategories, | ||
AgeGroup = (source.SearchResultItem.AgeGroup == "Adult" || source.SearchResultItem.AgeGroup == "General") ? "Adult" : "Juvenile", | ||
Language = source.SearchResultItem.Language, | ||
LibrisId = source.SearchResultItem.LibrisId, | ||
|
@@ -164,13 +167,16 @@ public static void CreateLists(ILogger log) | |
}).Where(book => book != null) | ||
.ToList(); | ||
|
||
foreach (var book in books) | ||
/* | ||
* foreach (var book in books) | ||
{ | ||
if (book.PublicationCategory.FirstOrDefault() == "Fiction") | ||
{ | ||
book.Category = "Skönlitteratur"; | ||
} | ||
} | ||
*/ | ||
|
||
|
||
var talkingBooks = books.Where(b => b.Format == "Talbok" || b.Format == "Talbok med text").ToList(); | ||
var brailleBooks = books.Where(b => b.Format == "Punktskriftsbok").ToList(); | ||
|
@@ -295,7 +301,7 @@ public static void CreateLists(ILogger log) | |
if (generatedFiles.Any()) | ||
{ | ||
SendEmailWithAttachments(generatedFiles.ToArray(), "[email protected]"); | ||
// SendEmailWithAttachments(generatedFiles.ToArray(), "[email protected]"); | ||
SendEmailWithAttachments(generatedFiles.ToArray(), "[email protected]"); | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters