Skip to content

Commit

Permalink
Merge pull request #578 from SharebookBR/meetups-youtube-only
Browse files Browse the repository at this point in the history
Poupando cota da api you tube.
  • Loading branch information
raffacabofrio authored Dec 23, 2024
2 parents 2bf7b7f + e4ff023 commit bcf3bed
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
17 changes: 14 additions & 3 deletions ShareBook/ShareBook.Api/Controllers/OperationsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@ public class OperationsController : Controller
protected string _validToken;
readonly IEmailService _emailService;
private readonly IWebHostEnvironment _env;
private readonly IMemoryCache _cache;
private readonly IMemoryCache _cache;
private readonly IMeetupService _meetupService;

public OperationsController(IJobExecutor executor, IOptions<ServerSettings> settings, IEmailService emailService, IWebHostEnvironment env, IMemoryCache memoryCache)
public OperationsController(IJobExecutor executor, IOptions<ServerSettings> settings, IEmailService emailService, IWebHostEnvironment env, IMemoryCache memoryCache, IMeetupService meetupService)
{
_executor = executor;
_validToken = settings.Value.JobExecutorToken;
_emailService = emailService;
_env = env;
_cache = memoryCache;
_cache = memoryCache;
_meetupService = meetupService;
}

[HttpGet]
Expand Down Expand Up @@ -85,6 +87,15 @@ public async Task<IActionResult> EmailTestAsync([FromBody] EmailTestVM emailVM)

await _emailService.TestAsync(emailVM.Email, emailVM.Name);
return Ok();
}

[HttpPost("JobTest")]
[Authorize("Bearer")]
[AuthorizationFilter(Permissions.Permission.ApproveBook)] // adm
public async Task<IActionResult> JobTestAsync()
{
var logs = await _meetupService.FetchMeetupsAsync();
return Ok(logs);
}

protected bool _IsValidJobToken() => Request.Headers["Authorization"].ToString() == _validToken;
Expand Down
4 changes: 3 additions & 1 deletion ShareBook/ShareBook.Service/Meetup/MeetupService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ public async Task<IList<string>> FetchMeetupsAsync()
else
{
logs.Add($"O vídeo '{title}' já estava no banco de dados. Não fiz nada.");
logs.Add($"Paranda de carregar meetups. Apenas o delta interessa. ( poupando cota api you tube )");
break;
}

}
Expand Down Expand Up @@ -170,7 +172,7 @@ public async Task<IList<Meetup>> SearchAsync(string title)
{
return await _repository.Get()
.Where(m => m.Active && (m.Title.Contains(title) || m.Description.Contains(title)))
.OrderByDescending(m => m.CreationDate)
.OrderByDescending(m => m.StartDate)
.ToListAsync();
}
}
2 changes: 1 addition & 1 deletion ShareBook/Sharebook.Jobs/Jobs/4 - MeetupSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public MeetupSearch(IJobHistoryRepository jobHistoryRepo, IMeetupService meetupS
JobName = "MeetupSearch";
Description = "Atualiza a lista de Meetups do Sharebook com base no youtube.";
Interval = Interval.Dayly;
Active = false;
Active = true;
BestTimeToExecute = new TimeSpan(1, 0, 0);
_configuration = configuration;
}
Expand Down
2 changes: 1 addition & 1 deletion ShareBook/Sharebook.Jobs/Jobs/6 - MailSupressListUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public MailSupressListUpdate(
Description = @"Atualiza a lista de emails suprimidos. Essa lista serve para manter boa reputação do nosso
mailling. Além de ser um requisito da AWS.";
Interval = Interval.Dayly;
Active = true;
Active = false;
BestTimeToExecute = new TimeSpan(2, 0, 0);

_emailService = emailService;
Expand Down

0 comments on commit bcf3bed

Please sign in to comment.