GraphQL API and utilities for the rpdata project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1.2 KiB

  1. -- name: SelectLog :one
  2. SELECT * FROM log WHERE id=$1 OR short_id=$1 LIMIT 1;
  3. -- name: SelectLogs :many
  4. SELECT * FROM log
  5. WHERE (@filter_short_id::BOOL = false OR short_id = ANY(@short_ids::TEXT[]))
  6. AND (@filter_character_id::BOOL = false OR character_ids && (@character_ids::TEXT[]))
  7. AND (@filter_channel_name::BOOL = false OR channel_name = ANY(@channel_names::TEXT[]))
  8. AND (@filter_event_name::BOOL = false OR event_name = ANY(@event_names::TEXT[]))
  9. AND (@filter_open::BOOL = false OR open = @open::BOOL)
  10. AND (@filter_earlist_date::BOOL = false OR date >= @earliest_date::TIMESTAMP)
  11. AND (@filter_lastest_date::BOOL = false OR date <= @latest_date::TIMESTAMP)
  12. ORDER BY date
  13. LIMIT NULLIF(@limit_size::INT, 0);
  14. -- name: InsertLog :exec
  15. INSERT INTO log (id, short_id, character_ids, date, channel_name, event_name, title, description, open)
  16. VALUES (
  17. @id, @short_id, @character_ids, @date, @channel_name, @event_name, @title, @description, @open
  18. );
  19. -- name: UpdateLog :exec
  20. UPDATE log
  21. SET title = @title,
  22. event_name = @event_name,
  23. description = @description,
  24. open = @open,
  25. character_ids = @character_ids
  26. WHERE id = @id;
  27. -- name: DeleteLog :exec
  28. DELETE FROM log WHERE id=$1;