This file contains hidden or 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
| FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env | |
| # Set working directory | |
| WORKDIR /app | |
| # Copy source code | |
| COPY . ./ | |
| # Restore packages | |
| RUN cd src && dotnet restore |
This file contains hidden or 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
| using System; | |
| using System.IO; | |
| using System.Linq; | |
| using Microsoft.Extensions.DependencyInjection; | |
| using Microsoft.OpenApi.Models; | |
| using Microsoft.AspNetCore.Builder; | |
| using Swashbuckle.AspNetCore.SwaggerGen; | |
| namespace DayHiker.API.Helpers | |
| { |
This file contains hidden or 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
| using Microsoft.EntityFrameworkCore; | |
| namespace DataConverter | |
| { | |
| public class DataConverterContext : DbContext | |
| { | |
| public DbSet<User> Users { get; set; } | |
| public DataConverterContext(DbContextOptions opts) : base(opts) { } |
This file contains hidden or 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
| using System; | |
| using System.Collections.Generic; | |
| using System.Threading.Tasks; | |
| using Microsoft.EntityFrameworkCore; | |
| namespace DataConverter | |
| { | |
| class Program | |
| { | |
| static string NpgsqlConnectionString => Environment.GetEnvironmentVariable("PSQL_CONN"); |
This file contains hidden or 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
| using System; | |
| using System.Linq; | |
| using System.Text; | |
| using SMBLibrary; | |
| namespace FileShare.Access | |
| { | |
| public interface IClientDTO | |
| { | |
| string IPAddress { get; set; } |
This file contains hidden or 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
| class Category < ApplicationRecord | |
| has_many :article_categories, class_name: ArticleCategory, foreign_key: :category_id, dependent: :destroy | |
| has_many :articles, through: :article_categories | |
| end | |
| class Article < ApplicationRecord | |
| belongs_to :author, class_name: User, foreign_key: :author_id | |
| has_many :article_categories, class_name: ArticleCategory, foreign_key: :article_id, dependent: :destroy | |
| has_many :categories, through: :article_categories | |
| has_many :images, class_name: ArticleImage, foreign_key: :article_id, dependent: :destroy |
This file contains hidden or 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
| RSpec.describe UpdateCounterCachesJob, type: :job do | |
| it 'updates all cache columns when they are out of sync' do sql = <<-SQL update categories SET articles_count = 5 SQL | |
| category = create(:category) | |
| ActiveRecord::Base.connection.execute(sql) | |
| category.reload | |
| expect(category.articles_count).to eq(5) | |
| UpdateCounterCachesJob.perform_now | |
| category.reload | |
| expect(category.articles_count).to eq(0) | |
| end |
This file contains hidden or 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
| { "category": [ "article_categories" ] } |
This file contains hidden or 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
| class UpdateCounterCacheJob < ApplicationJob attr_accessor :cache_columns | |
| def perform(key = 'all') | |
| self.cache_columns = counter_cache_hash | |
| if key == 'all' | |
| cache_columns.keys.each { |obj| update_cache_columns(obj) } | |
| else | |
| update_cache_columns(key) | |
| end | |
| end |
NewerOlder