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
-- Optimize GROUP BY query to retrieve latest row per user | |
--https://dbfiddle.uk/men99GVd | |
begin; | |
create table users( | |
user_id bigint primary key generated always as identity | |
,username text not null | |
); | |
insert into users(username) select 'usr_'::text || g | |
from generate_series(1,1000) g; |
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
# https://pgbackrest.org/user-guide.html#pitr | |
/usr/local/pgsql15/bin/pg_ctl -D /usr/local/pgsql15/data_42091266 stop | |
#info check | |
sudo -u jian pgbackrest --stanza=pgsql15_3 --log-level-console=info check | |
sudo -u jian pgbackrest --stanza=pgsql15_3 --type=diff --log-level-console=info backup | |
/usr/local/pgsql15/bin/pg_ctl -D /usr/local/pgsql15/data_42091266 stop |
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
# https://pgbackrest.org/user-guide.html#introduction | |
#in psql. | |
show wal_level \; show archive_mode \; show max_wal_senders; | |
ALTER SYSTEM SET wal_level = replica; | |
ALTER SYSTEM SET archive_mode = on; | |
ALTER SYSTEM SET max_wal_senders = 3; | |
ALTER SYSTEM SET archive_command = 'pgbackrest --stanza=pgsql15_3 archive-push %p'; | |
#check the cluster status. |
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
package jian.he.bootstrap; | |
import jian.he.model.*; | |
import jian.he.services.*; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.boot.CommandLineRunner; | |
import org.springframework.stereotype.Component; | |
import java.time.LocalDate; |
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
package jian.he.formatters; | |
import jian.he.model.PetType; | |
import jian.he.services.PetTypeService; | |
import org.springframework.format.Formatter; | |
import org.springframework.stereotype.Component; | |
import java.text.ParseException; | |
import java.util.Collection; | |
import java.util.Locale; |
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
package jian.he.recipe.services; | |
import jian.he.recipe.commands.IngredientCommand; | |
import jian.he.recipe.converters.IngredientCommandToIngredient; | |
import jian.he.recipe.converters.IngredientToIngredientCommand; | |
import jian.he.recipe.domain.Ingredient; | |
import jian.he.recipe.domain.Recipe; | |
import jian.he.recipe.repositroies.RecipeRepository; | |
import jian.he.recipe.repositroies.UnitOfMeasureRepository; | |
import lombok.extern.slf4j.Slf4j; |
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
package jian.he.services.springdatajpa; | |
import jian.he.model.Owner; | |
import jian.he.repositories.OwnerRepository; | |
import jian.he.repositories.PetRepository; | |
import jian.he.repositories.PetTypeRepository; | |
import jian.he.services.OwnerService; | |
import org.springframework.context.annotation.Profile; | |
import org.springframework.stereotype.Service; | |
import java.util.HashSet; |
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
package jian.he.recipe.services; | |
import jian.he.recipe.domain.Recipe; | |
import jian.he.recipe.repositroies.RecipeRepository; | |
import org.junit.jupiter.api.BeforeEach; | |
import org.junit.jupiter.api.Test; | |
import org.mockito.Mock; | |
import org.mockito.MockitoAnnotations; | |
import java.util.HashSet; |
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
package jian.he.controllers; | |
import jian.he.services.OwnerService; | |
import org.springframework.stereotype.Controller; | |
import org.springframework.ui.Model; | |
import org.springframework.web.bind.annotation.GetMapping; | |
@Controller | |
public class OwnerController { | |
private final OwnerService ownerService; |
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
package jian.he.bootstrap; | |
import jian.he.model.Owner; | |
import jian.he.model.Vet; | |
import jian.he.services.OwnerService; | |
import jian.he.services.VetService; | |
import jian.he.services.map.OwnerServiceMap; | |
import jian.he.services.map.VetServiceMap; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.boot.CommandLineRunner; |